From cf87cfeb5730ab9982adcb0a6b5608c7e75b3fa0 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 3 Jan 2015 23:25:09 +0100 Subject: Demonstrate example of `assert_emails` in testing guide rails/rails#18305, thanks for @dhh suggestion --- guides/source/testing.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index d6e4aa36db..065ca71d48 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1098,9 +1098,10 @@ require 'test_helper' class UserMailerTest < ActionMailer::TestCase test "invite" do # Send the email, then test that it got queued - email = UserMailer.create_invite('me@example.com', - 'friend@example.com', Time.now).deliver_now - assert ActionMailer::Base.deliveries.present? + assert_emails 1 do + email = UserMailer.create_invite('me@example.com', + 'friend@example.com', Time.now).deliver_now + end # Test the body of the sent email contains what we expect it to assert_equal ['me@example.com'], email.from -- cgit v1.2.3