Class: Tape::EmailSpec::Matchers::ReplyTo

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

Instance Method Summary collapse

Constructor Details

#initialize(email) ⇒ ReplyTo

Returns a new instance of ReplyTo.



5
6
7
# File 'lib/tape/email_spec/matchers.rb', line 5

def initialize(email)
  @expected_reply_to = Mail::ReplyToField.new(email).addrs.first
end

Instance Method Details

#descriptionObject



9
10
11
# File 'lib/tape/email_spec/matchers.rb', line 9

def description
  "have reply to as #{@expected_reply_to.address}"
end

#failure_messageObject



20
21
22
# File 'lib/tape/email_spec/matchers.rb', line 20

def failure_message
  "expected #{@email.inspect} to reply to #{@expected_reply_to.address.inspect}, but it replied to #{@actual_reply_to.inspect}"
end

#matches?(email) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'lib/tape/email_spec/matchers.rb', line 13

def matches?(email)
  @email = email
  @actual_reply_to = (email.reply_to || []).first
  !@actual_reply_to.nil? &&
    @actual_reply_to == @expected_reply_to.address
end

#negative_failure_messageObject



24
25
26
# File 'lib/tape/email_spec/matchers.rb', line 24

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