Class: Shoulda::ActionMailer::Matchers::HaveSentEmailMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActionMailer::Matchers::HaveSentEmailMatcher
- Defined in:
- lib/shoulda/action_mailer/matchers/have_sent_email.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #from(sender) ⇒ Object
-
#initialize ⇒ HaveSentEmailMatcher
constructor
A new instance of HaveSentEmailMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #to(recipient) ⇒ Object
- #with_body(body) ⇒ Object
- #with_subject(email_subject) ⇒ Object
Constructor Details
#initialize ⇒ HaveSentEmailMatcher
Returns a new instance of HaveSentEmailMatcher.
21 22 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 21 def initialize end |
Instance Method Details
#description ⇒ Object
64 65 66 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 64 def description "send an email" end |
#failure_message ⇒ Object
56 57 58 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 56 def "Expected #{expectation}" end |
#from(sender) ⇒ Object
29 30 31 32 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 29 def from(sender) @sender = sender self end |
#matches?(subject) ⇒ Boolean
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 44 def matches?(subject) ::ActionMailer::Base.deliveries.each do |mail| @subject_failed = !regexp_or_string_match(mail.subject, @email_subject) if @email_subject @body_failed = !regexp_or_string_match(mail.body, @body) if @body @sender_failed = !regexp_or_string_match_in_array(mail.from, @sender) if @sender @recipient_failed = !regexp_or_string_match_in_array(mail.to, @recipient) if @recipient return true unless anything_failed? end false end |
#negative_failure_message ⇒ Object
60 61 62 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 60 def "Did not expect #{expectation}" end |
#to(recipient) ⇒ Object
39 40 41 42 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 39 def to(recipient) @recipient = recipient self end |
#with_body(body) ⇒ Object
34 35 36 37 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 34 def with_body(body) @body = body self end |
#with_subject(email_subject) ⇒ Object
24 25 26 27 |
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 24 def with_subject(email_subject) @email_subject = email_subject self end |