aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/connection
diff options
context:
space:
mode:
authorutilum <oz@utilum.com>2018-04-22 18:33:40 +0200
committerutilum <oz@utilum.com>2018-04-26 08:02:08 +0200
commit94ceda00b99794d4f8c28e84d237cc1541af12d7 (patch)
treedaf32b6039ce0056950dd22a915fdc71087029b0 /actioncable/test/connection
parente4e25cc8dc76f641a304251ba37e1db99713e584 (diff)
downloadrails-94ceda00b99794d4f8c28e84d237cc1541af12d7.tar.gz
rails-94ceda00b99794d4f8c28e84d237cc1541af12d7.tar.bz2
rails-94ceda00b99794d4f8c28e84d237cc1541af12d7.zip
assert_called
Diffstat (limited to 'actioncable/test/connection')
-rw-r--r--actioncable/test/connection/authorization_test.rb9
-rw-r--r--actioncable/test/connection/base_test.rb21
-rw-r--r--actioncable/test/connection/identifier_test.rb5
-rw-r--r--actioncable/test/connection/stream_test.rb8
-rw-r--r--actioncable/test/connection/subscriptions_test.rb18
5 files changed, 40 insertions, 21 deletions
diff --git a/actioncable/test/connection/authorization_test.rb b/actioncable/test/connection/authorization_test.rb
index 7d039336b8..be41d510ff 100644
--- a/actioncable/test/connection/authorization_test.rb
+++ b/actioncable/test/connection/authorization_test.rb
@@ -1,9 +1,12 @@
# frozen_string_literal: true
require "test_helper"
+require "active_support/testing/method_call_assertions"
require "stubs/test_server"
class ActionCable::Connection::AuthorizationTest < ActionCable::TestCase
+ include ActiveSupport::Testing::MethodCallAssertions
+
class Connection < ActionCable::Connection::Base
attr_reader :websocket
@@ -25,9 +28,9 @@ class ActionCable::Connection::AuthorizationTest < ActionCable::TestCase
"HTTP_HOST" => "localhost", "HTTP_ORIGIN" => "http://rubyonrails.com"
connection = Connection.new(server, env)
- connection.websocket.expects(:close)
-
- connection.process
+ assert_called(connection.websocket, :close) do
+ connection.process
+ end
end
end
end
diff --git a/actioncable/test/connection/base_test.rb b/actioncable/test/connection/base_test.rb
index ac10b3d4d2..cbeac1bb3a 100644
--- a/actioncable/test/connection/base_test.rb
+++ b/actioncable/test/connection/base_test.rb
@@ -3,8 +3,11 @@
require "test_helper"
require "stubs/test_server"
require "active_support/core_ext/object/json"
+require "active_support/testing/method_call_assertions"
class ActionCable::Connection::BaseTest < ActionCable::TestCase
+ include ActiveSupport::Testing::MethodCallAssertions
+
class Connection < ActionCable::Connection::Base
attr_reader :websocket, :subscriptions, :message_buffer, :connected
@@ -60,10 +63,10 @@ class ActionCable::Connection::BaseTest < ActionCable::TestCase
connection = open_connection
connection.websocket.expects(:transmit).with({ type: "welcome" }.to_json)
- connection.message_buffer.expects(:process!)
-
- connection.process
- wait_for_async
+ assert_called(connection.message_buffer, :process!) do
+ connection.process
+ wait_for_async
+ end
assert_equal [ connection ], @server.connections
assert connection.connected
@@ -80,8 +83,9 @@ class ActionCable::Connection::BaseTest < ActionCable::TestCase
connection.send :handle_open
assert connection.connected
- connection.subscriptions.expects(:unsubscribe_from_all)
- connection.send :handle_close
+ assert_called(connection.subscriptions, :unsubscribe_from_all) do
+ connection.send :handle_close
+ end
assert_not connection.connected
assert_equal [], @server.connections
@@ -106,8 +110,9 @@ class ActionCable::Connection::BaseTest < ActionCable::TestCase
connection = open_connection
connection.process
- connection.websocket.expects(:close)
- connection.close
+ assert_called(connection.websocket, :close) do
+ connection.close
+ end
end
end
diff --git a/actioncable/test/connection/identifier_test.rb b/actioncable/test/connection/identifier_test.rb
index f3bc6f99a4..de1ae1d5b9 100644
--- a/actioncable/test/connection/identifier_test.rb
+++ b/actioncable/test/connection/identifier_test.rb
@@ -44,8 +44,9 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
run_in_eventmachine do
open_connection_with_stubbed_pubsub
- @connection.websocket.expects(:close)
- @connection.process_internal_message "type" => "disconnect"
+ assert_called(@connection.websocket, :close) do
+ @connection.process_internal_message "type" => "disconnect"
+ end
end
end
diff --git a/actioncable/test/connection/stream_test.rb b/actioncable/test/connection/stream_test.rb
index b0419b0994..1e1466af31 100644
--- a/actioncable/test/connection/stream_test.rb
+++ b/actioncable/test/connection/stream_test.rb
@@ -1,9 +1,12 @@
# frozen_string_literal: true
require "test_helper"
+require "active_support/testing/method_call_assertions"
require "stubs/test_server"
class ActionCable::Connection::StreamTest < ActionCable::TestCase
+ include ActiveSupport::Testing::MethodCallAssertions
+
class Connection < ActionCable::Connection::Base
attr_reader :connected, :websocket, :errors
@@ -42,9 +45,10 @@ class ActionCable::Connection::StreamTest < ActionCable::TestCase
# Internal hax = :(
client = connection.websocket.send(:websocket)
client.instance_variable_get("@stream").instance_variable_get("@rack_hijack_io").expects(:write).raises(closed_exception, "foo")
- client.expects(:client_gone)
- client.write("boo")
+ assert_called(client, :client_gone) do
+ client.write("boo")
+ end
assert_equal [], connection.errors
end
end
diff --git a/actioncable/test/connection/subscriptions_test.rb b/actioncable/test/connection/subscriptions_test.rb
index 3323785494..7bc8c4241c 100644
--- a/actioncable/test/connection/subscriptions_test.rb
+++ b/actioncable/test/connection/subscriptions_test.rb
@@ -1,8 +1,11 @@
# frozen_string_literal: true
require "test_helper"
+require "active_support/testing/method_call_assertions"
class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
+ include ActiveSupport::Testing::MethodCallAssertions
+
class Connection < ActionCable::Connection::Base
attr_reader :websocket
@@ -55,9 +58,11 @@ class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
subscribe_to_chat_channel
channel = subscribe_to_chat_channel
- channel.expects(:unsubscribe_from_channel)
- @subscriptions.execute_command "command" => "unsubscribe", "identifier" => @chat_identifier
+ assert_called(channel, :unsubscribe_from_channel) do
+ @subscriptions.execute_command "command" => "unsubscribe", "identifier" => @chat_identifier
+ end
+
assert_empty @subscriptions.identifiers
end
end
@@ -92,10 +97,11 @@ class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase
channel2_id = ActiveSupport::JSON.encode(id: 2, channel: "ActionCable::Connection::SubscriptionsTest::ChatChannel")
channel2 = subscribe_to_chat_channel(channel2_id)
- channel1.expects(:unsubscribe_from_channel)
- channel2.expects(:unsubscribe_from_channel)
-
- @subscriptions.unsubscribe_from_all
+ assert_called(channel1, :unsubscribe_from_channel) do
+ assert_called(channel2, :unsubscribe_from_channel) do
+ @subscriptions.unsubscribe_from_all
+ end
+ end
end
end