Sha256: b5bc56f65076bae6f034d5d1bcb86a9796efcf5df3d15a3c0c3c168310b175f4
Contents?: true
Size: 1.41 KB
Versions: 7
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true # Copyright (c) 2008 - 2018, 2020, 2022, 2024 Peter H. Boling of RailsBling.com # Released under the MIT license # Note: the RspecMatchers no longer use these methods. Instead they are composed matchers: # See: http://www.relishapp.com/rspec/rspec-expectations/v/3-5/docs/composing-matchers module SanitizeEmail # Helpers for test-unit module TestHelpers # Error raised when unable to match an expected part of email in order to fail the test class UnexpectedMailType < StandardError; end def string_matching_attribute(matcher, part, attribute) string_matching(matcher, part, attribute) end 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 # Normalize arrays to strings def array_matching(matcher, part, attribute) attribute = attribute.join(", ") if attribute.respond_to?(:join) string_matching(matcher, part, attribute) end def email_matching(matcher, part, mail_or_part) email_attribute_matching(matcher, part, mail_or_part.send(part)) end def email_attribute_matching(matcher, part, attribute) array_matching(matcher, part, attribute) end end end
Version data entries
7 entries across 7 versions & 1 rubygems