Sha256: 70ed364a2678b620f324d9b4c163cbef245b24d23d9dcdb6b2090a62164a48c5

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

class ResourceTestCase
  
  shared "return 200 Ok" do
    test "status should be 200 Ok" do
      assert_equal 200, last_response.status
    end
  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
  end

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

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

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

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

  shared "return 404 Not Found" do
    test "status should be 404 Not Found" do
      assert_equal 404, last_response.status
    end
  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

1 entries across 1 versions & 1 rubygems

Version Path
sinatra_resource-0.1.0 examples/datacatalog/test/helpers/shared/status_codes.rb