class ActionCable::Channel::TestCase
TODO: require?
Public Instance Methods
Asserts that the specified message has been sent to the stream.
def test_assert_transmitted_message ActionCable.server.broadcast 'messages', text: 'hello' assert_broadcast_on('messages', text: 'hello') end
If a block is passed, that block should cause a message with the specified data to be sent.
def test_assert_broadcast_on_again assert_broadcast_on('messages', text: 'hello') do ActionCable.server.broadcast 'messages', text: 'hello' end end
See also Minitest::Rails::Expectations::ActionCable::TestHelper#must_broadcast_on
See api.rubyonrails.org/v6.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcast_on
# File lib/minitest/rails/assertions/action_cable.rb, line 166
Asserts that the number of broadcasted messages to the stream matches the given number.
def test_broadcasts assert_broadcasts 'messages', 0 ActionCable.server.broadcast 'messages', { text: 'hello' } assert_broadcasts 'messages', 1 ActionCable.server.broadcast 'messages', { text: 'world' } assert_broadcasts 'messages', 2 end
If a block is passed, that block should cause the specified number of messages to be broadcasted.
def test_broadcasts_again assert_broadcasts('messages', 1) do ActionCable.server.broadcast 'messages', { text: 'hello' } end assert_broadcasts('messages', 2) do ActionCable.server.broadcast 'messages', { text: 'hi' } ActionCable.server.broadcast 'messages', { text: 'how are you?' } end end
See also Minitest::Rails::Expectations::ActionCable::TestHelper#must_have_broadcasts
See api.rubyonrails.org/v6.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcasts
# File lib/minitest/rails/assertions/action_cable.rb, line 116
Asserts that the specified stream has been started.
def test_assert_started_stream subscribe assert_has_stream 'messages' end
See also Minitest::Rails::Expectations::ActionCable::Channel#must_have_streams
See api.rubyonrails.org/v6.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream
# File lib/minitest/rails/assertions/action_cable.rb, line 194
Asserts that the specified stream for a model has started.
def test_assert_started_stream_for subscribe id: 42 assert_has_stream_for User.find(42) end
See also Minitest::Rails::Expectations::ActionCable::Channel#must_have_stream_for
See api.rubyonrails.org/v6.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream_for
# File lib/minitest/rails/assertions/action_cable.rb, line 207