aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/connection
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/test/connection')
-rw-r--r--actioncable/test/connection/base_test.rb1
-rw-r--r--actioncable/test/connection/identifier_test.rb27
-rw-r--r--actioncable/test/connection/multiple_identifiers_test.rb11
-rw-r--r--actioncable/test/connection/string_identifier_test.rb13
4 files changed, 18 insertions, 34 deletions
diff --git a/actioncable/test/connection/base_test.rb b/actioncable/test/connection/base_test.rb
index ed62e90b70..9e480ab60d 100644
--- a/actioncable/test/connection/base_test.rb
+++ b/actioncable/test/connection/base_test.rb
@@ -80,7 +80,6 @@ class ActionCable::Connection::BaseTest < ActionCable::TestCase
connection.process
# Setup the connection
- connection.server.stubs(:timer).returns(true)
connection.send :handle_open
assert connection.connected
diff --git a/actioncable/test/connection/identifier_test.rb b/actioncable/test/connection/identifier_test.rb
index de1ae1d5b9..204197c2a7 100644
--- a/actioncable/test/connection/identifier_test.rb
+++ b/actioncable/test/connection/identifier_test.rb
@@ -21,28 +21,28 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
test "connection identifier" do
run_in_eventmachine do
- open_connection_with_stubbed_pubsub
+ open_connection
assert_equal "User#lifo", @connection.connection_identifier
end
end
test "should subscribe to internal channel on open and unsubscribe on close" do
run_in_eventmachine do
- pubsub = mock("pubsub_adapter")
- pubsub.expects(:subscribe).with("action_cable/User#lifo", kind_of(Proc))
- pubsub.expects(:unsubscribe).with("action_cable/User#lifo", kind_of(Proc))
-
server = TestServer.new
- server.stubs(:pubsub).returns(pubsub)
- open_connection server: server
+ server.pubsub.expects(:subscribe)
+ .with("action_cable/User#lifo", kind_of(Proc))
+ server.pubsub.expects(:unsubscribe)
+ .with("action_cable/User#lifo", kind_of(Proc))
+
+ open_connection(server)
close_connection
end
end
test "processing disconnect message" do
run_in_eventmachine do
- open_connection_with_stubbed_pubsub
+ open_connection
assert_called(@connection.websocket, :close) do
@connection.process_internal_message "type" => "disconnect"
@@ -52,7 +52,7 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
test "processing invalid message" do
run_in_eventmachine do
- open_connection_with_stubbed_pubsub
+ open_connection
assert_not_called(@connection.websocket, :close) do
@connection.process_internal_message "type" => "unknown"
@@ -61,14 +61,9 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
end
private
- def open_connection_with_stubbed_pubsub
- server = TestServer.new
- server.stubs(:adapter).returns(stub_everything("adapter"))
-
- open_connection server: server
- end
+ def open_connection(server = nil)
+ server ||= TestServer.new
- def open_connection(server:)
env = Rack::MockRequest.env_for "/test", "HTTP_HOST" => "localhost", "HTTP_CONNECTION" => "upgrade", "HTTP_UPGRADE" => "websocket"
@connection = Connection.new(server, env)
diff --git a/actioncable/test/connection/multiple_identifiers_test.rb b/actioncable/test/connection/multiple_identifiers_test.rb
index 7f90cb3876..51716410b2 100644
--- a/actioncable/test/connection/multiple_identifiers_test.rb
+++ b/actioncable/test/connection/multiple_identifiers_test.rb
@@ -16,20 +16,15 @@ class ActionCable::Connection::MultipleIdentifiersTest < ActionCable::TestCase
test "multiple connection identifiers" do
run_in_eventmachine do
- open_connection_with_stubbed_pubsub
+ open_connection
+
assert_equal "Room#my-room:User#lifo", @connection.connection_identifier
end
end
private
- def open_connection_with_stubbed_pubsub
+ def open_connection
server = TestServer.new
- server.stubs(:pubsub).returns(stub_everything("pubsub"))
-
- open_connection server: server
- end
-
- def open_connection(server:)
env = Rack::MockRequest.env_for "/test", "HTTP_HOST" => "localhost", "HTTP_CONNECTION" => "upgrade", "HTTP_UPGRADE" => "websocket"
@connection = Connection.new(server, env)
diff --git a/actioncable/test/connection/string_identifier_test.rb b/actioncable/test/connection/string_identifier_test.rb
index 4cb58e7fd0..f7019b926a 100644
--- a/actioncable/test/connection/string_identifier_test.rb
+++ b/actioncable/test/connection/string_identifier_test.rb
@@ -18,22 +18,17 @@ class ActionCable::Connection::StringIdentifierTest < ActionCable::TestCase
test "connection identifier" do
run_in_eventmachine do
- open_connection_with_stubbed_pubsub
+ open_connection
+
assert_equal "random-string", @connection.connection_identifier
end
end
private
- def open_connection_with_stubbed_pubsub
- @server = TestServer.new
- @server.stubs(:pubsub).returns(stub_everything("pubsub"))
-
- open_connection
- end
-
def open_connection
+ server = TestServer.new
env = Rack::MockRequest.env_for "/test", "HTTP_HOST" => "localhost", "HTTP_CONNECTION" => "upgrade", "HTTP_UPGRADE" => "websocket"
- @connection = Connection.new(@server, env)
+ @connection = Connection.new(server, env)
@connection.process
@connection.send :on_open