Sha256: 3f642c7956c110ea02983ef254db8881ef813c4edf90e02721d7df1c328f45c5

Contents?: true

Size: 695 Bytes

Versions: 2

Compression:

Stored size: 695 Bytes

Contents

require "spec_helper"

describe Rack::API, "Params" do
   before do
    Rack::API.app do
      version :v1 do
        get("users/:id(.:format)") { params }
        post("users") { params }
      end
    end
  end

  it "detects optional names from routing params" do
    get "/v1/users/1.json"
    JSON.load(last_response.body).should == {"id" => "1", "format" => "json"}
  end

  it "detects query string params" do
    get "/v1/users/1?include=articles"
    JSON.load(last_response.body).should == {"id" => "1", "include" => "articles"}
  end

  it "detects post params" do
    post "/v1/users", :name => "John Doe"
    JSON.load(last_response.body).should == {"name" => "John Doe"}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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