instance method assert_turbo_frame

Ruby on Rails 2.0.23

Since v2.0.23 Last seen in v2.0.23

Signature

assert_turbo_frame(*ids, loading: nil, src: nil, target: nil, count: 1, &block)

Assert that the rendered fragment of HTML contains a ‘<turbo-frame>` element.

Arguments

  • ids [String, Array<String, ActiveRecord::Base>] matches the element’s [id] attribute

Options

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

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

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

  • :count [Integer] indicates how many turbo frames are expected. Defaults to 1.

    Given the following HTML fragment:

    <turbo-frame id="example" target="_top"></turbo-frame>

    The following assertion would pass:

    assert_turbo_frame id: "example", target: "_top"
    

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

  <turbo-frame id="example">
    <p>Hello!</p>
  </turbo-frame>

The following assertion would pass:

  assert_turbo_frame id: "example" do
    assert_select "p", text: "Hello!"
  end

Parameters

ids rest
loading key = nil
src key = nil
target key = nil
count key = 1
block block
Source
# File lib/turbo/test_assertions.rb, line 121
    def assert_turbo_frame(*ids, loading: nil, src: nil, target: nil, count: 1, &block)
      id = ids.first.respond_to?(:to_key) ? ActionView::RecordIdentifier.dom_id(*ids) : ids.join('_')
      selector = %(turbo-frame[id="#{id}"])
      selector << %([loading="#{loading}"]) if loading
      selector << %([src="#{src}"]) if src
      selector << %([target="#{target}"]) if target
      assert_select selector, count: count, &block
    end

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

Defined in Turbo::TestAssertions

Type at least 2 characters to search.

↑↓ navigate · open · esc close