Sha256: 4b473bac2cb3315df8c45fba87e519b765e8a3a07a6f2900ddd725db5b01af2b

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require "spec_helper"

describe Rack::API, "separators" do
   before do
    Rack::API.app do
      get("/no-dots/:name(.:format)") { params }
      get("/dots/:name", :separator => %w[/?]) { params }
    end
  end

  context "/no-dots/:name" do
    it "stops on /" do
      get "/no-dots/foo/"
      last_response.body.should == {:name => "foo"}.to_json
    end

    it "stops on ?" do
      get "/no-dots/foo?a=1"
      last_response.body.should == {:a => "1", :name => "foo"}.to_json
    end

    it "stops on ." do
      get "/no-dots/foo.json"
      last_response.body.should == {:name => "foo", :format => "json"}.to_json
    end
  end

  context "/dots/:name" do
    it "stops on /" do
      get "/dots/foo/"
      last_response.body.should == {:name => "foo"}.to_json
    end

    it "stops on ?" do
      get "/dots/foo?a=1"
      last_response.body.should == {:a => "1", :name => "foo"}.to_json
    end

    it "stops on ." do
      get "/dots/foo.json"
      last_response.body.should == {:name => "foo.json"}.to_json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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