# encoding: utf-8 require 'spec_helper' describe ProxyPac::PacParser do context '#initialize' do it 'fails if file is missing' do engine = double('pac_engine') expect { ProxyPac::PacParser.new(engine: engine) }.to raise_error ArgumentError end end context '#find' do it 'finds a proxy for url' do engine = double('pac_engine') expect(engine).to receive(:find).and_return('DIRECT') file = double('PacFile') stylist = double('Stylist') allow(stylist).to receive(:style_me) result_generator = double('PacResult') allow(result_generator).to receive(:new).and_return { result_generator } parser = ProxyPac::PacParser.new(file: file, engine: engine, result_generator: result_generator, stylist: stylist) result = parser.find('http://example.org') end end end