Class: ActionCable::SubscriptionAdapter::Test

Inherits:
Async
  • Object
show all
Defined in:
lib/rails_6_polyfills/actioncable/test_adapter.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 Method Summary collapse

Instance Method Details

#broadcast(channel, payload) ⇒ Object



19
20
21
22
# File 'lib/rails_6_polyfills/actioncable/test_adapter.rb', line 19

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

#broadcasts(channel) ⇒ Object



24
25
26
# File 'lib/rails_6_polyfills/actioncable/test_adapter.rb', line 24

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

#clearObject



32
33
34
# File 'lib/rails_6_polyfills/actioncable/test_adapter.rb', line 32

def clear
  @channels_data = nil
end

#clear_messages(channel) ⇒ Object



28
29
30
# File 'lib/rails_6_polyfills/actioncable/test_adapter.rb', line 28

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