Sha256: c942010c668a4bd134c90e1f53b220e2b383566e7b11865a3805e7e4ef26354e

Contents?: true

Size: 688 Bytes

Versions: 2

Compression:

Stored size: 688 Bytes

Contents

require "spec_helper"

describe Rack::API, "HTTP Methods" do
   before do
    Rack::API.app do
      version :v1 do
        get("get") { {:get => true} }
        post("post") { {:post => true} }
        put("put") { {:put => true} }
        delete("delete") { {:delete => true} }
        head("head") { {:head => true} }
      end
    end
  end

  Rack::API::Runner::HTTP_METHODS.each do |method|
    it "renders #{method}" do
      send method, "/v1/#{method}"
      last_response.status.should == 200
      JSON.load(last_response.body).should == {method => true}
    end
  end

  it "does not render unknown methods" do
    post "/get"
    last_response.status.should == 404
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-api-0.1.1 spec/rack-api/http_methods_spec.rb
rack-api-0.1.0 spec/rack-api/http_methods_spec.rb