Class: GraphQL::Testing::MockActionCable::MockChannel
- Inherits:
-
Object
- Object
- GraphQL::Testing::MockActionCable::MockChannel
- Defined in:
- lib/graphql/testing/mock_action_cable.rb
Instance Attribute Summary collapse
-
#mock_broadcasted_messages ⇒ Object
readonly
Returns.
Instance Method Summary collapse
-
#initialize ⇒ MockChannel
constructor
A new instance of MockChannel.
-
#stream_from(stream_name, coder: nil, &block) ⇒ Object
Called by ActionCableSubscriptions.
Constructor Details
#initialize ⇒ MockChannel
Returns a new instance of MockChannel.
54 55 56 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 54 def initialize @mock_broadcasted_messages = [] end |
Instance Attribute Details
#mock_broadcasted_messages ⇒ Object (readonly)
Returns
Array<Hash>— Payloads "sent" to this channel by GraphQL-Ruby
61 62 63 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 61 def @mock_broadcasted_messages end |
Instance Method Details
#stream_from(stream_name, coder: nil, &block) ⇒ Object
Called by ActionCableSubscriptions. Implements a Rails API.
64 65 66 67 68 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 64 def stream_from(stream_name, coder: nil, &block) # Rails uses `coder`, we don't block ||= ->(msg) { @mock_broadcasted_messages << msg } MockActionCable.mock_stream_for(stream_name).add_mock_channel(self, block) end |