Skip to content

Instantly share code, notes, and snippets.

@nbibler
Created March 13, 2009 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbibler/78594 to your computer and use it in GitHub Desktop.
Save nbibler/78594 to your computer and use it in GitHub Desktop.
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