Class: Alplus::TestTransport
- Inherits:
-
Object
- Object
- Alplus::TestTransport
- Defined in:
- lib/alplus/transport.rb
Overview
In-memory transport used when config.test_mode is true. Records every
envelope it would have sent instead of touching the network, so specs
can assert on the exact shape without a stubbed HTTP endpoint —
Alplus.test_transport.envelopes (issue #14 story 9).
Instance Attribute Summary collapse
-
#envelopes ⇒ Object
readonly
Returns the value of attribute envelopes.
-
#session_envelopes ⇒ Object
readonly
Returns the value of attribute session_envelopes.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize ⇒ TestTransport
constructor
A new instance of TestTransport.
-
#send_envelope(envelope, kind: :error) ⇒ Object
kind:mirrorsTransport#send_envelope(issue #12): a:sessionenvelope records tosession_envelopesinstead ofenvelopes, so existing specs asserting onenvelopes(error envelopes only) are unaffected by session traffic.
Constructor Details
#initialize ⇒ TestTransport
Returns a new instance of TestTransport.
80 81 82 83 |
# File 'lib/alplus/transport.rb', line 80 def initialize(*) @envelopes = [] @session_envelopes = [] end |
Instance Attribute Details
#envelopes ⇒ Object (readonly)
Returns the value of attribute envelopes.
78 79 80 |
# File 'lib/alplus/transport.rb', line 78 def envelopes @envelopes end |
#session_envelopes ⇒ Object (readonly)
Returns the value of attribute session_envelopes.
78 79 80 |
# File 'lib/alplus/transport.rb', line 78 def session_envelopes @session_envelopes end |
Instance Method Details
#clear ⇒ Object
99 100 101 102 |
# File 'lib/alplus/transport.rb', line 99 def clear @envelopes.clear @session_envelopes.clear end |
#send_envelope(envelope, kind: :error) ⇒ Object
kind: mirrors Transport#send_envelope (issue #12): a :session
envelope records to session_envelopes instead of envelopes, so
existing specs asserting on envelopes (error envelopes only) are
unaffected by session traffic.
89 90 91 92 93 94 95 96 97 |
# File 'lib/alplus/transport.rb', line 89 def send_envelope(envelope, kind: :error) if kind == :session @session_envelopes << envelope else @envelopes << envelope end :sent end |