Sha256: 9d84126dc61b50e23d28557b8b2fcb5c8b779909a7103e09d10c8b400f4a2a0a

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require "test_helper"
require_relative "common"
require_relative "channel_prefix"

class EventedRedisAdapterTest < ActionCable::TestCase
  include CommonSubscriptionAdapterTest
  include ChannelPrefixTest

  def setup
    assert_deprecated do
      super
    end

    # em-hiredis is warning-rich
    @previous_verbose, $VERBOSE = $VERBOSE, nil
  end

  def teardown
    super

    # Ensure EM is shut down before we re-enable warnings
    EventMachine.reactor_thread.tap do |thread|
      EventMachine.stop
      thread.join
    end

    $VERBOSE = @previous_verbose
  end

  def test_slow_eventmachine
    require "eventmachine"
    require "thread"

    lock = Mutex.new

    EventMachine.singleton_class.class_eval do
      alias_method :delayed_initialize_event_machine, :initialize_event_machine
      define_method(:initialize_event_machine) do
        lock.synchronize do
          sleep 0.5
          delayed_initialize_event_machine
        end
      end
    end

    test_basic_broadcast
  ensure
    lock.synchronize do
      EventMachine.singleton_class.class_eval do
        alias_method :initialize_event_machine, :delayed_initialize_event_machine
        remove_method :delayed_initialize_event_machine
      end
    end
  end

  def cable_config
    { adapter: "evented_redis", url: "redis://:password@127.0.0.1:6379/12" }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-on-quails-0.1.0 actioncable/test/subscription_adapter/evented_redis_test.rb