Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test email sending using Rspec?

What are the best practices and tools to test email-sending using rspec with Rails?

For instance, how do I test that an email has been sent or what should I test to have efficient testing and acceptable coverage.

If you guys need an example, how would I go and test this:

class UserMailer < ActionMailer::Base

 def jobdesc_has_been_reviewed(user, title)
    @body[:title]  = title
    @body[:jobdesc]  = jobdesc
    @body[:url]  = "http://" + user.account.subdomain + "." + Constants::SITE_URL + "/jobdescs/#{jobdesc.id}"
 end

end
like image 366
marcgg Avatar asked Nov 16 '09 14:11

marcgg


1 Answers

email-spec looks like a good library

http://github.com/bmabey/email-spec

like image 146
nicholaides Avatar answered Nov 08 '22 02:11

nicholaides