Created
March 13, 2009 14:47
-
-
Save nbibler/78594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test::Unit::TestCase | |
def assert_did_not_send_email | |
if block_given? | |
msg = "One or more sent emails matched your criteria.\n" | |
emails = ::ActionMailer::Base.deliveries | |
matching_emails = emails.select {|email| yield email } | |
assert matching_emails.empty?, msg | |
else | |
msg = "Sent #{::ActionMailer::Base.deliveries.size} emails.\n" | |
::ActionMailer::Base.deliveries.each { |m| msg << " '#{m.subject}' sent to #{m.to.to_sentence}\n" } | |
assert ::ActionMailer::Base.deliveries.empty?, msg | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment