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 ⇒ Array<Hash>
readonly
Payloads “sent” to this channel by GraphQL-Ruby.
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.
42 43 44 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 42 def initialize @mock_broadcasted_messages = [] end |
Instance Attribute Details
#mock_broadcasted_messages ⇒ Array<Hash> (readonly)
Returns Payloads “sent” to this channel by GraphQL-Ruby.
47 48 49 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 47 def @mock_broadcasted_messages end |
Instance Method Details
#stream_from(stream_name, coder: nil, &block) ⇒ Object
Called by ActionCableSubscriptions. Implements a Rails API.
50 51 52 53 54 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 50 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 |