Sha256: 28ff1a516ea4d455dc773b8b401bbfe002d97af4336349d4ea9748239540722e

Contents?: true

Size: 1005 Bytes

Versions: 2

Compression:

Stored size: 1005 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe 'returns proxy matcher' do
  let(:valid_proxy_pac) {
    <<-EOS.strip_heredoc
      function FindProxyForURL(url, host) {
        if (url == "http://example.com") {
          return "PROXY localhost2:8080";
        } else {
          return "DIRECT";
        }
      }
    EOS
  }

  before :each do
    set_offline true
  end

  it 'checks return proxy string' do
    file = create_file 'proxy.pac', valid_proxy_pac
    use_proxy :pac, file

    visit 'http://example.com'
    expect(proxy_pac).to return_proxy('PROXY localhost2:8080')

    visit 'http://otherdomain.com'
    expect(proxy_pac).to return_proxy('DIRECT')
  end

  it 'checks that a proxy string is not returned' do
    file = create_file 'proxy.pac', valid_proxy_pac
    use_proxy :pac, file

    visit 'http://example.com'
    expect(proxy_pac).not_to return_proxy('DIRECT')

    visit 'http://otherdomain.com'
    expect(proxy_pac).not_to return_proxy('PROXY localhost2:8080')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxy_tester-0.1.1 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.0 spec/matchers/returns_proxy_spec.rb