Class: GraphQL::Testing::MockActionCable
- Inherits:
-
Object
- Object
- GraphQL::Testing::MockActionCable
- Defined in:
- lib/graphql/testing/mock_action_cable.rb
Overview
A stub implementation of ActionCable.
Any methods to support the mock backend have mock in the name.
Defined Under Namespace
Classes: MockChannel, MockStream
Class Method Summary collapse
-
.broadcast(stream_name, message) ⇒ Object
Implements Rails API.
-
.clear_mocks ⇒ Object
Call this before each test run to make sure that MockActionCable’s data is empty.
-
.get_mock_channel ⇒ GraphQL::Testing::MockActionCable::MockChannel
Use this as
context[:channel]to simulate an ActionCable channel. -
.mock_stream_for(stream_name) ⇒ Object
Used by mock code.
-
.mock_stream_names ⇒ Array<String>
Streams that currently have subscribers.
-
.server ⇒ Object
Implements Rails API.
Class Method Details
.broadcast(stream_name, message) ⇒ Object
Implements Rails API
87 88 89 90 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 87 def broadcast(stream_name, ) stream = @mock_streams[stream_name] stream && stream.mock_broadcast() end |
.clear_mocks ⇒ Object
Call this before each test run to make sure that MockActionCable’s data is empty
77 78 79 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 77 def clear_mocks @mock_streams = {} end |
.get_mock_channel ⇒ GraphQL::Testing::MockActionCable::MockChannel
Use this as context[:channel] to simulate an ActionCable channel
100 101 102 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 100 def get_mock_channel MockChannel.new end |
.mock_stream_for(stream_name) ⇒ Object
Used by mock code
93 94 95 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 93 def mock_stream_for(stream_name) @mock_streams[stream_name] ||= MockStream.new end |
.mock_stream_names ⇒ Array<String>
Returns Streams that currently have subscribers.
105 106 107 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 105 def mock_stream_names @mock_streams.keys end |
.server ⇒ Object
Implements Rails API
82 83 84 |
# File 'lib/graphql/testing/mock_action_cable.rb', line 82 def server self end |