Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed exceptions when matching arrays of emails against regexps; fixes

…gh-125 (based on a patch from github.com/phene)
  • Loading branch information...
commit 02520e40c28c0bcd74d226f2b6a3006736c3e153 1 parent b0692c3
@jferris jferris authored
View
2  lib/shoulda/action_mailer/matchers/have_sent_email.rb
@@ -98,7 +98,7 @@ def regexp_or_string_match(a_string, a_regexp_or_string)
def regexp_or_string_match_in_array(an_array, a_regexp_or_string)
case a_regexp_or_string
when Regexp
- an_array.detect{|e| e =~ a_regexp_or_string}.any?
+ an_array.any? { |string| string =~ a_regexp_or_string }
when String
an_array.include?(a_regexp_or_string)
end
View
8 test/matchers/action_mailer/have_sent_email_test.rb
@@ -37,12 +37,18 @@ def the_email
:message => /Expected sent email with subject/
end
- should "accept based on the sender" do
+ should "accept based on a string sender" do
assert_accepts have_sent_email.from('do-not-reply@example.com'), nil
assert_rejects have_sent_email.from('you@example.com'), nil,
:message => /Expected sent email from/
end
+ should "accept based on a regexp sender" do
+ assert_accepts have_sent_email.from(/@example\.com/), nil
+ assert_rejects have_sent_email.from(/you@/), nil,
+ :message => /Expected sent email from/
+ end
+
should "accept based on the body" do
assert_accepts have_sent_email.with_body(/is spam\./), nil
assert_rejects have_sent_email.with_body(/totally safe/), nil,
Please sign in to comment.
Something went wrong with that request. Please try again.