Sha256: fbc5ccac01d19e674a3e0c00cb3a4d6ec7eeae1f8d707ef29ff31a0dfa517047
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
module EmailSpec module TestDeliveries def all_emails ActionMailer::Base.deliveries end def last_email_sent ActionMailer::Base.deliveries.last || raise("No email has been sent!") end def reset_mailer ActionMailer::Base.deliveries.clear end def mailbox_for(address) ActionMailer::Base.deliveries.select { |m| m.to.include?(address) || (m.bcc && m.bcc.include?(address)) || (m.cc && m.cc.include?(address)) } end end module ARMailerDeliveries def all_emails Email.all.map{ |email| parse_to_tmail(email) } end def last_email_sent if email = Email.last TMail::Mail.parse(email.mail) else raise("No email has been sent!") end end def reset_mailer Email.delete_all end def mailbox_for(address) Email.all.select { |email| email.to.include?(address) || email.bcc.include?(address) || email.cc.include?(address) }.map{ |email| parse_to_tmail(email) } end def parse_to_tmail(email) TMail::Mail.parse(email.mail) end end module Deliveries if ActionMailer::Base.delivery_method == :activerecord include EmailSpec::ARMailerDeliveries else include EmailSpec::TestDeliveries end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
bmabey-email_spec-0.3.1 | lib/email_spec/deliveries.rb |
email_spec-0.3.1 | lib/email_spec/deliveries.rb |