Sha256: 1cfa933ea462417e559be41dc4a37849f1a94c7c24d66ea6f8c5c08e038e6e82

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

class ResourceTestCase

  shared "return 200 Ok" do
    test "status should be 200 Ok" do
      assert_equal 200, last_response.status
    end

    use "content type header indicates JSON"
  end

  shared "return 201 Created" do
    test "status should be 201 Created" do
      assert_equal 201, last_response.status
    end

    test "location header should start with http://localhost" do
      assert_include "Location", last_response.headers
      generic_uri = %r{^http://localhost}
      assert_match generic_uri, last_response.headers["Location"]
    end

    use "content type header indicates JSON"
  end

  shared "return 204 No Content" do
    test "status should be 204 No Content" do
      assert_equal 204, last_response.status
    end

    use "return an empty response body"
    use "content type header not set"
  end

  shared "return 400 Bad Request" do
    test "status should be 400 Bad Request" do
      assert_equal 400, last_response.status
    end

    use "content type header indicates JSON"
  end

  shared "return 401 Unauthorized" do
    test "status should be 401 Unauthorized" do
      assert_equal 401, last_response.status
    end

    use "content type header indicates JSON"
  end

  shared "return 403 Forbidden" do
    test "status should be 403 Forbidden" do
      assert_equal 403, last_response.status
    end

    use "content type header indicates JSON"
  end

  shared "return 404 Not Found" do
    test "status should be 404 Not Found" do
      assert_equal 404, last_response.status
    end

    use "content type header indicates JSON"
  end

  shared "return 404 Not Found with empty response body" do
    use "return 404 Not Found"

    use "return an empty response body"
  end

  shared "return 409 Conflict" do
    test "status should be 409 Conflict" do
      assert_equal 409, last_response.status
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinatra_resource-0.4.24 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.23 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.22 examples/datacatalog/test/helpers/shared/status_codes.rb