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 ...
Get Rails 4 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.