aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_helper.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2015-10-15 21:11:49 -0500
committerPratik Naik <pratiknaik@gmail.com>2015-10-15 21:11:49 -0500
commitee16ca8990e80da731e6566b34640e65f6b337e6 (patch)
tree467f7b0c3acac7133ef61fe2bf7970321a98e2fa /test/test_helper.rb
parentdb56e8bf3ba8f562219f9f87d300153e848ed8b2 (diff)
downloadrails-ee16ca8990e80da731e6566b34640e65f6b337e6.tar.gz
rails-ee16ca8990e80da731e6566b34640e65f6b337e6.tar.bz2
rails-ee16ca8990e80da731e6566b34640e65f6b337e6.zip
Run connection tests in EM loop
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 5640178f34..39fa98c1f9 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -19,3 +19,21 @@ ActiveSupport.test_order = :sorted
Dir[File.dirname(__FILE__) + '/stubs/*.rb'].each {|file| require file }
Celluloid.logger = Logger.new(StringIO.new)
+
+class Faye::WebSocket
+ # 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 EW loop in tests to make things simpler.
+ def self.ensure_reactor_running
+ # no-op
+ end
+end
+
+class ActionCable::TestCase < ActiveSupport::TestCase
+ def run_in_eventmachine
+ EM.run do
+ yield
+
+ EM::Timer.new(0.1) { EM.stop }
+ end
+ end
+end