Class: Emailer::MockSmtpFacade

Inherits:
SmtpFacade show all
Defined in:
lib/emailer/mock_smtp_facade.rb

Direct Known Subclasses

LoggerSmtpFacade, ToFileSmtpFacade

Instance Attribute Summary collapse

Attributes inherited from SmtpFacade

#error, #offending_mail, #settings

Instance Method Summary collapse

Methods inherited from SmtpFacade

#open, #send_html, #send_text

Constructor Details

#initialize(settings = {}) ⇒ MockSmtpFacade

Returns a new instance of MockSmtpFacade.



16
17
18
19
# File 'lib/emailer/mock_smtp_facade.rb', line 16

def initialize(settings = {})
  @sent = {}
  super
end

Instance Attribute Details

#sentObject (readonly)

Returns the value of attribute sent.



14
15
16
# File 'lib/emailer/mock_smtp_facade.rb', line 14

def sent
  @sent
end

Instance Method Details

#get_net_smtp_instanceObject

Don’t open connections…



22
23
24
# File 'lib/emailer/mock_smtp_facade.rb', line 22

def get_net_smtp_instance
  MockNetSmtp.new
end

#get_url_for(uuidString) ⇒ Object



51
52
53
# File 'lib/emailer/mock_smtp_facade.rb', line 51

def get_url_for uuidString
   TestingMiddleware.testing_path+uuidString
end

#last_email_sentObject



39
40
41
# File 'lib/emailer/mock_smtp_facade.rb', line 39

def last_email_sent
  @sent[@sent.keys.last.to_s]
end

#last_email_sent_keyObject



43
44
45
# File 'lib/emailer/mock_smtp_facade.rb', line 43

def last_email_sent_key
  @sent.keys.last
end

#last_email_sent_urlObject



47
48
49
# File 'lib/emailer/mock_smtp_facade.rb', line 47

def last_email_sent_url
  get_url_for last_email_sent_key
end

#send_mail(options) ⇒ Object

And save, don’t send, mail…



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/emailer/mock_smtp_facade.rb', line 27

def send_mail(options)
  raise ConnectionNotOpenError unless @open
  @sent[UUID.new.generate] = options
  true
rescue ConnectionNotOpenError => e
  raise e
rescue StandardError => e
  @error = e
  @offending_mail = options
  false
end