From 9c8d4850f1d69db784ffafa93f38f780bf57c519 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 18 Dec 2018 16:48:14 -0500 Subject: Add streams assert methods to ActionCable channel test case --- actioncable/test/channel/test_case_test.rb | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'actioncable/test') diff --git a/actioncable/test/channel/test_case_test.rb b/actioncable/test/channel/test_case_test.rb index 63d0d6207e..9c360d5dc3 100644 --- a/actioncable/test/channel/test_case_test.rb +++ b/actioncable/test/channel/test_case_test.rb @@ -93,13 +93,39 @@ class StreamsTestChannelTest < ActionCable::Channel::TestCase def test_stream_without_params subscribe - assert_equal "test_0", streams.last + assert_has_stream "test_0" end def test_stream_with_params subscribe id: 42 - assert_equal "test_42", streams.last + assert_has_stream "test_42" + end +end + +class StreamsForTestChannel < ActionCable::Channel::Base + def subscribed + stream_for User.new(params[:id]) + end +end + +class StreamsForTestChannelTest < ActionCable::Channel::TestCase + def test_stream_with_params + subscribe id: 42 + + assert_has_stream_for User.new(42) + end +end + +class NoStreamsTestChannel < ActionCable::Channel::Base + def subscribed; end # no-op +end + +class NoStreamsTestChannelTest < ActionCable::Channel::TestCase + def test_stream_with_params + subscribe + + assert_no_streams end end -- cgit v1.2.3