1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/test/test_helper.rb
Pratik Naik 84b1f0a3e6 Send subscription confirmation from server to the client to avoid race conditions.
Without this, it's very easy to send messages over a subscription even before the
redis pubsub has been fully initialized.

Now we delay calling the subscription#connected method on the client side until we
receive a subscription confirmation message from the server.
2015-10-16 21:11:21 -05:00

47 lines
983 B
Ruby

require "rubygems"
require "bundler"
gem 'minitest'
require "minitest/autorun"
Bundler.setup
Bundler.require :default, :test
require 'puma'
require 'em-hiredis'
require 'mocha/mini_test'
require 'rack/mock'
require 'action_cable'
ActiveSupport.test_order = :sorted
# Require all the stubs and models
Dir[File.dirname(__FILE__) + '/stubs/*.rb'].each {|file| require file }
require 'celluloid'
$CELLULOID_DEBUG = false
$CELLULOID_TEST = false
Celluloid.logger = Logger.new(StringIO.new)
require 'faye/websocket'
class << Faye::WebSocket
remove_method :ensure_reactor_running
# We don't want Faye to start the EM reactor in tests because it makes testing much harder.
# We want to be able to start and stop EM loop in tests to make things simpler.
def ensure_reactor_running
# no-op
end
end
class ActionCable::TestCase < ActiveSupport::TestCase
def run_in_eventmachine
EM.run do
yield
EM.run_deferred_callbacks
EM.stop
end
end
end