method

capture_emails

Importance_1
v7.1.3.4 - Show latest stable - 0 notes - Class: ActionMailer::TestHelper
capture_emails(&block) public

Returns any emails that are sent in the block.

def test_emails
  emails = capture_emails do
    ContactMailer.welcome.deliver_now
  end
  assert_equal "Hi there", emails.first.subject

  emails = capture_emails do
    ContactMailer.welcome.deliver_now
    ContactMailer.welcome.deliver_later
  end
  assert_equal "Hi there", emails.first.subject
end
Show source
Register or log in to add new notes.