Class: EmailSpec::Matchers::DeliverFrom
- Inherits:
-
EmailMatcher
- Object
- EmailMatcher
- EmailSpec::Matchers::DeliverFrom
- 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(email) ⇒ DeliverFrom
constructor
A new instance of DeliverFrom.
- #matches?(email) ⇒ Boolean
Methods inherited from EmailMatcher
Constructor Details
#initialize(email) ⇒ DeliverFrom
Returns a new instance of DeliverFrom.
83 84 85 |
# File 'lib/email_spec/matchers.rb', line 83 def initialize(email) @expected_sender = Mail::FromField.new(email).addrs.first end |
Instance Method Details
#description ⇒ Object
87 88 89 |
# File 'lib/email_spec/matchers.rb', line 87 def description "be delivered from #{@expected_sender}" end |
#failure_message ⇒ Object
99 100 101 |
# File 'lib/email_spec/matchers.rb', line 99 def %(expected #{@email.inspect} to deliver from "#{@expected_sender.to_s}", but it delivered from "#{@actual_sender.to_s}") end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
103 104 105 |
# File 'lib/email_spec/matchers.rb', line 103 def %(expected #{@email.inspect} not to deliver from "#{@expected_sender.to_s}", but it did) end |
#matches?(email) ⇒ Boolean
91 92 93 94 95 96 97 |
# File 'lib/email_spec/matchers.rb', line 91 def matches?(email) @email = email @actual_sender = address_array{ email.header[:from].addrs }.first !@actual_sender.nil? && @actual_sender.to_s == @expected_sender.to_s end |