Parent

Class Index [+]

Quicksearch

Mail::Matchers::HasSentEmailMatcher

Public Class Methods

new(_context) click to toggle source
   # File lib/mail/matchers/has_sent_mail.rb, line 8
8:       def initialize(_context)
9:       end

Public Instance Methods

description() click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 52
52:       def description
53:         result = "send a matching email"
54:         result
55:       end
failure_message() click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 57
57:       def failure_message
58:         result = "Expected email to be sent "
59:         result += explain_expectations
60:         result += dump_deliveries
61:         result
62:       end
from(sender) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 16
16:       def from(sender)
17:         @sender = sender
18:         self
19:       end
matches?(subject) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 11
11:       def matches?(subject)
12:         matching_deliveries = filter_matched_deliveries(Mail::TestMailer.deliveries)
13:         !(matching_deliveries.empty?)
14:       end
matching_body(body_matcher) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 47
47:       def matching_body(body_matcher)
48:         @body_matcher = body_matcher
49:         self
50:       end
matching_subject(subject_matcher) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 37
37:       def matching_subject(subject_matcher)
38:         @subject_matcher = subject_matcher
39:         self
40:       end
negative_failure_message() click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 64
64:       def negative_failure_message
65:         result = "Expected no email to be sent "
66:         result += explain_expectations
67:         result += dump_deliveries
68:         result
69:       end
to(recipient_or_list) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 21
21:       def to(recipient_or_list)
22:         @recipients ||= []
23: 
24:         if recipient_or_list.kind_of?(Array)
25:           @recipients += recipient_or_list
26:         else
27:           @recipients << recipient_or_list
28:         end
29:         self
30:       end
with_body(body) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 42
42:       def with_body(body)
43:         @body = body
44:         self
45:       end
with_subject(subject) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 32
32:       def with_subject(subject)
33:         @subject = subject
34:         self
35:       end

Protected Instance Methods

dump_deliveries() click to toggle source
     # File lib/mail/matchers/has_sent_mail.rb, line 119
119:       def dump_deliveries
120:         "(actual deliveries: " + Mail::TestMailer.deliveries.inspect + ")"
121:       end
explain_expectations() click to toggle source
     # File lib/mail/matchers/has_sent_mail.rb, line 108
108:       def explain_expectations
109:         result = ''
110:         result += "from #{@sender} " if instance_variable_defined?('@sender')
111:         result += "to #{@recipients.inspect} " if instance_variable_defined?('@recipients')
112:         result += "with subject \"#{@subject}\" " if instance_variable_defined?('@subject')
113:         result += "with subject matching \"#{@subject_matcher}\" " if instance_variable_defined?('@subject_matcher')
114:         result += "with body \"#{@body}\" " if instance_variable_defined?('@body')
115:         result += "with body matching \"#{@body_matcher}\" " if instance_variable_defined?('@body_matcher')
116:         result
117:       end
filter_matched_deliveries(deliveries) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 73
73:       def filter_matched_deliveries(deliveries)
74:         candidate_deliveries = deliveries
75: 
76:         %(sender recipients subject subject_matcher body body_matcher).each do |modifier_name|
77:           next unless instance_variable_defined?("@#{modifier_name}")
78:           candidate_deliveries = candidate_deliveries.select{|matching_delivery| self.send("matches_on_#{modifier_name}?", matching_delivery)}
79:         end
80: 
81:         candidate_deliveries
82:       end
matches_on_body?(delivery) click to toggle source
     # File lib/mail/matchers/has_sent_mail.rb, line 100
100:       def matches_on_body?(delivery)
101:         delivery.body == @body
102:       end
matches_on_body_matcher?(delivery) click to toggle source
     # File lib/mail/matchers/has_sent_mail.rb, line 104
104:       def matches_on_body_matcher?(delivery)
105:         @body_matcher.match delivery.body.raw_source
106:       end
matches_on_recipients?(delivery) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 88
88:       def matches_on_recipients?(delivery)
89:         @recipients.all? {|recipient| delivery.to.include?(recipient) }
90:       end
matches_on_sender?(delivery) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 84
84:       def matches_on_sender?(delivery)
85:         delivery.from.include?(@sender)
86:       end
matches_on_subject?(delivery) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 92
92:       def matches_on_subject?(delivery)
93:         delivery.subject == @subject
94:       end
matches_on_subject_matcher?(delivery) click to toggle source
    # File lib/mail/matchers/has_sent_mail.rb, line 96
96:       def matches_on_subject_matcher?(delivery)
97:         @subject_matcher.match delivery.subject
98:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.