[rspec-users] Rails Rendering diagnostics.rhtml in Controller Spec

David Chelimsky dchelimsky at gmail.com
Wed May 23 17:08:02 EDT 2007

On 5/23/07, Ryan Bates <bates.ryan at gmail.com> wrote:
> Forgive me if this isn't the proper list. It's specific to the rSpec
> Rails plugin.

This is the place. Welcome!

> The problem is, some controller actions are rendering the
> "diagnostics.rhtml" template when I'm expecting it to render something
> else in a controller spec. I'm assuming this is the template that
> displays the error message and a stack trace when an error is raised
> in the development environment.
> Is there anyway to see the error through rspec instead of the
> controller just rendering the diagnostics.rhtml template? I'm
> surprised this would even be rendered in the test environment.

Try overriding rescue_action as is done in rails controller tests:

# Re-raise errors caught by the controller.
class MyController; def rescue_action(e) raise e end; end

This used to be implicit, but we removed it because it overrode your
own definition of rescue_action.

If you want to do this for every controller, assuming you're on 1.0,
you can do this in spec/spec_helper.rb

Spec::Runner.configure do |config|
  config.before(:each) do
    controller.class.class_eval do
      define_method :rescue_action do |e|
        raise e


More information about the rspec-users mailing list