If you are rescuing an exception, test what the rescue does. Purposely cause the exception, then check the rescue does what it's supposed to.
Sent from my iPhone On Aug 10, 2011, at 11:13 AM, Lenny Marks <le...@aps.org> wrote: > As best I can tell, bypass_rescue from rspec-rails-1 is no longer part of > rspec-rails, '> 2'. I had been using it on occasion for things like: > > describe CorrespondencesController do > ... > describe '#show' do > it "should raise an AuthorizationError if current user is not the > correspondent " do > bypass_rescue > ... > expect { do_get }.to raise_error(AuthorizationError) > > I know there are conflicting opinions on whether or not it's a good idea to > directly check for exceptions this way, but I've always felt that this was > appropriate for testing a controller action in isolation where the > responsibility of the action under test was only to raise the error. > > Anyway, I couldn't find any recent references to this (not even in the > rspec-rails repo). Is there any way to do this in rspec-rails-2 or is the > official consensus to check only on response codes, etc... ? > > -lenny > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users