aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test
diff options
context:
space:
mode:
authorSergey Ponomarev <me@sergey-ponomarev.ru>2018-12-18 16:48:14 -0500
committerSergey Ponomarev <me@sergey-ponomarev.ru>2018-12-18 17:37:53 -0500
commit9c8d4850f1d69db784ffafa93f38f780bf57c519 (patch)
treea3dd4b89de4123f3d483a4123d180dc19d7386ea /actioncable/test
parent2f6456cbe1da73c13b37e23720caa8716df85e78 (diff)
downloadrails-9c8d4850f1d69db784ffafa93f38f780bf57c519.tar.gz
rails-9c8d4850f1d69db784ffafa93f38f780bf57c519.tar.bz2
rails-9c8d4850f1d69db784ffafa93f38f780bf57c519.zip
Add streams assert methods to ActionCable channel test case
Diffstat (limited to 'actioncable/test')
-rw-r--r--actioncable/test/channel/test_case_test.rb30
1 files changed, 28 insertions, 2 deletions
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