module SanitizeEmail::TestHelpers

Helpers for test-unit

Public Instance Methods

array_matching(matcher, part, attribute) click to toggle source

Normalize arrays to strings

# File lib/sanitize_email/test_helpers.rb, line 29
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) click to toggle source
# File lib/sanitize_email/test_helpers.rb, line 38
def email_attribute_matching(matcher, part, attribute)
  array_matching(matcher, part, attribute)
end
email_matching(matcher, part, mail_or_part) click to toggle source
# File lib/sanitize_email/test_helpers.rb, line 34
def email_matching(matcher, part, mail_or_part)
  email_attribute_matching(matcher, part, mail_or_part.send(part))
end
string_matching(matcher, part, attribute) click to toggle source
# File lib/sanitize_email/test_helpers.rb, line 18
def string_matching(matcher, part, attribute)
  # Can we match a regex against it?
  raise UnexpectedMailType, "Cannot match #{matcher} for #{part}" unless attribute.respond_to?(:=~)
  attribute =~ if matcher.is_a?(Regexp)
                 matcher
               else
                 Regexp.new(Regexp.escape(matcher))
               end
end
string_matching_attribute(matcher, part, attribute) click to toggle source
# File lib/sanitize_email/test_helpers.rb, line 14
def string_matching_attribute(matcher, part, attribute)
  string_matching(matcher, part, attribute)
end