rails/actionmailer/lib
Alex Ghiculescu a3724cdd20 assert_emails: return the emails that were sent
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
```
2023-01-16 12:44:32 -07:00
..
action_mailer assert_emails: return the emails that were sent 2023-01-16 12:44:32 -07:00
rails/generators/mailer Improve mailer generator usage docs 2022-06-21 00:30:27 -05:00
action_mailer.rb Add ActionMailer.deprecator 2022-10-29 16:01:02 -05:00