class EmailSpec::Matchers::DeliverFrom

Public Class Methods

new(email) click to toggle source
# File lib/email_spec/matchers.rb, line 83
def initialize(email)
  @expected_sender = Mail::FromField.new(email).addrs.first
end

Public Instance Methods

description() click to toggle source
# File lib/email_spec/matchers.rb, line 87
def description
  "be delivered from #{@expected_sender}"
end
failure_message() click to toggle source
# File lib/email_spec/matchers.rb, line 99
def failure_message
  %(expected #{@email.inspect} to deliver from "#{@expected_sender.to_s}", but it delivered from "#{@actual_sender.to_s}")
end
failure_message_when_negated() click to toggle source
# File lib/email_spec/matchers.rb, line 103
def failure_message_when_negated
  %(expected #{@email.inspect} not to deliver from "#{@expected_sender.to_s}", but it did)
end
Also aliased as: negative_failure_message
matches?(email) click to toggle source
# 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
negative_failure_message()