instance method assert_no_turbo_stream_broadcasts

Ruby on Rails 2.0.23

Since v1.5.0 Last seen in v2.0.23

Available in: v1.5.0 v2.0.23

Signature

assert_no_turbo_stream_broadcasts(stream_name_or_object, &block)

Asserts that no ‘<turbo-stream>` elements were broadcast over Action Cable

Arguments

  • stream_name_or_object the objects used to generate the channel Action Cable name, or the name itself

  • &block optional block executed before the assertion

Asserts that no ‘<turbo-stream>` elements were broadcast:

message = Message.find(1)
message.broadcast_replace_to "messages"

assert_no_turbo_stream_broadcasts "messages" # fails with MiniTest::Assertion error

You can pass a block to run before the assertion:

message = Message.find(1)

assert_no_turbo_stream_broadcasts "messages" do
  # do something other than broadcast to "messages"
end

In addition to a String, the helper also accepts an Object or Array to determine the name of the channel the elements are broadcast to:

message = Message.find(1)

assert_no_turbo_stream_broadcasts message do
  # do something other than broadcast to "message_1"
end

Parameters

stream_name_or_object req
block block
Source
# File lib/turbo/broadcastable/test_helper.rb, line 104
      def assert_no_turbo_stream_broadcasts(stream_name_or_object, &block)
        block&.call

        stream_name = stream_name_from(stream_name_or_object)

        payloads = broadcasts(stream_name)

        assert payloads.empty?, "Expected no broadcasts on #{stream_name.inspect}, but there were #{payloads.count}"
      end

Defined in lib/turbo/broadcastable/test_helper.rb line 104 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Turbo::Broadcastable::TestHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close