Sha256: 8b3d96d93d8825c5d9e1d147a877f8f7a32d981825566a5faef905f6b0cf8c84

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 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} }
        patch("patch") { {:patch => true} }
        options("options") { {:options => 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
      last_response.body.should == {method => true}.to_json
    end
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-api-1.1.0 spec/rack-api/http_methods_spec.rb