aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/channel/stream_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/test/channel/stream_test.rb')
-rw-r--r--actioncable/test/channel/stream_test.rb37
1 files changed, 25 insertions, 12 deletions
diff --git a/actioncable/test/channel/stream_test.rb b/actioncable/test/channel/stream_test.rb
index b4b118846d..dbb53fec1f 100644
--- a/actioncable/test/channel/stream_test.rb
+++ b/actioncable/test/channel/stream_test.rb
@@ -2,6 +2,7 @@
require "test_helper"
require "active_support/testing/method_call_assertions"
+require "minitest/mock"
require "stubs/test_connection"
require "stubs/room"
@@ -54,29 +55,41 @@ module ActionCable::StreamTests
test "streaming start and stop" do
run_in_eventmachine do
connection = TestConnection.new
- connection.pubsub.expects(:subscribe).with("test_room_1", kind_of(Proc), kind_of(Proc))
- channel = ChatChannel.new connection, "{id: 1}", id: 1
- channel.subscribe_to_channel
+ pubsub = Minitest::Mock.new connection.pubsub
- wait_for_async
+ pubsub.expect(:subscribe, nil, ["test_room_1", Proc, Proc])
+ pubsub.expect(:unsubscribe, nil, ["test_room_1", Proc])
+
+ connection.stub(:pubsub, pubsub) do
+ channel = ChatChannel.new connection, "{id: 1}", id: 1
+ channel.subscribe_to_channel
+
+ wait_for_async
+ channel.unsubscribe_from_channel
+ end
- connection.pubsub.expects(:unsubscribe)
- channel.unsubscribe_from_channel
+ assert pubsub.verify
end
end
test "stream from non-string channel" do
run_in_eventmachine do
connection = TestConnection.new
- connection.pubsub.expects(:subscribe).with("channel", kind_of(Proc), kind_of(Proc))
+ pubsub = Minitest::Mock.new connection.pubsub
- channel = SymbolChannel.new connection, ""
- channel.subscribe_to_channel
+ pubsub.expect(:subscribe, nil, ["channel", Proc, Proc])
+ pubsub.expect(:unsubscribe, nil, ["channel", Proc])
- wait_for_async
+ connection.stub(:pubsub, pubsub) do
+ channel = SymbolChannel.new connection, ""
+ channel.subscribe_to_channel
+
+ wait_for_async
+
+ channel.unsubscribe_from_channel
+ end
- connection.pubsub.expects(:unsubscribe)
- channel.unsubscribe_from_channel
+ assert pubsub.verify
end
end