3 # Asserts that the number of emails sent matches the given number.
7 # ContactMailer.deliver_contact
9 # ContactMailer.deliver_contact
13 # If a block is passed, that block should cause the specified number of emails to be sent.
15 # def test_emails_again
17 # ContactMailer.deliver_contact
21 # ContactMailer.deliver_contact
22 # ContactMailer.deliver_contact
25 def assert_emails(number
)
27 original_count
= ActionMailer
::Base.deliveries
.size
29 new_count
= ActionMailer
::Base.deliveries
.size
30 assert_equal original_count
+ number
, new_count
, "#{number} emails expected, but #{new_count - original_count} were sent"
32 assert_equal number
, ActionMailer
::Base.deliveries
.size
36 # Assert that no emails have been sent.
40 # ContactMailer.deliver_contact
44 # If a block is passed, that block should not cause any emails to be sent.
46 # def test_emails_again
48 # # No emails should be sent from this block
52 # Note: This assertion is simply a shortcut for:
55 def assert_no_emails(&block
)
56 assert_emails
0, &block
64 include ActionMailer
::TestHelper