# File lib/mail/matchers/has_sent_mail.rb, line 52 52: def description 53: result = "send a matching email" 54: result 55: end
# 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
# File lib/mail/matchers/has_sent_mail.rb, line 16 16: def from(sender) 17: @sender = sender 18: self 19: end
# 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
# 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
# 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
# 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
# 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
# File lib/mail/matchers/has_sent_mail.rb, line 119 119: def dump_deliveries 120: "(actual deliveries: " + Mail::TestMailer.deliveries.inspect + ")" 121: end
# 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
# 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
# File lib/mail/matchers/has_sent_mail.rb, line 100 100: def matches_on_body?(delivery) 101: delivery.body == @body 102: end
# 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
# 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
# File lib/mail/matchers/has_sent_mail.rb, line 84 84: def matches_on_sender?(delivery) 85: delivery.from.include?(@sender) 86: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.