forked from castlerock/shoulda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
21 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,35 +19,35 @@ def the_email | |
end | ||
end | ||
if defined?(AbstractController::Rendering) | ||
@mail = Mailer.the_email | ||
::ActionMailer::Base.deliveries << Mailer.the_email | ||
else | ||
@mail = Mailer.create_the_email | ||
::ActionMailer::Base.deliveries << Mailer.create_the_email | ||
end | ||
end | ||
|
||
should "accept based on the subject" do | ||
assert_accepts have_sent_email.with_subject(/is spam$/), @mail | ||
assert_rejects have_sent_email.with_subject(/totally safe/), @mail | ||
assert_accepts have_sent_email.with_subject(/is spam$/), nil | ||
assert_rejects have_sent_email.with_subject(/totally safe/), nil | ||
end | ||
|
||
should "accept based on the sender" do | ||
assert_accepts have_sent_email.from('[email protected]'), @mail | ||
assert_rejects have_sent_email.from('[email protected]'), @mail | ||
assert_accepts have_sent_email.from('[email protected]'), nil | ||
assert_rejects have_sent_email.from('[email protected]'), nil | ||
end | ||
|
||
should "accept based on the body" do | ||
assert_accepts have_sent_email.with_body(/is spam\./), @mail | ||
assert_rejects have_sent_email.with_body(/totally safe/), @mail | ||
assert_accepts have_sent_email.with_body(/is spam\./), nil | ||
assert_rejects have_sent_email.with_body(/totally safe/), nil | ||
end | ||
|
||
should "accept baed on the recipienct" do | ||
assert_accepts have_sent_email.to('[email protected]'), @mail | ||
assert_rejects have_sent_email.to('[email protected]'), @mail | ||
assert_accepts have_sent_email.to('[email protected]'), nil | ||
assert_rejects have_sent_email.to('[email protected]'), nil | ||
end | ||
|
||
should "chain" do | ||
assert_accepts have_sent_email.with_subject(/spam/).from('[email protected]').with_body(/spam/).to('[email protected]'), @mail | ||
assert_rejects have_sent_email.with_subject(/ham/).from('[email protected]').with_body(/ham/).to('[email protected]'), @mail | ||
assert_accepts have_sent_email.with_subject(/spam/).from('[email protected]').with_body(/spam/).to('[email protected]'), nil | ||
assert_rejects have_sent_email.with_subject(/ham/).from('[email protected]').with_body(/ham/).to('[email protected]'), nil | ||
end | ||
end | ||
end |