Sha256: 42e18c24899d0055f84291572695ccfbf7e293b1d9e6063202ae972697c2c1ae
Contents?: true
Size: 1.86 KB
Versions: 5
Compression:
Stored size: 1.86 KB
Contents
require 'spec_helper' describe 'Fetch proxy pac' do context '/v1/pac' do let(:valid_pac_file) do <<-EOS.strip_heredoc.chomp function FindProxyForURL(url, host) { return "DIRECT"; } EOS end let(:compressed_valid_pac_file) { "function FindProxyForURL(){return\"DIRECT\"}" } let(:git_repo) { 'git_repo' } before(:each) do git_init(git_repo) create_file(File.join(git_repo, 'file.pac'), valid_pac_file) git_add(git_repo, 'file.pac') git_commit(git_repo) end def app config = Class.new do include FeduxOrg::Stdlib::Filesystem def root_directory File.expand_path('../../../', __FILE__) end def local_storage File.join(working_directory, 'git_repo', '.git') end end.new LocalPac.config(config) LocalPac::FileServer end it 'finds an existing proxy pac' do response = get('/v1/pac/file.pac') expect(response.body).to eq(compressed_valid_pac_file) 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/file.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
5 entries across 5 versions & 1 rubygems