Testing Email

You might wonder how we test email. After all, email ends up on someone
else’s computer, so how do we test that?

We can test mailers in isolation with unit tests. And we can write
integration tests to verify that email is sent as part of a feature. The
secret is that we must set up our test environment so emails are not
actually delivered. Instead, they are saved to an array in memory that
can be examined in the verification phase of a test.