aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/channel/periodic_timers_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/test/channel/periodic_timers_test.rb')
-rw-r--r--actioncable/test/channel/periodic_timers_test.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/actioncable/test/channel/periodic_timers_test.rb b/actioncable/test/channel/periodic_timers_test.rb
index 500b984ca6..8d9482577c 100644
--- a/actioncable/test/channel/periodic_timers_test.rb
+++ b/actioncable/test/channel/periodic_timers_test.rb
@@ -4,8 +4,11 @@ require "test_helper"
require "stubs/test_connection"
require "stubs/room"
require "active_support/time"
+require "active_support/testing/method_call_assertions"
class ActionCable::Channel::PeriodicTimersTest < ActiveSupport::TestCase
+ include ActiveSupport::Testing::MethodCallAssertions
+
class ChatChannel < ActionCable::Channel::Base
# Method name arg
periodically :send_updates, every: 1
@@ -64,11 +67,22 @@ class ActionCable::Channel::PeriodicTimersTest < ActiveSupport::TestCase
end
test "timer start and stop" do
- @connection.server.event_loop.expects(:timer).times(3).returns(stub(shutdown: nil))
- channel = ChatChannel.new @connection, "{id: 1}", id: 1
+ mock = Minitest::Mock.new
+ 3.times { mock.expect(:shutdown, nil) }
+
+ assert_called(
+ @connection.server.event_loop,
+ :timer,
+ times: 3,
+ returns: mock
+ ) do
+ channel = ChatChannel.new @connection, "{id: 1}", id: 1
+
+ channel.subscribe_to_channel
+ channel.unsubscribe_from_channel
+ assert_equal [], channel.send(:active_periodic_timers)
+ end
- channel.subscribe_to_channel
- channel.unsubscribe_from_channel
- assert_equal [], channel.send(:active_periodic_timers)
+ assert mock.verify
end
end