Class: Mail::Matchers::HasSentEmailMatcher
- Defined in:
- lib/mail/matchers/has_sent_mail.rb
Instance Method Summary collapse
- #bcc(recipient_or_list) ⇒ Object
- #cc(recipient_or_list) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #from(sender) ⇒ Object
-
#initialize(_context) ⇒ HasSentEmailMatcher
constructor
A new instance of HasSentEmailMatcher.
- #matches?(subject) ⇒ Boolean
- #matching_body(body_matcher) ⇒ Object
- #matching_subject(subject_matcher) ⇒ Object
- #negative_failure_message ⇒ Object
- #to(recipient_or_list) ⇒ Object
- #with_body(body) ⇒ Object
- #with_subject(subject) ⇒ Object
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
#bcc(recipient_or_list) ⇒ Object
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 |
#cc(recipient_or_list) ⇒ Object
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 |
#description ⇒ Object
75 76 77 78 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 75 def description result = "send a matching email" result end |
#failure_message ⇒ Object
80 81 82 83 84 85 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 80 def 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
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
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 |
#matching_subject(subject_matcher) ⇒ Object
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 |
#negative_failure_message ⇒ Object
87 88 89 90 91 92 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 87 def 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
65 66 67 68 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 65 def with_body(body) @body = body self end |
#with_subject(subject) ⇒ Object
55 56 57 58 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 55 def with_subject(subject) @subject = subject self end |