Class: EmailSpec::Matchers::CcTo
- Inherits:
-
EmailMatcher
- Object
- EmailMatcher
- EmailSpec::Matchers::CcTo
- 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) ⇒ CcTo
constructor
A new instance of CcTo.
- #matches?(email) ⇒ Boolean
Methods inherited from EmailMatcher
Constructor Details
#initialize(expected_email_addresses_or_objects_that_respond_to_email) ⇒ CcTo
Returns a new instance of CcTo.
153 154 155 156 157 158 159 |
# File 'lib/email_spec/matchers.rb', line 153 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
161 162 163 |
# File 'lib/email_spec/matchers.rb', line 161 def description "be cc'd to #{@expected_email_addresses.inspect}" end |
#failure_message ⇒ Object
171 172 173 |
# File 'lib/email_spec/matchers.rb', line 171 def "expected #{@email.inspect} to cc to #{@expected_email_addresses.inspect}, but it was cc'd to #{@actual_recipients.inspect}" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
175 176 177 |
# File 'lib/email_spec/matchers.rb', line 175 def "expected #{@email.inspect} not to cc to #{@expected_email_addresses.inspect}, but it did" end |
#matches?(email) ⇒ Boolean
165 166 167 168 169 |
# File 'lib/email_spec/matchers.rb', line 165 def matches?(email) @email = email @actual_recipients = address_array { email[:cc].formatted }.sort @actual_recipients == @expected_email_addresses end |