Sha256: 4330e4579cece8f3a014e3a05c0fb8daf7ecf6e78a9ff0497e78ae223db33e31

Contents?: true

Size: 1000 Bytes

Versions: 90

Compression:

Stored size: 1000 Bytes

Contents

# frozen_string_literal: true

require_relative "async"

module ActionCable
  module SubscriptionAdapter
    # == Test adapter for Action Cable
    #
    # The test adapter should be used only in testing. Along with
    # <tt>ActionCable::TestHelper</tt> 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 <tt>ActionCable::SubscriptionsAdapter::Async</tt> 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

90 entries across 88 versions & 7 rubygems

Version Path
actioncable-6.1.7.10 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.9 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.8 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.7 lib/action_cable/subscription_adapter/test.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actioncable-6.1.6.1/lib/action_cable/subscription_adapter/test.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actioncable-7.0.2.3/lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.6 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.5 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.4 lib/action_cable/subscription_adapter/test.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actioncable-7.0.2.3/lib/action_cable/subscription_adapter/test.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actioncable-6.1.6.1/lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.3 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.2 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7.1 lib/action_cable/subscription_adapter/test.rb
actioncable-6.0.6.1 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.7 lib/action_cable/subscription_adapter/test.rb
actioncable-6.0.6 lib/action_cable/subscription_adapter/test.rb
actioncable-6.1.6.1 lib/action_cable/subscription_adapter/test.rb
actioncable-6.0.5.1 lib/action_cable/subscription_adapter/test.rb
actioncable-6.0.5 lib/action_cable/subscription_adapter/test.rb