Class: Tape::EmailSpec::Matchers::DeliverFrom
- Inherits:
-
Object
- Object
- Tape::EmailSpec::Matchers::DeliverFrom
- Defined in:
- lib/tape/email_spec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(email) ⇒ DeliverFrom
constructor
A new instance of DeliverFrom.
- #matches?(email) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(email) ⇒ DeliverFrom
Returns a new instance of DeliverFrom.
71 72 73 |
# File 'lib/tape/email_spec/matchers.rb', line 71 def initialize(email) @expected_sender = Mail::FromField.new(email).addrs.first end |
Instance Method Details
#description ⇒ Object
75 76 77 |
# File 'lib/tape/email_spec/matchers.rb', line 75 def description "be delivered from #{@expected_sender}" end |
#failure_message ⇒ Object
87 88 89 |
# File 'lib/tape/email_spec/matchers.rb', line 87 def %(expected #{@email.inspect} to deliver from "#{@expected_sender.to_s}", but it delivered from "#{@actual_sender.to_s}") end |
#matches?(email) ⇒ Boolean
79 80 81 82 83 84 85 |
# File 'lib/tape/email_spec/matchers.rb', line 79 def matches?(email) @email = email @actual_sender = (email.header[:from].addrs || []).first !@actual_sender.nil? && @actual_sender.to_s == @expected_sender.to_s end |
#negative_failure_message ⇒ Object
91 92 93 |
# File 'lib/tape/email_spec/matchers.rb', line 91 def %(expected #{@email.inspect} not to deliver from "#{@expected_sender.to_s}", but it did) end |