Module: SanitizeEmail::TestHelpers
- Defined in:
- lib/sanitize_email/test_helpers.rb
Overview
Defined Under Namespace
Classes: UnexpectedMailType
Instance Method Summary
collapse
-
#array_matching(matcher, part, attribute) ⇒ Object
Normalize arrays to strings.
-
#email_attribute_matching(matcher, part, attribute) ⇒ Object
-
#email_matching(matcher, part, mail_or_part) ⇒ Object
-
#string_matching(matcher, part, attribute) ⇒ Object
-
#string_matching_attribute(matcher, part, attribute) ⇒ Object
Instance Method Details
#array_matching(matcher, part, attribute) ⇒ Object
Normalize arrays to strings
30
31
32
33
|
# File 'lib/sanitize_email/test_helpers.rb', line 30
def array_matching(matcher, part, attribute)
attribute = attribute.join(", ") if attribute.respond_to?(:join)
string_matching(matcher, part, attribute)
end
|
#email_attribute_matching(matcher, part, attribute) ⇒ Object
39
40
41
|
# File 'lib/sanitize_email/test_helpers.rb', line 39
def email_attribute_matching(matcher, part, attribute)
array_matching(matcher, part, attribute)
end
|
#email_matching(matcher, part, mail_or_part) ⇒ Object
35
36
37
|
# File 'lib/sanitize_email/test_helpers.rb', line 35
def email_matching(matcher, part, mail_or_part)
email_attribute_matching(matcher, part, mail_or_part.send(part))
end
|
#string_matching(matcher, part, attribute) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/sanitize_email/test_helpers.rb', line 17
def string_matching(matcher, part, attribute)
if attribute.respond_to?(:=~) if matcher.is_a?(Regexp)
attribute =~ matcher
else
attribute =~ Regexp.new(Regexp.escape(matcher))
end
else
raise UnexpectedMailType, "Cannot match #{matcher} for #{part}"
end
end
|
#string_matching_attribute(matcher, part, attribute) ⇒ Object
13
14
15
|
# File 'lib/sanitize_email/test_helpers.rb', line 13
def string_matching_attribute(matcher, part, attribute)
string_matching(matcher, part, attribute)
end
|