Sha256: 4b6b918187bcc7d21f57ca01b52d24f7189bb80fb5deb5e2ac60c552c907c735

Contents?: true

Size: 682 Bytes

Versions: 10

Compression:

Stored size: 682 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(last_response.body).should == {"id" => "1", "format" => "json"}
  end

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rack-api-1.1.0 spec/rack-api/params_spec.rb
rack-api-1.0.2 spec/rack-api/params_spec.rb
rack-api-1.0.1 spec/rack-api/params_spec.rb
rack-api-1.0.0 spec/rack-api/params_spec.rb
rack-api-0.3.1 spec/rack-api/params_spec.rb
rack-api-0.3.0 spec/rack-api/params_spec.rb
rack-api-0.2.2 spec/rack-api/params_spec.rb
rack-api-0.2.1 spec/rack-api/params_spec.rb
rack-api-0.2.0 spec/rack-api/params_spec.rb
rack-api-0.1.2 spec/rack-api/params_spec.rb