[rspec-devel] [ rspec-Bugs-11508 ] Exceptions are not raised for Controller Specs

noreply at rubyforge.org noreply at rubyforge.org
Mon Jun 11 16:17:01 EDT 2007


Bugs item #11508, was opened at 2007-06-11 20:06
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11508&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Brian Takita (btakita)
Assigned to: Nobody (None)
Summary: Exceptions are not raised for Controller Specs

Initial Comment:
The issue is old_rescue_action is called if the exception is not a MockExpectationError. This makes it hard to find exceptions in controllers.

The standard Rails test behaviour is to always raise an exception.

It used to work in 0.9.4.

module ActionController
  module Rescue
    protected
    alias old_rescue_action rescue_action
    def rescue_action(exception)
      raise exception if exception.is_a?(Spec::Mocks::MockExpectationError)
      old_rescue_action(exception)
    end
  end
end


----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-06-11 20:17

Message:
If you run script/generate rspec you'll see the following in spec_helper.rb:

  config.before(:each, :behaviour_type => :controller) do
    raise_controller_errors
  end

That makes things work as you suspect, and allows you use your own rescue_action if you want to.

This is a bit experimental and hence not very well doc'd, so I'll leave this open. But you can use that for now.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11508&group_id=797


More information about the rspec-devel mailing list