[rspec-users] Spec'ing ActionMailer

s.ross cwdinfo at gmail.com
Sun Feb 4 13:53:39 EST 2007


Good morning (Pacific Time). I have a controller action that, as a  
side-effect, sends an email to an administrator. I want it to do  
something like this:

specify "when someone successfully signs up, an email should be sent  
to the administrator with the person's contact page" do
   post :signup, {...lots o' params}
   response should_be success

   # here's where I want to see whether email was sent. Of course,  
the code is bogus.
   email.body.should have_tag(:p, :content => /page=/)
end

Is there some way to reach in and grab the message (what I've written  
as "email" above) so I can test the various parameters such as the  
"to" array and the email contents? I'm most interested in whether the  
controller/mailer interaction is working properly. Also, can I use  
the DOM select expectations or is it a simple matcher?

Thanks


More information about the rspec-users mailing list