Class: EmailSpec::Matchers::BccTo
- Inherits:
-
EmailMatcher
- Object
- EmailMatcher
- EmailSpec::Matchers::BccTo
- Defined in:
- lib/email_spec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
-
#initialize(expected_email_addresses_or_objects_that_respond_to_email) ⇒ BccTo
constructor
A new instance of BccTo.
- #matches?(email) ⇒ Boolean
Methods inherited from EmailMatcher
Constructor Details
#initialize(expected_email_addresses_or_objects_that_respond_to_email) ⇒ BccTo
Returns a new instance of BccTo.
119 120 121 122 123 124 125 |
# File 'lib/email_spec/matchers.rb', line 119 def initialize(expected_email_addresses_or_objects_that_respond_to_email) emails = expected_email_addresses_or_objects_that_respond_to_email.map do |email_or_object| email_or_object.kind_of?(String) ? email_or_object : email_or_object.email end @expected_email_addresses = emails.sort end |
Instance Method Details
#description ⇒ Object
127 128 129 |
# File 'lib/email_spec/matchers.rb', line 127 def description "be bcc'd to #{@expected_email_addresses.inspect}" end |
#failure_message ⇒ Object
137 138 139 |
# File 'lib/email_spec/matchers.rb', line 137 def "expected #{@email.inspect} to bcc to #{@expected_email_addresses.inspect}, but it was bcc'd to #{@actual_recipients.inspect}" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
141 142 143 |
# File 'lib/email_spec/matchers.rb', line 141 def "expected #{@email.inspect} not to bcc to #{@expected_email_addresses.inspect}, but it did" end |
#matches?(email) ⇒ Boolean
131 132 133 134 135 |
# File 'lib/email_spec/matchers.rb', line 131 def matches?(email) @email = email @actual_recipients = address_array { email[:bcc].formatted }.sort @actual_recipients == @expected_email_addresses end |