# Bypass\_rescue and its inverse

**URL:** <https://www.ruby-forum.com/t/bypass-rescue-and-its-inverse/163422>\
**Category:** RSpec\
**Created:** [March 20, 2009, 7:51am UTC](https://www.ruby-forum.com/t/bypass-rescue-and-its-inverse/163422 "2009-03-20T07:51:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lodestone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e495f1/32.png) [@lodestone](https://www.ruby-forum.com/u/lodestone)\
**Post date:** [March 20, 2009, 7:51am UTC](https://www.ruby-forum.com/t/bypass-rescue-and-its-inverse/163422/1 "2009-03-20T07:51:43Z")

</div>

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 P. | Design & Code  
 | [http://www.reprocessed.org/](http://www.reprocessed.org/)

---

<div class="post-metadata">

**Author:** ![lodestone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e495f1/32.png) [@lodestone](https://www.ruby-forum.com/u/lodestone)\
**Post date:** [March 20, 2009, 3:08pm UTC](https://www.ruby-forum.com/t/bypass-rescue-and-its-inverse/163422/2 "2009-03-20T15:08:03Z")

</div>

On 20 Mar 2009, at 06:46, Matt P. 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

> **[GitHub - fidothe/rspec-on-rails-matchers: A collection of RSpec matchers to be...](https://github.com/fidothe/rspec-on-rails-matchers/tree/master)**
>
> master

. It won’t work if you’ve used a block with rescue\_from, but I decided  
I could live without that…

Matt

–  
Matt P. | Design & Code  
 | [http://www.reprocessed.org/](http://www.reprocessed.org/)
