Browse files

Fixed exceptions when matching arrays of emails against regexps; fixes

…gh-125 (based on a patch from
  • Loading branch information...
1 parent b0692c3 commit 02520e40c28c0bcd74d226f2b6a3006736c3e153 @jferris jferris committed Aug 17, 2010
@@ -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
@@ -37,12 +37,18 @@ def the_email
:message => /Expected sent email with subject/
- should "accept based on the sender" do
+ should "accept based on a string sender" do
assert_accepts have_sent_email.from(''), nil
assert_rejects have_sent_email.from(''), nil,
:message => /Expected sent email from/
+ 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,

0 comments on commit 02520e4

Please sign in to comment.