Class: ActionCable::SubscriptionAdapter::Test

Inherits:
Async show all
Defined in:
lib/action_cable/subscription_adapter/test.rb

Overview

Test adapter for Action Cable

The test adapter should be used only in testing. Along with ActionCable::TestHelper it makes a great tool to test your Rails application.

To use the test adapter set adapter value to test in your config/cable.yml file.

NOTE: Test adapter extends the ActionCable::SubscriptionsAdapter::Async adapter, so it could be used in system tests too.

Instance Attribute Summary

Attributes inherited from Base

#logger, #server

Instance Method Summary collapse

Methods inherited from Inline

#initialize, #shutdown, #subscribe, #unsubscribe

Methods inherited from Base

#initialize, #shutdown, #subscribe, #unsubscribe

Constructor Details

This class inherits a constructor from ActionCable::SubscriptionAdapter::Inline

Instance Method Details

#broadcast(channel, payload) ⇒ Object



17
18
19
20
# File 'lib/action_cable/subscription_adapter/test.rb', line 17

def broadcast(channel, payload)
  broadcasts(channel) << payload
  super
end

#broadcasts(channel) ⇒ Object



22
23
24
# File 'lib/action_cable/subscription_adapter/test.rb', line 22

def broadcasts(channel)
  channels_data[channel] ||= []
end

#clearObject



30
31
32
# File 'lib/action_cable/subscription_adapter/test.rb', line 30

def clear
  @channels_data = nil
end

#clear_messages(channel) ⇒ Object



26
27
28
# File 'lib/action_cable/subscription_adapter/test.rb', line 26

def clear_messages(channel)
  channels_data[channel] = []
end