Module: Turbo::TestAssertions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/turbo/test_assertions.rb
Instance Method Summary collapse
- #assert_no_turbo_stream(action:, target: nil, targets: nil) ⇒ Object
- #assert_turbo_stream(action:, target: nil, targets: nil, status: :ok, &block) ⇒ Object
Instance Method Details
#assert_no_turbo_stream(action:, target: nil, targets: nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/turbo/test_assertions.rb', line 19 def assert_no_turbo_stream(action:, target: nil, targets: nil) assert_equal Mime[:turbo_stream], response.media_type 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 |
#assert_turbo_stream(action:, target: nil, targets: nil, status: :ok, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/turbo/test_assertions.rb', line 10 def assert_turbo_stream(action:, target: nil, targets: nil, status: :ok, &block) assert_response status assert_equal Mime[:turbo_stream], response.media_type 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: 1, &block end |