Class: Mail::Matchers::HasSentEmailMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(_context) ⇒ HasSentEmailMatcher

Returns a new instance of HasSentEmailMatcher.



8
9
# File 'lib/mail/matchers/has_sent_mail.rb', line 8

def initialize(_context)
end

Instance Method Details

#descriptionObject



52
53
54
55
# File 'lib/mail/matchers/has_sent_mail.rb', line 52

def description
  result = "send a matching email"
  result
end

#failure_messageObject



57
58
59
60
61
62
# File 'lib/mail/matchers/has_sent_mail.rb', line 57

def failure_message
  result = "Expected email to be sent "
  result += explain_expectations
  result += dump_deliveries
  result
end

#from(sender) ⇒ Object



16
17
18
19
# File 'lib/mail/matchers/has_sent_mail.rb', line 16

def from(sender)
  @sender = sender
  self
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/mail/matchers/has_sent_mail.rb', line 11

def matches?(subject)
  matching_deliveries = filter_matched_deliveries(Mail::TestMailer.deliveries)
  !(matching_deliveries.empty?)
end

#matching_body(body_matcher) ⇒ Object



47
48
49
50
# File 'lib/mail/matchers/has_sent_mail.rb', line 47

def matching_body(body_matcher)
  @body_matcher = body_matcher
  self
end

#matching_subject(subject_matcher) ⇒ Object



37
38
39
40
# File 'lib/mail/matchers/has_sent_mail.rb', line 37

def matching_subject(subject_matcher)
  @subject_matcher = subject_matcher
  self
end

#negative_failure_messageObject



64
65
66
67
68
69
# File 'lib/mail/matchers/has_sent_mail.rb', line 64

def negative_failure_message
  result = "Expected no email to be sent "
  result += explain_expectations
  result += dump_deliveries
  result
end

#to(recipient_or_list) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/mail/matchers/has_sent_mail.rb', line 21

def to(recipient_or_list)
  @recipients ||= []

  if recipient_or_list.kind_of?(Array)
    @recipients += recipient_or_list
  else
    @recipients << recipient_or_list
  end
  self
end

#with_body(body) ⇒ Object



42
43
44
45
# File 'lib/mail/matchers/has_sent_mail.rb', line 42

def with_body(body)
  @body = body
  self
end

#with_subject(subject) ⇒ Object



32
33
34
35
# File 'lib/mail/matchers/has_sent_mail.rb', line 32

def with_subject(subject)
  @subject = subject
  self
end