[rspec-users] Example controller spec no worky?
Jarkko Laine
jarkko at jlaine.net
Wed Feb 13 14:58:02 EST 2008
On 13.2.2008, at 21.09, Brad Carson <lists at ruby-forum.com> wrote:
> Pat Maddox wrote:
>> Try
>>
>> Event.stub!(:find).and_raise(RecordNotFound)
>
> To my credit, I did try that (though ActiveRecord::RecordNotFound, of
> course) but then I get:
>
> EventsController attempt to show non-existing event
> - should render 404 (ERROR - 2)
> - 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
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
More information about the rspec-users
mailing list