Test that an email was sent with correct params
assert_email_delivered_with is a function that checks if an email was delivered using Bamboo.
Sending an email is a side-effect in functional programming parlance. When testing a function where the email is sent several calls deep, you generally don't get the email as a return value of that function.
When using Bamboo's TestAdaptor in test mode, Bamboo captures the delivered email so that you can assert about it.
Lottery.notify_winner()
assert_email_delivered_with(subject: "You Won!!")
You can also assert on: to
, cc
, text_body
, html_body
, from
, and bcc
.
Happy Testing!
Tweet