-
-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed all ThoughtBot (and Thoughtbot) namespaces
- Loading branch information
Showing
22 changed files
with
1,963 additions
and
1,990 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,39 +1,38 @@ | |||
module ThoughtBot # :nodoc: | module Shoulda # :nodoc: | ||
module Shoulda # :nodoc: | module ActionMailer # :nodoc: | ||
module ActionMailer # :nodoc: | module Assertions | ||
module Assertions | # Asserts that an email was delivered. Can take a block that can further | ||
# Asserts that an email was delivered. Can take a block that can further | # narrow down the types of emails you're expecting. | ||
# narrow down the types of emails you're expecting. | # | ||
# | # assert_sent_email | ||
# assert_sent_email | # | ||
# | # Passes if ActionMailer::Base.deliveries has an email | ||
# Passes if ActionMailer::Base.deliveries has an email | # | ||
# | # assert_sent_email do |email| | ||
# assert_sent_email do |email| | # email.subject =~ /hi there/ && email.to.include?('none@none.com') | ||
# email.subject =~ /hi there/ && email.to.include?('none@none.com') | # end | ||
# end | # | ||
# | # Passes if there is an email with subject containing 'hi there' and | ||
# Passes if there is an email with subject containing 'hi there' and | # 'none@none.com' as one of the recipients. | ||
# 'none@none.com' as one of the recipients. | # | ||
# | def assert_sent_email | ||
def assert_sent_email | emails = ::ActionMailer::Base.deliveries | ||
emails = ::ActionMailer::Base.deliveries | assert !emails.empty?, "No emails were sent" | ||
assert !emails.empty?, "No emails were sent" | if block_given? | ||
if block_given? | matching_emails = emails.select {|email| yield email } | ||
matching_emails = emails.select {|email| yield email } | assert !matching_emails.empty?, "None of the emails matched." | ||
assert !matching_emails.empty?, "None of the emails matched." | |||
end | |||
end | end | ||
end | |||
|
|
||
# Asserts that no ActionMailer mails were delivered | # Asserts that no ActionMailer mails were delivered | ||
# | # | ||
# assert_did_not_send_email | # assert_did_not_send_email | ||
def assert_did_not_send_email | def assert_did_not_send_email | ||
msg = "Sent #{::ActionMailer::Base.deliveries.size} emails.\n" | msg = "Sent #{::ActionMailer::Base.deliveries.size} emails.\n" | ||
::ActionMailer::Base.deliveries.each { |m| msg << " '#{m.subject}' sent to #{m.to.to_sentence}\n" } | ::ActionMailer::Base.deliveries.each { |m| msg << " '#{m.subject}' sent to #{m.to.to_sentence}\n" } | ||
assert ::ActionMailer::Base.deliveries.empty?, msg | assert ::ActionMailer::Base.deliveries.empty?, msg | ||
end | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
|
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
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
Oops, something went wrong.