Class: ActionMessenger::Messengers::MockMessenger

Inherits:
ActionMessenger::Messenger show all
Defined in:
lib/action_messenger/messengers/mock_messenger.rb

Overview

A mock subclass of Messenger for use in unit tests where a network connection may not be present.

Instance Attribute Summary collapse

Attributes inherited from ActionMessenger::Messenger

#config

Instance Method Summary collapse

Methods inherited from ActionMessenger::Messenger

#add_message_handler, #message_received, resolve, #shutdown

Constructor Details

#initializeMockMessenger

Constructs the mock messenger.


11
12
13
14
# File 'lib/action_messenger/messengers/mock_messenger.rb', line 11

def initialize
  super
  @deliveries = []
end

Instance Attribute Details

#deliveriesObject

The list of deliveries.


8
9
10
# File 'lib/action_messenger/messengers/mock_messenger.rb', line 8

def deliveries
  @deliveries
end

Instance Method Details

#fake_received(message) ⇒ Object

Fakes a message being received, for unit testing.


22
23
24
# File 'lib/action_messenger/messengers/mock_messenger.rb', line 22

def fake_received(message)
  message_received(message)
end

#send_message(message) ⇒ Object

Sends a message. Really just adds it to the delivery list, for unit testing.


17
18
19
# File 'lib/action_messenger/messengers/mock_messenger.rb', line 17

def send_message(message)
  @deliveries << message
end