Class: RhizMail::MockMailer
- Inherits:
-
Object
- Object
- RhizMail::MockMailer
- Defined in:
- lib/rhizmail.rb
Overview
The MockMailer can be swapped out for the Mailer in test code, and then queried to make sure that the right emails were sent out. To set this, call
mock_mailer = RhizMail::MockMailer.new
RhizMail::Mailer.set_mailer mock_mailer
Afterwards, every time you call Message#deliver it will be delivered by the MockMailer.
Instance Attribute Summary collapse
-
#messages_sent ⇒ Object
readonly
Returns the value of attribute messages_sent.
Instance Method Summary collapse
-
#flush ⇒ Object
Clear out the history of messages sent.
-
#initialize ⇒ MockMailer
constructor
A new instance of MockMailer.
-
#send_message(email) ⇒ Object
Pretends to send an email, recording it in
messages_sent
to allow inspection later.
Constructor Details
#initialize ⇒ MockMailer
Returns a new instance of MockMailer.
251 |
# File 'lib/rhizmail.rb', line 251 def initialize; flush; end |
Instance Attribute Details
#messages_sent ⇒ Object (readonly)
Returns the value of attribute messages_sent.
249 250 251 |
# File 'lib/rhizmail.rb', line 249 def end |
Instance Method Details
#flush ⇒ Object
Clear out the history of messages sent.
254 |
# File 'lib/rhizmail.rb', line 254 def flush; = []; end |
#send_message(email) ⇒ Object
Pretends to send an email, recording it in messages_sent
to allow inspection later.
258 259 260 261 |
# File 'lib/rhizmail.rb', line 258 def (email) email.verify_sendable << email end |