Module: EmailSpec::ARMailerDeliveries
- Defined in:
- lib/email_spec/deliveries.rb
Instance Method Summary collapse
- #all_emails ⇒ Object
- #last_email_sent ⇒ Object
- #mailbox_for(address) ⇒ Object
- #parse_to_tmail(email) ⇒ Object
- #reset_mailer ⇒ Object
Instance Method Details
#all_emails ⇒ Object
34 35 36 |
# File 'lib/email_spec/deliveries.rb', line 34 def all_emails Email.all.map{ |email| parse_to_tmail(email) } end |
#last_email_sent ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/email_spec/deliveries.rb', line 38 def last_email_sent if email = Email.last TMail::Mail.parse(email.mail) else raise("No email has been sent!") end end |
#mailbox_for(address) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/email_spec/deliveries.rb', line 50 def mailbox_for(address) Email.all.select { |email| (email.to && email.to.include?(address)) || (email.bcc && email.bcc.include?(address)) || (email.cc && email.cc.include?(address)) }.map{ |email| parse_to_tmail(email) } end |
#parse_to_tmail(email) ⇒ Object
57 58 59 |
# File 'lib/email_spec/deliveries.rb', line 57 def parse_to_tmail(email) TMail::Mail.parse(email.mail) end |
#reset_mailer ⇒ Object
46 47 48 |
# File 'lib/email_spec/deliveries.rb', line 46 def reset_mailer Email.delete_all end |