Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix conflict

  • Loading branch information...
commit 0142d8bf5f70a243dd37345b75e4ed09ed50aa7d 2 parents 646d282 + 832f46b
@mike-burns mike-burns authored
View
2  lib/shoulda/action_mailer/matchers.rb
@@ -1,7 +1,7 @@
require 'shoulda/action_mailer/matchers/have_sent_email'
module Shoulda # :nodoc:
- module ActiveRecord # :nodoc:
+ module ActionMailer # :nodoc:
# = Matchers for your mailers
#
# This matcher will test that email is sent properly
View
14 lib/shoulda/action_mailer/matchers/have_sent_email.rb
@@ -42,13 +42,15 @@ def to(recipient)
end
def matches?(subject)
- @mail = subject
- @subject_failed = !regexp_or_string_match(@mail.subject, @email_subject) if @email_subject
- @body_failed = !regexp_or_string_match(@mail.body, @body) if @body
- @sender_failed = !regexp_or_string_match_in_array(@mail.from, @sender) if @sender
- @recipient_failed = !regexp_or_string_match_in_array(@mail.to, @recipient) if @recipient
+ ::ActionMailer::Base.deliveries.each do |mail|
+ @subject_failed = !regexp_or_string_match(mail.subject, @email_subject) if @email_subject
+ @body_failed = !regexp_or_string_match(mail.body, @body) if @body
+ @sender_failed = !regexp_or_string_match_in_array(mail.from, @sender) if @sender
+ @recipient_failed = !regexp_or_string_match_in_array(mail.to, @recipient) if @recipient
+ return true unless anything_failed?
+ end
- !anything_failed?
+ false
end
def failure_message
View
24 test/matchers/action_mailer/have_sent_email_test.rb
@@ -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('do-not-reply@example.com'), @mail
- assert_rejects have_sent_email.from('you@example.com'), @mail
+ assert_accepts have_sent_email.from('do-not-reply@example.com'), nil
+ assert_rejects have_sent_email.from('you@example.com'), 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('myself@me.com'), @mail
- assert_rejects have_sent_email.to('you@example.com'), @mail
+ assert_accepts have_sent_email.to('myself@me.com'), nil
+ assert_rejects have_sent_email.to('you@example.com'), nil
end
should "chain" do
- assert_accepts have_sent_email.with_subject(/spam/).from('do-not-reply@example.com').with_body(/spam/).to('myself@me.com'), @mail
- assert_rejects have_sent_email.with_subject(/ham/).from('you@example.com').with_body(/ham/).to('them@example.com'), @mail
+ assert_accepts have_sent_email.with_subject(/spam/).from('do-not-reply@example.com').with_body(/spam/).to('myself@me.com'), nil
+ assert_rejects have_sent_email.with_subject(/ham/).from('you@example.com').with_body(/ham/).to('them@example.com'), nil
end
end
end

0 comments on commit 0142d8b

Please sign in to comment.
Something went wrong with that request. Please try again.