[rspec-users] [rspec-rails] Exception catching in controller

Yuriy Naidyon yurokle at gmail.com
Wed Feb 16 07:24:45 EST 2011

Hi folks. I'm currently using rspec-2.4.0 and rspec-rails-2.4.1.
In the controller I have the code like this (at least at two different

def some_action
  raise Exception if some_falsy_value
  @message = 'Error'

but when I do testing with rspec this exception doesn't proceeded by
controller, and I'm getting the following:

  1) SignupsController GET confirm_email should proceed unexpected errors
     Failure/Error: get :confirm_email, @params
     # ./app/controllers/signups_controller.rb:251:in `confirm_email'
     # ./spec/controllers/signups_controller_spec.rb:168:in `block (3
levels) in <top (required)>'

I saw in examples that we can do exceptions catching by contoller filters
like (rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found)
but I don't want to use this way, con my exceptions aren't controller wide,
they only related to some single action.
Also, it's my first email to mailing group, if I composed it incorrectly,
someone please let me know.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110216/4558d658/attachment-0001.html>

More information about the rspec-users mailing list