[rspec-devel] [cucumber] lib/cucumber/rails/world.rb redefining ActionController::Base#rescue_action

aslak hellesoy aslak.hellesoy at gmail.com
Tue Mar 24 18:45:49 EDT 2009

On Tue, Mar 24, 2009 at 10:46 PM, Matt Patterson <matt-lists at reprocessed.org
> wrote:

> Evening.
> I've got a question about the redefinition of
> ActionController::Base#rescue_action. Mainly, why? From the comment in the
> source it looks there was a pain point that this solved, but I can't figure
> out what that might be.
> My problem is this: I make heavy use of rescue_from to trap exceptional
> cases so I can 404, 401 or 500 as appropriate. I've got a Scenario which
> looks like this ('deleted' blog posts in this app aren't erased from the DB,
> they're marked deleted for auditing):
>  Scenario: Attempting to visit a deleted blog post
>    Given there is a blog post entitled "Look Ma no hands"
>    And the blog post "Look Ma no hands" has been marked as deleted
>    When I attempt to visit the Blog post page for "Look Ma no hands"
>    Then the response should be a 404 error
> That looks like a perfectly reasonable scenario to me, except that it blows
> up at "When I attempt to visit". The source for that step is:
> When /^I attempt to visit the Blog post page for "(.+)"$/ do |title|
>  visit entry_path(Entry.find_by_url_slug!(Digest::MD5.hexdigest(title)))
> end
> [Excuse the MD5 - it's just a way of maintaining readability in the
> scenarios without resorting to fixtures (I'm undecided about it as an
> approach, btw)]
> visit is exploding when my controller raises a FourOhFour error because a
> non-staff non-logged-in user shouldn't be able to see the page. I use
> rescue_from to render a special 404 template, but that's never reached
> because of the redefinition of rescue_action.
> This seems really counterintuitive to me: I expect that the integration
> tests will use the full stack, and even in my isolated controller specs I
> have to explicitly request that the normal rescue_action is bypassed. If
> there's a genuine pain point here that re-raising and not handling the
> exception solves then I'm sure I can find a different idiom for these kinds
> of scenarios, but I've spent 4 hours today trying to figure out what was
> broken: first in my app code then breaking out rdebug to find out what was
> really happening, which suggests to me that it's a non-obvious and confusing
> intervention.
> Anyway, sorry to sound so whingey. Like I said: if there's a genuine
> problem this approach solves, I'll find a new idiom and shut up. Otherwise,
> can this be changed?

I understand your situation - it's perfectly valid. Still, I think you are
the first person to bring this up. The vast majority of Cucumber users/Rails
developers don't rely on this kind of error handling, so raising errors
seems to be a sensible default.

There is currently no way to turn off that default. Can you provide a patch
(or a suggestion) that will let users optionally turn off the current


> Thanks,
> Matt
> --
>  Matt Patterson | Design & Code
>  <matt at reprocessed org> | http://www.reprocessed.org/
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-devel/attachments/20090324/6552b10f/attachment.html>

More information about the rspec-devel mailing list