Sha256: 1b19c596394ec77d4592ed71aff93e85aab8c494ee8412e85855756c887ef134

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe CapybaraProxyPac do
  let(:valid_pac_file1) do <<-EOS.strip_heredoc.chomp
                           function FindProxyForURL(url, host) {
                             return "PROXY localhost:3128";
                           }
  EOS
  end

  context 'all' do
    it 'handles exceptions for file not found' do
      pac = CapybaraProxyPac.new
      expect { pac.pac_file = 'asdf' }.to raise_error Exceptions::PacFileNotFound
    end
  end

  context '#host' do
    it 'returns host for url' do
      file = create_file 'proxy.pac', valid_pac_file1

      pac = CapybaraProxyPac.new
      pac.pac_file = file
      pac.url = 'http://www.heise.de'

      expect(pac.host).to eq('localhost')
    end
  end

  context '#port' do
    it 'returns port for url' do
      file = create_file 'proxy.pac', valid_pac_file1

      pac = CapybaraProxyPac.new
      pac.pac_file = file
      pac.url = 'http://www.heise.de'

      expect(pac.port).to eq('3128')
    end
  end

  context '#verbatim' do
    it 'verbatim output' do
      file = create_file 'proxy.pac', valid_pac_file1

      pac = CapybaraProxyPac.new
      pac.pac_file = file
      pac.url = 'http://www.heise.de'

      expect(pac.verbatim).to eq('PROXY localhost:3128')
    end

    it 'handles not set file' do
      pac = CapybaraProxyPac.new
      expect { pac.verbatim }.not_to raise_error
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxy_tester-0.1.1 spec/capybara_proxy_pac_spec.rb
proxy_tester-0.1.0 spec/capybara_proxy_pac_spec.rb