Class: Mail::Matchers::HasSentEmailMatcher

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

Instance Method Summary (collapse)

Constructor Details

- (HasSentEmailMatcher) initialize(_context)



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

def initialize(_context)
end

Instance Method Details

- (Object) bcc(recipient_or_list)



43
44
45
46
47
48
49
50
51
52
# File 'lib/mail/matchers/has_sent_mail.rb', line 43

def bcc(recipient_or_list)
  @blind_copy_recipients ||= []

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

- (Object) cc(recipient_or_list)



32
33
34
35
36
37
38
39
40
41
# File 'lib/mail/matchers/has_sent_mail.rb', line 32

def cc(recipient_or_list)
  @copy_recipients ||= []

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

- (Object) description



75
76
77
78
# File 'lib/mail/matchers/has_sent_mail.rb', line 75

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

- (Object) failure_message



80
81
82
83
84
85
# File 'lib/mail/matchers/has_sent_mail.rb', line 80

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

- (Object) from(sender)



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

def from(sender)
  @sender = sender
  self
end

- (Boolean) matches?(subject)



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

- (Object) matching_body(body_matcher)



70
71
72
73
# File 'lib/mail/matchers/has_sent_mail.rb', line 70

def matching_body(body_matcher)
  @body_matcher = body_matcher
  self
end

- (Object) matching_subject(subject_matcher)



60
61
62
63
# File 'lib/mail/matchers/has_sent_mail.rb', line 60

def matching_subject(subject_matcher)
  @subject_matcher = subject_matcher
  self
end

- (Object) negative_failure_message



87
88
89
90
91
92
# File 'lib/mail/matchers/has_sent_mail.rb', line 87

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

- (Object) to(recipient_or_list)



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

- (Object) with_body(body)



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

def with_body(body)
  @body = body
  self
end

- (Object) with_subject(subject)



55
56
57
58
# File 'lib/mail/matchers/has_sent_mail.rb', line 55

def with_subject(subject)
  @subject = subject
  self
end