Since these emails are critical to our business I spent some time looking at how to write clean test to make sure my mailers are called when they shou

Nolan Phillips's Blog

submited by
Style Pass
2022-05-14 14:30:08

Since these emails are critical to our business I spent some time looking at how to write clean test to make sure my mailers are called when they should be.

So we're working on a Point of Sale for the the Frosty Treat in Kengsington PEI. The CEO is all about data and dopamine rushes, so they want to get an email every time a banana gets split...for whatever reason.

The ActionMailer API is nice to work with...but involves a lot of weird objects. After a bit of fiddling around and searching through StackOverflow we find the magic spell we need:

It's a mess though, and the thought of writing that every time I need to test a mailer is enough to keep me from ever writing a mailer test again.

Leave a Comment