# Testing exception notification plugin with rspec

**URL:** <https://www.ruby-forum.com/t/testing-exception-notification-plugin-with-rspec/173509>\
**Category:** Rails\
**Created:** [August 10, 2009, 8:06pm UTC](https://www.ruby-forum.com/t/testing-exception-notification-plugin-with-rspec/173509 "2009-08-10T20:06:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoann-Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/59ef9b/32.png) [@Yoann-Z](https://www.ruby-forum.com/u/Yoann-Z)\
**Post date:** [August 10, 2009, 8:06pm UTC](https://www.ruby-forum.com/t/testing-exception-notification-plugin-with-rspec/173509/1 "2009-08-10T20:06:25Z")

</div>

Hi,

I’m trying to install exception notification plugin and test it with  
rspec.  
The problem that I have is that when running the server in production  
mode : at the end of the log i get this when I have a critical error

rendering section “request”  
rendering section “session”  
rendering section “environment”  
rendering section “backtrace”  
Sent mail to removed\_email\_address@domain.invalid

but the spec fails :

ActionMailer::Base.delivery\_method = ‘test’  
ActionMailer::Base.perform\_deliveries = false  
ActionMailer::Base.deliveries = []  
@size\_before = ActionMailer::Base.deliveries.count  
lambda { get ‘dummy\_method\_raises\_exception’ }.should raise\_error  
(RuntimeError)  
ActionMailer::Base.deliveries.count.should eql(@size\_before + 1) \<====  
here I got 0 and not 1

Does someone have an idea about this problem?

Thank you by advance  
-Yoann

---

<div class="post-metadata">

**Author:** ![Yoann-Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/59ef9b/32.png) [@Yoann-Z](https://www.ruby-forum.com/u/Yoann-Z)\
**Post date:** [August 11, 2009, 1:10am UTC](https://www.ruby-forum.com/t/testing-exception-notification-plugin-with-rspec/173509/2 "2009-08-11T01:10:15Z")

</div>

On Aug 10, 2009, at 11:05 AM, Yoann-Z wrote:

> rendering section “environment”  
> (RuntimeError)  
> ActionMailer::Base.deliveries.count.should eql(@size\_before + 1) \<====  
> here I got 0 and not 1
> 
> Does someone have an idea about this problem?
> 
> Thank you by advance  
> -Yoann

A very similar topic came up recently on the cukes group  
([http://groups.google.com/group/cukes/browse\_thread/thread/79d45e6e8a4b5ce0](http://groups.google.com/group/cukes/browse_thread/thread/79d45e6e8a4b5ce0)  
). Maybe the thread will be of some use to you in puzzling this out.

---

<div class="post-metadata">

**Author:** ![Yoann-Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/59ef9b/32.png) [@Yoann-Z](https://www.ruby-forum.com/u/Yoann-Z)\
**Post date:** [September 16, 2009, 9:54am UTC](https://www.ruby-forum.com/t/testing-exception-notification-plugin-with-rspec/173509/3 "2009-09-16T09:54:11Z")

</div>

On Aug 11, 3:05 am, Yoann-Z [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> rendering section “backtrace”  
> ActionMailer::Base.deliveries.count.should eql(@size\_before + 1) \<====  
> here I got 0 and not 1
> 
> Does someone have an idea about this problem?
> 
> Thank you by advance  
> -Yoann

Setting ‘ActionMailer::Base.perform\_deliveries = false’ means that  
nothing makes it to the ActionMailer::Base.deliveries, so you will get  
0.

deliver calls deliver! which calls perform\_delivery\_#{delivery\_method}  
iff perform\_deliveries is true.  
as you can see here

> <https://github.com/rails/rails/blob/main/actionmailer/lib/action_mailer/base.rb#L736>

thats the thing that polulates the ActionMailer::Base.deliveries.

Hope i’m on the right track and this helps.  
Niko.
