Sha256: ccc4626588ce85d3249c19f9e64f5976126beadbf8f5ebe9e891bd78c8c75dae

Contents?: true

Size: 1.1 KB

Versions: 18

Compression:

Stored size: 1.1 KB

Contents

require 'rack/content_type'

describe Rack::ContentType do
  should "set Content-Type to default text/html if none is set" do
    app = lambda { |env| [200, {}, "Hello, World!"] }
    headers = Rack::ContentType.new(app).call({})[1]
    headers['Content-Type'].should.equal 'text/html'
  end

  should "set Content-Type to chosen default if none is set" do
    app = lambda { |env| [200, {}, "Hello, World!"] }
    headers =
      Rack::ContentType.new(app, 'application/octet-stream').call({})[1]
    headers['Content-Type'].should.equal 'application/octet-stream'
  end

  should "not change Content-Type if it is already set" do
    app = lambda { |env| [200, {'Content-Type' => 'foo/bar'}, "Hello, World!"] }
    headers = Rack::ContentType.new(app).call({})[1]
    headers['Content-Type'].should.equal 'foo/bar'
  end

  should "detect Content-Type case insensitive" do
    app = lambda { |env| [200, {'CONTENT-Type' => 'foo/bar'}, "Hello, World!"] }
    headers = Rack::ContentType.new(app).call({})[1]
    headers.to_a.select { |k,v| k.downcase == "content-type" }.
      should.equal [["CONTENT-Type","foo/bar"]]
  end
end

Version data entries

18 entries across 16 versions & 4 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/gems/rack-1.3.5/test/spec_content_type.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/rack-1.3.5/test/spec_content_type.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/rack-1.3.5/test/spec_content_type.rb
rack-1.3.10 test/spec_content_type.rb
rack-1.3.9 test/spec_content_type.rb
rack-1.3.8 test/spec_content_type.rb
rack-1.3.7 test/spec_content_type.rb
rack-1.3.6 test/spec_content_type.rb
rack-1.3.5 test/spec_content_type.rb
rack-1.3.4 test/spec_content_type.rb
rack-1.3.3 test/spec_content_type.rb
rack-1.3.2 test/spec_content_type.rb
rack-1.3.1 test/spec_content_type.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/rack-1.3.0/test/spec_content_type.rb
rack-1.3.0 test/spec_content_type.rb
rack-1.3.0.beta2 test/spec_content_type.rb
rack-1.3.0.beta test/spec_content_type.rb
edgar-rack-1.2.1 test/spec_content_type.rb