Sha256: 4ea6e804927fc8cd4e99b2149bf6d285a94392f2c47311d9ca39e773381b54b6

Contents?: true

Size: 1.84 KB

Versions: 33

Compression:

Stored size: 1.84 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

33 entries across 33 versions & 1 rubygems

Version Path
sinatra_resource-0.4.21 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.20 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.19 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.18 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.17 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.16 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.15 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.14 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.13 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.12 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.11 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.10 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.9 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.8 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.7 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.6 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.5 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.4 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.3 examples/datacatalog/test/helpers/shared/status_codes.rb
sinatra_resource-0.4.2 examples/datacatalog/test/helpers/shared/status_codes.rb