[rspec-users] ControllerExampleGroup.bypass_rescue

Lenny Marks lenny at aps.org
Wed Aug 10 11:13:15 EDT 2011

 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
        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... ?


More information about the rspec-users mailing list