method

capture_emails

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