a3724cdd20
This pattern is pretty common: ```ruby assert_emails 1 do post invite_user_path # ... end email = ActionMailer::Base.deliveries.last assert_equal "You were invited!", email.subject ``` We can make it a bit nicer, by returning the email object from `assert_emails`. This is similar to how `assert_raises` returns the error so you can do additional checks on it. With this PR: ```ruby email = assert_emails 1 do post invite_user_path # ... end assert_equal "You were invited!", email.subject ``` If a single email is sent, a single `Mail::Message` is returned. If multiple emails were sent, an array is returned. ```ruby emails = assert_emails 2 do post invite_user_path # ... end emails.each do |email| assert_equal "You were invited!", email.subject end ``` |
||
---|---|---|
.. | ||
action_mailer | ||
rails/generators/mailer | ||
action_mailer.rb |