[rspec-users] Example controller spec no worky?

Brad Carson lists at ruby-forum.com
Wed Feb 13 15:22:33 EST 2008

Jarkko Laine wrote:
> On 13.2.2008, at 21.09, Brad Carson <lists at ruby-forum.com> wrote:
>> - should not assign an event (ERROR - 3)
>> ActiveRecord::RecordNotFound in 'EventsController attempt to show
>> non-existing event should render 404'
>> ActiveRecord::RecordNotFound
>> Mind-boggling.
> The exception is never rescued. You'd have to catch the exception
> yourself, I think, and render the 404 page. I might be talking through
> my ass but I think the built in rescue of AR::RNF only works in
> production.
> //jarkko

I was led to believe Rails automatically handled RecordNotFounds with a 
404, meaning I didn't have to catch them myself.

I made sure requests weren't considered local in the test environment to 
trigger the 404 page instead of the debug info.  I tried putting a 
rescue_action_in_public in the application controller to handle the 
RecordNotFound and do the 404 render, just in case, but the spec won't 
pass unless I rescue the exception inside the show method, which doesn't 
seem right or necessary.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list