Module: EmailSpec::MailerDeliveries

Included in:
Deliveries
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



15
16
17
18
19
20
# File 'lib/email_spec/deliveries.rb', line 15

def mailbox_for(address)
  deliveries.select { |email|
    (email.to && email.to.include?(address)) ||
    (email.bcc && email.bcc.include?(address)) ||
    (email.cc && email.cc.include?(address)) }
end

#reset_mailerObject



11
12
13
# File 'lib/email_spec/deliveries.rb', line 11

def reset_mailer
  deliveries.clear
end