diff options
Diffstat (limited to 'actioncable/test/connection/identifier_test.rb')
-rw-r--r-- | actioncable/test/connection/identifier_test.rb | 27 |
1 files changed, 11 insertions, 16 deletions
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) |