Class: EmailSpec::Matchers::DeliverTo
- Inherits:
-
Object
- Object
- EmailSpec::Matchers::DeliverTo
- Defined in:
- lib/email_spec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_email_addresses_or_objects_that_respond_to_email) ⇒ DeliverTo
constructor
A new instance of DeliverTo.
- #matches?(email) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected_email_addresses_or_objects_that_respond_to_email) ⇒ DeliverTo
Returns a new instance of DeliverTo.
7 8 9 10 11 12 13 |
# File 'lib/email_spec/matchers.rb', line 7 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
15 16 17 |
# File 'lib/email_spec/matchers.rb', line 15 def description "be delivered to #{@expected_email_addresses.inspect}" end |
#failure_message ⇒ Object
25 26 27 |
# File 'lib/email_spec/matchers.rb', line 25 def "expected #{@email.inspect} to deliver to #{@expected_email_addresses.inspect}, but it delivered to #{@actual_recipients.inspect}" end |
#matches?(email) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/email_spec/matchers.rb', line 19 def matches?(email) @email = email @actual_recipients = (email.to || []).sort @actual_recipients == @expected_email_addresses end |
#negative_failure_message ⇒ Object
29 30 31 |
# File 'lib/email_spec/matchers.rb', line 29 def "expected #{@email.inspect} not to deliver to #{@expected_email_addresses.inspect}, but it did" end |