aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-01-30 06:41:14 +1030
committerMatthew Draper <matthew@trebex.net>2016-01-30 06:41:14 +1030
commite6d0d4b1ae1970f3c4379f5bc2c4147a227221c3 (patch)
tree9e87130ebf9c64e6310002c1a2430442274e5384 /actioncable
parentda6342779b3228e1796ed4e3c385b52d60821b0f (diff)
downloadrails-e6d0d4b1ae1970f3c4379f5bc2c4147a227221c3.tar.gz
rails-e6d0d4b1ae1970f3c4379f5bc2c4147a227221c3.tar.bz2
rails-e6d0d4b1ae1970f3c4379f5bc2c4147a227221c3.zip
Don't bother stopping EM between tests
It's not strictly necessary, and maybe this will help with the current test failure.
Diffstat (limited to 'actioncable')
-rw-r--r--actioncable/test/client_test.rb41
1 files changed, 3 insertions, 38 deletions
diff --git a/actioncable/test/client_test.rb b/actioncable/test/client_test.rb
index 3d9690fb01..fd03c2a24c 100644
--- a/actioncable/test/client_test.rb
+++ b/actioncable/test/client_test.rb
@@ -31,19 +31,13 @@ class ClientTest < ActionCable::TestCase
server.config.disable_request_forgery_protection = true
server.config.channel_load_paths = [File.expand_path('client', __dir__)]
- @reactor_mutex = Mutex.new
- @reactor_users = 0
- @reactor_running = Concurrent::Event.new
+ Thread.new { EventMachine.run } unless EventMachine.reactor_running?
# faye-websocket is warning-rich
@previous_verbose, $VERBOSE = $VERBOSE, nil
end
def teardown
- if @reactor_running.set?
- EM.stop
- end
-
$VERBOSE = @previous_verbose
begin
@@ -70,38 +64,10 @@ class ClientTest < ActionCable::TestCase
t.join if t
end
- def start_event_machine
- @reactor_mutex.synchronize do
- unless @reactor_running.set?
- @reactor ||= Thread.new do
- EM.next_tick do
- @reactor_running.set
- end
- EM.run
- end
- @reactor_running.wait(WAIT_WHEN_EXPECTING_EVENT)
- end
- @reactor_users += 1
- end
- end
-
- def stop_event_machine
- @reactor_mutex.synchronize do
- @reactor_users -= 1
- if @reactor_users < 1
- @reactor_running.reset
- EM.stop
- @reactor = nil
- end
- end
- end
-
class SyncClient
attr_reader :pings
- def initialize(em_controller, port)
- em_controller.start_event_machine
-
+ def initialize(port)
@ws = Faye::WebSocket::Client.new("ws://127.0.0.1:#{port}/")
@messages = Queue.new
@closed = Concurrent::Event.new
@@ -135,7 +101,6 @@ class ClientTest < ActionCable::TestCase
end
@ws.on(:close) do |event|
- em_controller.stop_event_machine
@closed.set
end
@@ -192,7 +157,7 @@ class ClientTest < ActionCable::TestCase
end
def faye_client(port)
- SyncClient.new(self, port)
+ SyncClient.new(port)
end
def test_single_client