instance method assert_turbo_stream

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_turbo_stream(status: :ok, **attributes, &block)

Assert that the Turbo Stream request’s response body’s HTML contains a ‘<turbo-stream>` element.

Options

  • :status [Integer, Symbol] the HTTP response status

  • :action [String] matches the element’s [action] attribute

  • :target [String, #to_key] matches the element’s [target] attribute. If the value responds to #to_key, the value will be transformed by calling dom_id

  • :targets [String] matches the element’s [targets] attribute

    Given the following HTML response body:

    <turbo-stream action="remove" target="message_1"></turbo-stream>

    The following assertion would pass:

    assert_turbo_stream action: "remove", target: "message_1"
    

You can also pass a block make assertions about the contents of the element. Given the following HTML response body:

  <turbo-stream action="replace" target="message_1">
    <template>
      <p>Hello!</p>
    <template>
  </turbo-stream>

The following assertion would pass:

  assert_turbo_stream action: "replace", target: "message_1" do
    assert_select "template p", text: "Hello!"
  end

Parameters

status key = :ok
attributes keyrest
block block
Source
# File lib/turbo/test_assertions/integration_test_assertions.rb, line 41
      def assert_turbo_stream(status: :ok, **attributes, &block)
        assert_response status
        assert_equal Mime[:turbo_stream], response.media_type
        super(**attributes, &block)
      end

Defined in lib/turbo/test_assertions/integration_test_assertions.rb line 41 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Turbo::TestAssertions::IntegrationTestAssertions

Type at least 2 characters to search.

↑↓ navigate · open · esc close