Testing Mailers
Testing Rails mailers involves two separate bits of functionality: specifying whether the email gets sent as a result of some action, and specifying the contents of that email. Specifying whether the email gets sent often starts as part of a controller or integration test, while specifying the content has a lot in common with view testing. The somewhat indirect nature of the Rails ActionMailer makes testing email less obvious than it might be, but it’s not hard. We’ll also look at a third-party library that makes email testing easier.
Let’s say, for example purposes, that we want to send an email in our project system when a task is marked as complete. We don’t have a user model yet (we’ll talk about users in this system when ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access