I have a User controller where users aren’t added with the usual
new/create
actions. I’m trying to set it so that it raises when ‘new’ is called
but it
doesn’t seem to be working - here’s the method, test and test result.
Can
anyone see why it’s not working?
#in controller
def new
raise “Users should be added with ‘batch_add’ rather than 'new”
end
#test
describe “/new” do
it “should raise an error when called” do
lambda{get(‘new’)}.should raise_error(RuntimeError)
end
end
#test report
‘Admin::UserController /new should raise an error when called’ FAILED
expected RuntimeError but nothing was raised
500? That’s internal server error. You could set up an expectation for
the
return, using a code you know isn’t right (200?), then see what the
actual
value is after you get the failing test.
So, now, “should_not be_success” passes ok, but should i be more
specific
and require a particular error code? If so, which would i get from a
get
call that’s failed because of a RuntimeError exception?
500? That’s internal server error. You could set up an expectation for the
return, using a code you know isn’t right (200?), then see what the actual
value is after you get the failing test.
So, now, “should_not be_success” passes ok, but should i be more specific
and require a particular error code? If so, which would i get from a get
call that’s failed because of a RuntimeError exception?
You should be able to discover that by specifying one (like 200) and
seeing what you get.