Class: EmailSpec::Matchers::BccTo

Inherits:
Object
  • Object
show all
Defined in:
lib/email_spec/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_email_addresses_or_objects_that_respond_to_email) ⇒ BccTo



73
74
75
76
77
78
79
# File 'lib/email_spec/matchers.rb', line 73

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

#descriptionObject



81
82
83
# File 'lib/email_spec/matchers.rb', line 81

def description
  "be bcc'd to #{@expected_email_addresses.inspect}"
end

#failure_messageObject



91
92
93
# File 'lib/email_spec/matchers.rb', line 91

def failure_message
  "expected #{@email.inspect} to bcc to #{@expected_email_addresses.inspect}, but it was bcc'd to #{@actual_recipients.inspect}"
end

#matches?(email) ⇒ Boolean



85
86
87
88
89
# File 'lib/email_spec/matchers.rb', line 85

def matches?(email)
  @email = email
  @actual_recipients = (email.bcc || []).sort
  @actual_recipients == @expected_email_addresses
end

#negative_failure_messageObject



95
96
97
# File 'lib/email_spec/matchers.rb', line 95

def negative_failure_message
  "expected #{@email.inspect} not to bcc to #{@expected_email_addresses.inspect}, but it did"
end