Sha256: 8a68078c74b4c9e34f0c568ec4167b5ae8d6f68d50f2a801e6f56778fd1d0853

Contents?: true

Size: 1.18 KB

Versions: 35

Compression:

Stored size: 1.18 KB

Contents

require 'rack/mock'
require 'rack/content_type'

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

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

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

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

Version data entries

35 entries across 34 versions & 12 rubygems

Version Path
kjvarga-rack-1.0.0 test/spec_rack_content_type.rb
qoobaa-rack-1.0.0.1 test/spec_rack_content_type.rb
qoobaa-rack-1.0.2 test/spec_rack_content_type.rb
timocratic-rack-1.0.0 test/spec_rack_content_type.rb
rack-1.1.6 test/spec_rack_content_type.rb
rack-1.1.5 test/spec_rack_content_type.rb
rack-1.1.4 test/spec_rack_content_type.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rack-1.1.3/test/spec_rack_content_type.rb
rack-1.1.3 test/spec_rack_content_type.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rack-1.1.2/test/spec_rack_content_type.rb
rack-1.1.2 test/spec_rack_content_type.rb
rack-1.1.1 test/spec_rack_content_type.rb
rack-1.1.1.pre test/spec_rack_content_type.rb
eac-rack-1.1.1 test/spec_rack_content_type.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_content_type.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_content_type.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/rack-1.1.0/test/spec_rack_content_type.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_content_type.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_content_type.rb
rack-1.1.0 test/spec_rack_content_type.rb