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::SubscriptionAdapter::Async adapter, so it could be used in system tests too.

Methods

Instance Public methods

broadcast(channel, payload)

📝 Source code
# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 18
def broadcast(channel, payload)
  broadcasts(channel) << payload
  super
end
🔎 See on GitHub

broadcasts(channel)

📝 Source code
# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 23
def broadcasts(channel)
  channels_data[channel] ||= []
end
🔎 See on GitHub

clear()

📝 Source code
# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 31
def clear
  @channels_data = nil
end
🔎 See on GitHub

clear_messages(channel)

📝 Source code
# File actioncable/lib/action_cable/subscription_adapter/test.rb, line 27
def clear_messages(channel)
  channels_data[channel] = []
end
🔎 See on GitHub

Definition files