[rspec-users] Cucumber + Webrat + Selenium + ActionMailer

Ben Mabey ben at benmabey.com
Thu Feb 19 00:13:43 EST 2009


Stephen Eley wrote:
> On Wed, Feb 18, 2009 at 6:27 PM, Ben Mabey <ben at benmabey.com> wrote:
>   
>> Well, in this case the ARMailer is an arguably better alternative than
>> waiting on an SMTP connection for ActionMailer in production settings.
>>  ARMailer was not created to solve testing woes.. it was created it solve
>> production woes. :)  The fact that it helps in testing is just a side
>> effect.
>>     
>
> Oh, sure.  I wasn't trying to be critical against ARMailer itself; I
> do think that e-mail is the sort of side process that ought to be
> brought out of the request critical path one way or another.  But
> that's unrelated here.  It just seems like the sort of process change
> that might be overkill for 'I upgraded my gems and then my testing
> toolchain broke.'  Testability may be a factor in initial tool
> selection, but in this case the tool *was* testable until the tests
> were broken by an unrelated change.  Once a production process is in
> place, I think changes to it should be driven by business
> requirements.
>   

Yeah, and so I probably wouldn't change to ARMailer in production if 
that was an issue or wasn't really needed.  So I agree with you there.  
However, I wouldn't have a problem in using ARMailer in my tests but 
still use straight ActionMailer in production.  ActionMailer works and I 
don't need to test that.  What I'm interested in testing is if I am 
sending the correct emails at the correct time.  If I really need to 
test this part of the app in conjunction with selenium or another 
secondary process then setting up ARMailer just for that purpose seems 
like a reasonable investment.  Once you have that tested the only point 
of failure in production would be your ActionMailer settings. I'll point 
out that you will face the same risk when using ActionMailer in :test 
mode anyways.  So coming up with a method to test your settings would be 
needed in either case.  My method for doing this is clicking through the 
site once to fire off an email and never changing the working production 
settings again. :)

An alternative to using ARMailer would be to use something like 
Mailtrap[1] that acts as a dummy SMTP server to capture the emails from 
the app.  You would then need to provide a way for the tests to access 
these emails to verify them.

Both ways involve some extra work.  If it isn't worth the investment 
then the only other option is to test the emails apart from the selenium 
tests.  It just depends on how important it is that you test everything 
at the same time.

-Ben


1. http://github.com/mmower/mailtrap/tree/master



More information about the rspec-users mailing list