class EmailSpec::Matchers::IncludeEmailWithSubject
Public Class Methods
new(subject)
click to toggle source
# File lib/email_spec/matchers.rb, line 230 def initialize(subject) @expected_subject = subject end
Public Instance Methods
description()
click to toggle source
# File lib/email_spec/matchers.rb, line 234 def description if @expected_subject.is_a?(String) "include email with subject of #{@expected_subject.inspect}" else "include email with subject matching #{@expected_subject.inspect}" end end
failure_message()
click to toggle source
# File lib/email_spec/matchers.rb, line 251 def failure_message if @expected_subject.is_a?(String) "expected at least one email to have the subject #{@expected_subject.inspect} but none did. Subjects were #{@given_emails.map(&:subject).inspect}" else "expected at least one email to have a subject matching #{@expected_subject.inspect}, but none did. Subjects were #{@given_emails.map(&:subject).inspect}" end end
failure_message_when_negated()
click to toggle source
# File lib/email_spec/matchers.rb, line 259 def failure_message_when_negated if @expected_subject.is_a?(String) "expected no email with the subject #{@expected_subject.inspect} but found at least one. Subjects were #{@given_emails.map(&:subject).inspect}" else "expected no email to have a subject matching #{@expected_subject.inspect} but found at least one. Subjects were #{@given_emails.map(&:subject).inspect}" end end
Also aliased as: negative_failure_message
matches?(emails)
click to toggle source
# File lib/email_spec/matchers.rb, line 242 def matches?(emails) @given_emails = emails if @expected_subject.is_a?(String) @given_emails.map(&:subject).include?(@expected_subject) else !!(@given_emails.any?{ |mail| mail.subject =~ @expected_subject }) end end