Class: RSpec::MailMatcher::BodyMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/mail_matcher/body_matcher.rb

Direct Known Subclasses

BodyHtmlMatcher, BodyTextMatcher

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BodyMatcher

Returns a new instance of BodyMatcher.



3
4
5
# File 'lib/rspec/mail_matcher/body_matcher.rb', line 3

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



16
17
18
19
20
21
22
# File 'lib/rspec/mail_matcher/body_matcher.rb', line 16

def description
  if @expected.kind_of?(String)
    "have body including #{@expected.inspect}"
  else
    "have body matching #{@expected.inspect}"
  end
end

#failure_messageObject



24
25
26
27
28
29
30
# File 'lib/rspec/mail_matcher/body_matcher.rb', line 24

def failure_message
  if @expected.kind_of?(String)
    "expected the body to contain #{@expected.inspect} but was #{mail_body.inspect}"
  else
    "expected the body to match #{@expected.inspect}, but did not. Actual body was: #{mail_body.inspect}"
  end
end

#matches?(mail) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
# File 'lib/rspec/mail_matcher/body_matcher.rb', line 7

def matches?(mail)
  @mail = mail
  if @expected.kind_of?(String)
    include?
  else
    match?
  end
end