Trying to spec ExceptionNotifiable behavior

Hello List.

I’m trying to overwrite part of ExceptionNotifiable
(ExceptionNotification plugin) to render customized error 500 pages
based on browser agents.

For this, I’ve created a fake controller that inherits directly from

class FooExceptionController < ActionController::Base
include ExceptionNotifiable

this action should not fail, used for controller.expect_render(…)

def ok_action
render(:file => “#{RAILS_ROOT}/public/ok.html”)

this action should raise an unexpected exception

def fail_action
raise“manually raised exception”)

I’m running with RSpec 1.0.8 (pistoned as plugin) and respective
REL_1_0_8 rspec_on_rails
All the specs are ran with ‘script/spec -R -c spec’

This is my spec:

describe FooExceptionController, “dealing with exceptions” do
it “should succeed on a good action” do
get ‘ok_action’
response.should be_success

it “should render the action ok_action” do
controller.expect_render(:file => “#{RAILS_ROOT}/public/ok.html”)
get ‘ok_action’

Why we are getting the exception here?

shouldn’t be rspec passing it to rails to process it?

it “should fail on fail_action” do
lambda {
get ‘fail_action’
}.should raise_error(StandardError, /manually raised exception/)

it “should render error template” do
controller.expect_render(:file => “#{RAILS_ROOT}/public/500.html”)
get ‘fail_action’


First spec “should render the action ok_action” works ok, and the
controller render expectation do its work.

The second spec, isn’t right. I’m not trying to get the Exception to
catch it on Rspec, but actully let ExceptionNotifier do its job and
actually expect rendering of RAILS_ROOT/public/500.html, as shown in
the third spec.

Anyway, both 1 and 2, pass, but third fails with “manually raised
exception” on the output:

StandardError in ‘FooExceptionController dealing with exceptions
should render error template’
manually raised exception

I’ve looked all over, for 1.0.8 and 1.1.2, but the only reference I
could find is use_rails_error_handling! in rdoc, but no Spec::Runner
configuration option or before behavior that could be change.

What I’m doing wrong? What I’m missing?

Thanks in advance for your time.

Luis L.
Multimedia systems

A common mistake that people make when trying to design
something completely foolproof is to underestimate
the ingenuity of complete fools.
Douglas Adams

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs