module ActionMailer::TestHelper

def assert_no_emails(&block)

assert_emails 0

Note: This assertion is simply a shortcut for:

end
end
# No emails should be sent from this block
assert_no_emails do
def test_emails_again

If a block is passed, that block should not cause any emails to be sent.

end
assert_emails 1
ContactMailer.welcome.deliver_now
assert_no_emails
def test_emails

Assert that no emails have been sent.
def assert_no_emails(&block)
  assert_emails 0, &block
end