aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-10-06 13:12:35 +1030
committerMatthew Draper <matthew@trebex.net>2016-10-06 13:12:35 +1030
commit1fe967d0c954f96476c471ee39455d8cceee3061 (patch)
tree743db20d84b68330c6aedbcf6e6c0d07f7c83b5f /actioncable
parentacd7ba795ed0f69691b7e6879f17fa50d7664ea0 (diff)
downloadrails-1fe967d0c954f96476c471ee39455d8cceee3061.tar.gz
rails-1fe967d0c954f96476c471ee39455d8cceee3061.tar.bz2
rails-1fe967d0c954f96476c471ee39455d8cceee3061.zip
Wait for the socket to be closed asynchronously
Diffstat (limited to 'actioncable')
-rw-r--r--actioncable/test/connection/client_socket_test.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actioncable/test/connection/client_socket_test.rb b/actioncable/test/connection/client_socket_test.rb
index dff7fefbfb..bc3ff6a3d7 100644
--- a/actioncable/test/connection/client_socket_test.rb
+++ b/actioncable/test/connection/client_socket_test.rb
@@ -51,10 +51,12 @@ class ActionCable::Connection::ClientSocketTest < ActionCable::TestCase
connection = open_connection
client = connection.websocket.send(:websocket)
+ event = Concurrent::Event.new
client.instance_variable_get("@stream")
.instance_variable_get("@rack_hijack_io")
- .expects(:close)
+ .define_singleton_method(:close) { event.set }
connection.close
+ event.wait
end
end
@@ -63,7 +65,13 @@ class ActionCable::Connection::ClientSocketTest < ActionCable::TestCase
env = Rack::MockRequest.env_for "/test",
"HTTP_CONNECTION" => "upgrade", "HTTP_UPGRADE" => "websocket",
"HTTP_HOST" => "localhost", "HTTP_ORIGIN" => "http://rubyonrails.com"
- env["rack.hijack"] = -> { env["rack.hijack_io"] = StringIO.new }
+ io = \
+ begin
+ Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM, 0).first
+ rescue
+ StringIO.new
+ end
+ env["rack.hijack"] = -> { env["rack.hijack_io"] = io }
Connection.new(@server, env).tap do |connection|
connection.process