module Turbo::TestAssertions
def assert_no_turbo_stream(action:, target: nil, targets: nil)
assert_no_turbo_stream action: "remove", target: "message_1"
The following assertion would fail:
Given the following HTML fragment:
attribute
* :targets [String] matches the element's [targets]
the value will be transformed by calling dom_id
[target] attribute. If the value responds to #to_key,
* :target [String, #to_key] matches the element's
attribute
* :action [String] matches the element's [action]
==== Options
element.
Assert that the rendered fragment of HTML does not contain a `
def assert_no_turbo_stream(action:, target: nil, targets: nil) selector = %(turbo-stream[action="#{action}"]) selector << %([target="#{target.respond_to?(:to_key) ? dom_id(target) : target}"]) if target selector << %([targets="#{targets}"]) if targets assert_select selector, count: 0 end
def assert_turbo_stream(action:, target: nil, targets: nil, count: 1, &block)
end
assert_select "template p", text: "Hello!"
assert_turbo_stream action: "replace", target: "message_1" do
The following assertion would pass:
Hello!
element. Given the following HTML fragment:
You can also pass a block make assertions about the contents of the
assert_turbo_stream action: "remove", target: "message_1"
The following assertion would pass:
Given the following HTML fragment:
Defaults to 1.
* :count [Integer] indicates how many turbo streams are expected.
attribute
* :targets [String] matches the element's [targets]
the value will be transformed by calling dom_id
[target] attribute. If the value responds to #to_key,
* :target [String, #to_key] matches the element's
attribute
* :action [String] matches the element's [action]
==== Options
element.
Assert that the rendered fragment of HTML contains a `
def assert_turbo_stream(action:, target: nil, targets: nil, count: 1, &block) selector = %(turbo-stream[action="#{action}"]) selector << %([target="#{target.respond_to?(:to_key) ? dom_id(target) : target}"]) if target selector << %([targets="#{targets}"]) if targets assert_select selector, count: count, &block end