Module: SanitizeEmail::TestHelpers
- Included in:
- RspecMatchers
- Defined in:
- lib/sanitize_email/test_helpers.rb
Defined Under Namespace
Classes: UnexpectedMailType
Instance Method Summary collapse
-
#array_matching(matcher, part, mail_or_part) ⇒ Object
Normalize arrays to strings.
- #email_matching(matcher, part, mail_or_part) ⇒ Object
- #string_matching(matcher, part, mail_or_part) ⇒ Object
Instance Method Details
#array_matching(matcher, part, mail_or_part) ⇒ Object
Normalize arrays to strings
14 15 16 17 |
# File 'lib/sanitize_email/test_helpers.rb', line 14 def array_matching(matcher, part, mail_or_part) mail_or_part = mail_or_part.join(', ') if mail_or_part.respond_to?(:join) string_matching(matcher, part, mail_or_part) end |
#email_matching(matcher, part, mail_or_part) ⇒ Object
19 20 21 |
# File 'lib/sanitize_email/test_helpers.rb', line 19 def email_matching(matcher, part, mail_or_part) array_matching(matcher, part, mail_or_part.send(part)) end |
#string_matching(matcher, part, mail_or_part) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/sanitize_email/test_helpers.rb', line 5 def string_matching(matcher, part, mail_or_part) if mail_or_part.respond_to?(:=~) # Can we match a regex against it? mail_or_part =~ Regexp.new(Regexp.escape(matcher)) else raise UnexpectedMailType, "Cannot match #{matcher} for #{part}" end end |