Class: Mail::Matchers::HasSentEmailMatcher
- Inherits:
-
Object
- Object
- 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
- #failure_message_when_negated ⇒ 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
- #to(recipient_or_list) ⇒ Object
- #with_any_attachments ⇒ Object
- #with_attachments(attachments) ⇒ Object
- #with_body(body) ⇒ Object
- #with_html(body) ⇒ Object
- #with_no_attachments ⇒ Object
- #with_subject(subject) ⇒ Object
- #with_text(body) ⇒ Object
Constructor Details
#initialize(_context) ⇒ HasSentEmailMatcher
Returns a new instance of HasSentEmailMatcher.
9 10 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 9 def initialize(_context) end |
Instance Method Details
#bcc(recipient_or_list) ⇒ Object
44 45 46 47 48 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 44 def bcc(recipient_or_list) @blind_copy_recipients ||= [] @blind_copy_recipients.concat(Array(recipient_or_list)) self end |
#cc(recipient_or_list) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 33 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
96 97 98 99 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 96 def description result = "send a matching email" result end |
#failure_message ⇒ Object
101 102 103 104 105 106 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 101 def result = "Expected email to be sent " result += explain_expectations result += dump_deliveries result end |
#failure_message_when_negated ⇒ Object
108 109 110 111 112 113 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 108 def result = "Expected no email to be sent " result += explain_expectations result += dump_deliveries result end |
#from(sender) ⇒ Object
17 18 19 20 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 17 def from(sender) @sender = sender self end |
#matches?(subject) ⇒ Boolean
12 13 14 15 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 12 def matches?(subject) matching_deliveries = filter_matched_deliveries(Mail::TestMailer.deliveries) !(matching_deliveries.empty?) end |
#matching_body(body_matcher) ⇒ Object
81 82 83 84 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 81 def matching_body(body_matcher) @body_matcher = body_matcher self end |
#matching_subject(subject_matcher) ⇒ Object
71 72 73 74 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 71 def matching_subject(subject_matcher) @subject_matcher = subject_matcher self end |
#to(recipient_or_list) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 22 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_any_attachments ⇒ Object
61 62 63 64 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 61 def @having_attachments = true self end |
#with_attachments(attachments) ⇒ Object
50 51 52 53 54 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 50 def () @attachments ||= [] @attachments.concat(Array()) self end |
#with_body(body) ⇒ Object
76 77 78 79 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 76 def with_body(body) @body = body self end |
#with_html(body) ⇒ Object
86 87 88 89 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 86 def with_html(body) @html_part_body = body self end |
#with_no_attachments ⇒ Object
56 57 58 59 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 56 def @having_attachments = false self end |
#with_subject(subject) ⇒ Object
66 67 68 69 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 66 def with_subject(subject) @subject = subject self end |
#with_text(body) ⇒ Object
91 92 93 94 |
# File 'lib/mail/matchers/has_sent_mail.rb', line 91 def with_text(body) @text_part_body = body self end |