Sha256: d613fc73a44979d5fc8f6e39f088054fde7db340835dc88a704fcf496bf67038

Contents?: true

Size: 984 Bytes

Versions: 5

Compression:

Stored size: 984 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe ProxyPac::PACEngine do
  let(:valid_pac_file) do <<-EOS.strip_heredoc
                           function FindProxyForURL(url, host) {
                             return "DIRECT"
                           }
  EOS
  end

  context '#find' do
    it 'returns a result' do
      file = double('PacFile')
      expect(file).to receive(:content).and_return(valid_pac_file)

      parser = ProxyPac::PACEngine.new(file: file)
      result = parser.find(Addressable::URI.parse('http://example.org'))
      expect(result).to eq('DIRECT')
    end

    it 'raises an error if pac file is invalid' do
      file = double('PacFile')
      allow(file).to receive(:content).and_return('asdfasdf()')

      parser = ProxyPac::PACEngine.new(file: file)

      expect do
        silence(:stderr) do
          parser.find(Addressable::URI.parse('http://example.org'))
        end
      end.to raise_error Exceptions::PacFileInvalid
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
local_pac-0.6.3 spec/proxy_pac/pac_engine_spec.rb
local_pac-0.6.2 spec/proxy_pac/pac_engine_spec.rb
local_pac-0.6.1 spec/proxy_pac/pac_engine_spec.rb
local_pac-0.5.0 spec/proxy_pac/pac_engine_spec.rb
local_pac-0.4.0 spec/proxy_pac/pac_engine_spec.rb