# encoding: utf-8 require 'spec_helper' describe ProxyPac::PacResult do context '#initialize' do it 'requires a pac parser result' do ProxyPac::PacResult.new('"DIRECT"') end it 'handles a empty string' do expect { ProxyPac::PacResult.new('') }.not_to raise_error end end context '#verbatim_content' do it 'returns the verbatim content' do result = ProxyPac::PacResult.new('"DIRECT"') expect(result.verbatim_content).to eq('"DIRECT"') end end context '#proxy' do it 'extracts proxy-hostname from string' do result = ProxyPac::PacResult.new('"PROXY 127.0.0.1:8080"') expect(result.proxy).to eq('127.0.0.1') end it 'extracts proxy-hostname from short string' do result = ProxyPac::PacResult.new('"PROXY 127.0.0.1"') expect(result.proxy).to eq('127.0.0.1') end end context '#proxy_port' do it 'extracts proxy-port from string' do result = ProxyPac::PacResult.new('"PROXY 127.0.0.1:8080"') expect(result.proxy_port).to eq('8080') end end context '#request_type' do it 'extracts request type from string' do result = ProxyPac::PacResult.new('"PROXY 127.0.0.1:8080"') expect(result.request_type).to eq('PROXY') end it 'extracts request type from short string' do result = ProxyPac::PacResult.new('"DIRECT"') expect(result.request_type).to eq('DIRECT') end end end