Class: EmailSpec::Matchers::DeliverFrom

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

Instance Method Summary collapse

Constructor Details

#initialize(email) ⇒ DeliverFrom

Returns a new instance of DeliverFrom.



42
43
44
# File 'lib/email_spec/matchers.rb', line 42

def initialize(email)
  @expected_email_addresses = email
end

Instance Method Details

#descriptionObject



46
47
48
# File 'lib/email_spec/matchers.rb', line 46

def description
  "be delivered from #{@expected_email_addresses.inspect}"
end

#failure_messageObject



56
57
58
# File 'lib/email_spec/matchers.rb', line 56

def failure_message
  "expected #{@email.inspect} to deliver from #{@expected_email_addresses.inspect}, but it delivered from #{@actual_sender.inspect}"
end

#matches?(email) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
# File 'lib/email_spec/matchers.rb', line 50

def matches?(email)
  @email = email
  @actual_sender = (email.from || []).first
  @actual_sender.eql? @expected_email_addresses
end

#negative_failure_messageObject



60
61
62
# File 'lib/email_spec/matchers.rb', line 60

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