aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/test_helper.rb
blob: 65b45e0c89b1d248b30a9f254b3f9d2fbedd3ef6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require File.expand_path('../../../load_paths', __FILE__)

require 'action_cable'
require 'active_support/testing/autorun'


require 'puma'

require 'mocha/setup'

require 'rack/mock'

# Require all the stubs and models
Dir[File.dirname(__FILE__) + '/stubs/*.rb'].each {|file| require file }

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