Everytime I run tests, emails are actually sent. My config/environments/test.rb
has this configuration
config.action_mailer.delivery_method = :test
So I thought that whenever I run test, they should not be really sent, but when I run the command
RAILS_ENV="test" rake test
The emails get sent either way. For a moment I thought that maybe I was not using the right environment. But then I deleted completely db/test.sqlite3
and immediately after I run the tests again. The file was again restored, which proves that I am actually running in the test
environment.
What is going on? Why are my tests sending real mails? Could it have anything to do with the fact that I am using deliver_now
on my app?
You should at least be able to disable them by placing
config.action_mailer.perform_deliveries = false
in your environments/test.rb as suggested by Brent Sullivan in his answer.