method
assert_emails
v3.0.0 -
Show latest stable
- Class:
ActionMailer::TestHelper
assert_emails(number)public
Asserts that the number of emails sent matches the given number.
def test_emails assert_emails 0 ContactMailer.deliver_contact assert_emails 1 ContactMailer.deliver_contact assert_emails 2 end
If a block is passed, that block should cause the specified number of emails to be sent.
def test_emails_again assert_emails 1 do ContactMailer.deliver_contact end assert_emails 2 do ContactMailer.deliver_contact ContactMailer.deliver_contact end end
1Note
Asserting Emails
--setup_mailer.rb in config/initializers --rails g mailer MailerName --methods in mailer_name.rb --files in views/mailer_name --MailerName.method(@object).deliver in object controller