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

David Chelimsky dchelimsky at gmail.com
Mon May 28 16:06:01 EDT 2007


On 5/23/07, Ryan Bates <bates.ryan at gmail.com> wrote:
> > I'm not in love w/ exactly that - but something like that. Any suggestions?
>
> Maybe call it "override_controller_rescue_action!" and have it default
> to that block?

For better or worse, I ended up calling it raise_controller_errors,
and didn't provide a re-definition hook. I think this makes things
more friendly. You can say this for one behaviour:

describe SomeController do
  raise_controller_errors
  ...
end

or this for all:

#in spec_helper.rb
Spec::Runner.configure do |config|
  config.before(:each, :behaviour_type => :controller) do
    raise_controller_errors
  end
end

This config gets set up for you by default when you say "script/generate rspec".

Cheers,
David

>
> --
> Spec::Runner.configure do |config|
>   config.override_controller_rescue_action!
> end
> --
>
> A block could then be optionally passed to change its behavior if you
> don't want to simply raise the exception. You may also want to have it
> alias the old rescue_action method in case someone wants to call it?
> Hmm.
>
> Whatever the case, I do think there should be an easy way to do this
> and maybe mention something in the comments in the config file. I
> imagine the majority of Rails projects would want to set this?
>
> Ryan
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list