diff options
author | Matthew Draper <matthew@trebex.net> | 2016-01-20 15:54:20 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-01-24 22:51:06 +1030 |
commit | 68a9060d02b1eb35c12843c0f1653809b776b35b (patch) | |
tree | cde309fbbd468e972a1e01df4f50c1d2bbe119b4 /actioncable/test/test_helper.rb | |
parent | dcdadd5e82eed2e64d21399599b14501c3e16cc3 (diff) | |
download | rails-68a9060d02b1eb35c12843c0f1653809b776b35b.tar.gz rails-68a9060d02b1eb35c12843c0f1653809b776b35b.tar.bz2 rails-68a9060d02b1eb35c12843c0f1653809b776b35b.zip |
Using a hacked faye-websocket, drop EventMachine
Diffstat (limited to 'actioncable/test/test_helper.rb')
-rw-r--r-- | actioncable/test/test_helper.rb | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/actioncable/test/test_helper.rb b/actioncable/test/test_helper.rb index 6636ce078b..8ddbd4e764 100644 --- a/actioncable/test/test_helper.rb +++ b/actioncable/test/test_helper.rb @@ -13,28 +13,16 @@ 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 + def wait_for_async + e = Concurrent.global_io_executor + until e.completed_task_count == e.scheduled_task_count + sleep 0.1 end end - def spawn_eventmachine - Thread.new { EventMachine.run } unless EventMachine.reactor_running? + def run_in_eventmachine + yield + wait_for_async end end |