I am writing tests for future functionality in my ruby on rails 4 application. After reading the RoR Guides, I found I could change the smtp settings in my config/environments/test.rb file to store emails in an array and not actually send them. After making that change I'm still receiving emails in my inbox when running my feature specs.
environments/test.rb
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
In production, my emails are being sent out via the Mandrill API. To double check my tests were running on the test environment, I ran: "RAILS_ENV=test rspec spec" and it still sent out emails.
feature spec
# Excerpt of feature spec
email = ActionMailer::Base.deliveries.last
email.body.raw_source.should include "Welcome!"
The above code fails with the following message:
expected to find text "Welcome!" in ""
If I'm correct, it looks like the emails aren't being store in the ActionMailer::Base.deliveries array.
environments/test.rbsettings? - Dylan Markow