Forum: RSpec bypass_rescue and its inverse

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
828784c46bc7ed3d9cc7a46aac85e37a?d=identicon&s=25 Matt Patterson (Guest)
on 2009-03-20 07:51
(Received via mailing list)
Hey,

I've just started using rspec-rails 1.2 and the bypass rescue
declaration is wonderful - by default I tend to write controller which
raise exceptions (in exceptional circumstances), along with before-
filters as guard clauses, so being able to switch off rescue from
(which I properly spec separately) is a real boon.

Such a boon, in fact, that I immediately shoved it into a global
before :each block so that my controller specs would do what I expect
by default.

However, that makes my speccing of the rescue_from code a little
trickier. Is there an easy way to do the inverse: to switch the
default Rails behaviour back on, on command?

Thanks,

Matt

PS

I guess the other option is to figure out how to declaratively spec
rescue from (which I, and judging by forks of the
rspec_on_rails_matchers plugin, several others figured out for before
filters)...

Bit unawake yet, may follow up with an answer to my own question when
I've imbibed the caffeine.


--
   Matt Patterson | Design & Code
   <matt at reprocessed org> | http://www.reprocessed.org/
828784c46bc7ed3d9cc7a46aac85e37a?d=identicon&s=25 Matt Patterson (Guest)
on 2009-03-20 15:08
(Received via mailing list)
On 20 Mar 2009, at 06:46, Matt Patterson wrote:

> rspec_on_rails_matchers plugin, several others figured out for
> before filters)...
>
> Bit unawake yet, may follow up with an answer to my own question
> when I've imbibed the caffeine.


As predicted, I woke up and implemented a declarative matcher (will
also work on anything which includes ActiveSupport::Rescuable). Up in
rough form at
http://github.com/fidothe/rspec-on-rails-matchers/...
. It won't work if you've used a block with rescue_from, but I decided
I could live without that...

Matt


--
   Matt Patterson | Design & Code
   <matt at reprocessed org> | http://www.reprocessed.org/
This topic is locked and can not be replied to.