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 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 ...
Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.