Make ActionMailer Synchronous In Test
When you set up an ActionMailer
email, the default configuration is for it to use ActiveJob
to send the emails. As of Rails 5, it will do so asynchronously.. Depending on your preferences for testing emails, you may prefer ActiveJob
to send the emails synchronously. This can be done by changing the queue_adapter
back to :inline
in your config/environments/test.rb
.
If you also configure the delivery_method
as :test
:
then emails will be queued up in ActionMailer::Base.deliveries
allowing you to write a test like this:
Check out the docs for more on ActionMailer
.
Last updated