Because we need to have the ability to schedule email delivery, we have migrated to using Sidekiq to send emails with the deliver_later
method. Under the old regime that used deliver_now
, our testing could use
ActionMailer::Base.deliveries[index]
to inspect the recipient, subject, body, attachments, etc...
For testing purposes, is there an equivalent mechanism to inspect the contents of queued email when using Sidekiq and deliver_later
?
The solution turned out to be to execute perform_enqueued_jobs
after all emails were queued. After this, all of the existing testing mechanisms worked.
See https://api.rubyonrails.org/v7.0.4/classes/ActiveJob/TestHelper.html for additional information.