Nov 12, 2011

ActionMailer Testing with Rspec

In environment/test.rb


Flood::Application.configure do
config.action_mailer.delivery_method = :test
end


And in your Rspec case, after sending an email, you can validate it with ActionMailer::Base.deliveries, which is an array of emails sent.

For example:


ActionMailer::Base.deliveries.last.to.should =~ ["test@gmail.com"]