Sha256: 6c8aff59ad2be3bf31c38712f9bb7a1212dc25a4a019b29253e17c62288ca3d7

Contents?: true

Size: 986 Bytes

Versions: 21

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true

# :markup: markdown

module ActionCable
  module SubscriptionAdapter
    # ## 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.
    class Test < Async
      def broadcast(channel, payload)
        broadcasts(channel) << payload
        super
      end

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

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

      def clear
        @channels_data = nil
      end

      private
        def channels_data
          @channels_data ||= {}
        end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
actioncable-8.0.0 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.2 lib/action_cable/subscription_adapter/test.rb
actioncable-8.0.0.rc2 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.1.2 lib/action_cable/subscription_adapter/test.rb
actioncable-8.0.0.rc1 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.1.1 lib/action_cable/subscription_adapter/test.rb
actioncable-next-0.1.1 lib/action_cable/subscription_adapter/test.rb
actioncable-next-0.1.0 lib/action_cable/subscription_adapter/test.rb
actioncable-8.0.0.beta1 lib/action_cable/subscription_adapter/test.rb
omg-actioncable-8.0.0.alpha9 lib/action_cable/subscription_adapter/test.rb
omg-actioncable-8.0.0.alpha8 lib/action_cable/subscription_adapter/test.rb
omg-actioncable-8.0.0.alpha7 lib/action_cable/subscription_adapter/test.rb
omg-actioncable-8.0.0.alpha4 lib/action_cable/subscription_adapter/test.rb
omg-actioncable-8.0.0.alpha3 lib/action_cable/subscription_adapter/test.rb
omg-actioncable-8.0.0.alpha2 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.1 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.0 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.0.rc1 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.0.beta3 lib/action_cable/subscription_adapter/test.rb
actioncable-7.2.0.beta2 lib/action_cable/subscription_adapter/test.rb