class ActionCable::TestCase
Public Instance Methods
assert_broadcast_on(stream, data)
click to toggle source
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 82
assert_broadcasts(stream, number)
click to toggle source
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 33