Sha256: 93d4fa015b56aaf9070a3e44c67ff0c88e0a09cb22c1323e398f3c4a3ecc0b3f

Contents?: true

Size: 1.28 KB

Versions: 48

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require "abstract_unit"

class TestResponseTest < ActiveSupport::TestCase
  def assert_response_code_range(range, predicate)
    response = ActionDispatch::TestResponse.new
    (0..599).each do |status|
      response.status = status
      assert_equal range.include?(status), response.send(predicate),
                   "ActionDispatch::TestResponse.new(#{status}).#{predicate}"
    end
  end

  test "helpers" do
    assert_response_code_range 200..299, :successful?
    assert_response_code_range [404],    :not_found?
    assert_response_code_range 300..399, :redirection?
    assert_response_code_range 500..599, :server_error?
    assert_response_code_range 400..499, :client_error?
  end

  test "response parsing" do
    response = ActionDispatch::TestResponse.create(200, {}, "")
    assert_equal response.body, response.parsed_body

    response = ActionDispatch::TestResponse.create(200, { "Content-Type" => "application/json" }, '{ "foo": "fighters" }')
    assert_equal({ "foo" => "fighters" }, response.parsed_body)
  end

  test "response status aliases deprecated" do
    response = ActionDispatch::TestResponse.create
    assert_deprecated { response.success? }
    assert_deprecated { response.missing? }
    assert_deprecated { response.error? }
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
jets-1.9.7 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.6 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.5 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.4 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.3 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.2 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.1 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.9.0 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.14 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.13 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.12 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.11 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.10 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.9 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.8 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.7 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.6 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.5 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.4 vendor/rails/actionpack/test/dispatch/test_response_test.rb
jets-1.8.3 vendor/rails/actionpack/test/dispatch/test_response_test.rb