Sha256: 132dfe8dc6867ee483177d91251c73a846db022f007120a7c0c35757a3859f58

Contents?: true

Size: 604 Bytes

Versions: 9

Compression:

Stored size: 604 Bytes

Contents

require "spec_helper"

describe Rack::API, "Headers" do
   before do
    Rack::API.app do
      version :v1 do
        get("/users(.:format)") do
          headers["X-Awesome"] = "U R Awesome"
          headers["Content-Type"] = "application/x-json" # the default json header is application/json
        end
      end
    end
  end

  it "sends custom headers" do
    get "/v1/users"
    last_response.headers["X-Awesome"].should == "U R Awesome"
  end

  it "overrides inferred content type" do
    get "/v1/users.json"
    last_response.headers["Content-Type"].should == "application/x-json"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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