class EmailSpec::Matchers::DeliverTo

Public Class Methods

new(expected_email_addresses_or_objects_that_respond_to_email) click to toggle source
# File lib/email_spec/matchers.rb, line 46
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_recipients = Mail::ToField.new(emails).addrs.map(&:to_s).sort
end

Public Instance Methods

description() click to toggle source
# File lib/email_spec/matchers.rb, line 54
def description
  "be delivered to #{@expected_recipients.inspect}"
end
failure_message() click to toggle source
# File lib/email_spec/matchers.rb, line 65
def failure_message
  "expected #{@email.inspect} to deliver to #{@expected_recipients.inspect}, but it delivered to #{@actual_recipients.inspect}"
end
failure_message_when_negated() click to toggle source
# File lib/email_spec/matchers.rb, line 69
def failure_message_when_negated
  "expected #{@email.inspect} not to deliver to #{@expected_recipients.inspect}, but it did"
end
Also aliased as: negative_failure_message
matches?(email) click to toggle source
# File lib/email_spec/matchers.rb, line 58
def matches?(email)
  @email = email
  recipients = email.header[:to] || email.header[:bcc]
  @actual_recipients = address_array{ recipients  && recipients.addrs }.map(&:to_s).sort
  @actual_recipients == @expected_recipients
end
negative_failure_message()