Sha256: e581dc6ec16903e1a549939ae1521b5e8b7ed31a73c779fde7c63688c36f3736

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require "turbo_test"

class Turbo::StreamsControllerTest < ActionDispatch::IntegrationTest
  test "create with respond to" do
    post messages_path
    assert_redirected_to message_path(id: 1)

    post messages_path, as: :turbo_stream
    assert_response :ok
    assert_turbo_stream action: :append, target: "messages" do |selected|
      assert_equal "<template>message_1</template>", selected.children.to_html
    end
  end

  test "show all turbo actions" do
    get message_path(id: 1), as: :turbo_stream
    assert_equal <<-STREAM, @response.body
<turbo-stream action="remove" target="message_1"></turbo-stream>
<turbo-stream action="replace" target="message_1"><template><p>My message</p></template></turbo-stream>
<turbo-stream action="replace" target="message_1"><template>Something else</template></turbo-stream>
<turbo-stream action="replace" target="message_5"><template>Something fifth</template></turbo-stream>
<turbo-stream action="replace" target="message_5"><template><p>OLLA!</p></template></turbo-stream>
<turbo-stream action="append" target="messages"><template><p>My message</p></template></turbo-stream>
<turbo-stream action="append" target="messages"><template><p>OLLA!</p></template></turbo-stream>
<turbo-stream action="prepend" target="messages"><template><p>My message</p></template></turbo-stream>
<turbo-stream action="prepend" target="messages"><template><p>OLLA!</p></template></turbo-stream>
STREAM
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
turbo-rails-0.5.3 test/streams/streams_controller_test.rb
turbo-rails-0.5.2 test/streams/streams_controller_test.rb
turbo-rails-0.5.1 test/streams/streams_controller_test.rb
turbo-rails-0.5.0 test/streams/streams_controller_test.rb