Sha256: 094df29b906c533536b8d6023c23e1d479b78d6736558a99bd1a2d8305e1f433

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe 'Fetch proxy pac' do
  context '/v1/pac' do
    let(:valid_pac_file) do <<-EOS.strip_heredoc
                           function FindProxyForURL(url, host) {
                             return "DIRECT"
                           }
                           EOS
    end

    it 'finds an existing proxy pac' do
      create_file '.config/pacfiles/file1.pac', valid_pac_file

      env = {
        'HOME' => working_directory,
      }

      with_environment env, clear: true do
        response = get('/v1/pac/file1.pac')
        expect(response.body).to eq(valid_pac_file)
      end
    end

    it 'exits with 404 if file does not exist' do
      response = get('/v1/pac/does_not_exist.pac')
      expect(response.body).to include('does_not_exist.pac')
    end

    it 'compresses data for transit if requested' do
      ['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
        response = get('/v1/pac/does_not_exist.pac', {}, { 'HTTP_ACCEPT_ENCODING' => compression_method })
        expect(response.headers['Content-Encoding']).to be
      end
    end

    it 'does not compresses data for transit if not requested' do
      ['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
        response = get('/v1/pac/does_not_exist.pac')
        expect(response.headers['Content-Encoding']).not_to be
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
local_pac-0.0.7 spec/features/fetch_proxy_pac_spec.rb