Sha256: 1aedd7073cd3c9a3d2fe078b9901f521214c285e123cd65e012ba6de2ec65214

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

require 'spec_helper'
require 'goliath/env'
require 'goliath/rack/default_mime_type'

describe Goliath::Rack::DefaultMimeType do
  let(:app) { double('app').as_null_object }
  let(:dmt) { Goliath::Rack::DefaultMimeType.new(app) }
  let(:env) do
    env = Goliath::Env.new
    env['status'] = double('status').as_null_object
    env
  end

  context 'accept header cleanup' do
    it 'handles a nil header' do
      env['HTTP_ACCEPT'] = nil
      lambda { dmt.call(env) }.should_not raise_error
    end

    %w(gzip deflate compressed identity).each do |type|
      it "removes #{type} from the accept header" do
        env['HTTP_ACCEPT'] = "text/html, #{type}, text/javascript"
        dmt.call(env)
        env['HTTP_ACCEPT'].should == 'text/html, text/javascript'
      end
    end

    it 'sets to */* if all entries removed' do
      env['HTTP_ACCEPT'] = 'identity'
      dmt.call(env)
      env['HTTP_ACCEPT'].should == '*/*'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
goliath-1.0.5 spec/unit/rack/default_mime_type_spec.rb
goliath-1.0.4 spec/unit/rack/default_mime_type_spec.rb