February 2018
Intermediate to advanced
406 pages
9h 52m
English
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 request or system 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 you want to send an email in your project-management system when a task is marked as complete. You don’t have a user model yet (I’ll talk about users in this system ...