Module: EmailSpec::Deliveries

Included in:
EmailViewer, Helpers
Defined in:
lib/email_spec/deliveries.rb

Instance Method Summary collapse

Instance Method Details

#all_emailsObject



3
4
5
# File 'lib/email_spec/deliveries.rb', line 3

def all_emails
  deliveries
end

#last_email_sentObject



7
8
9
# File 'lib/email_spec/deliveries.rb', line 7

def last_email_sent
  deliveries.last || raise("No email has been sent!")
end

#mailbox_for(address) ⇒ Object



21
22
23
# File 'lib/email_spec/deliveries.rb', line 21

def mailbox_for(address)
  deliveries.select { |email| email.destinations.include?(address) }
end

#reset_mailerObject



11
12
13
14
15
16
17
18
19
# File 'lib/email_spec/deliveries.rb', line 11

def reset_mailer
  if defined?(ActionMailer) && ActionMailer::Base.delivery_method == :activerecord
    Email.delete_all
  elsif defined?(ActionMailer) && ActionMailer::Base.delivery_method == :cache
    mailer.clear_cache
  else
    deliveries.clear
  end
end