Sha256: 796739ad0b764b865c4ecd3bec5b14a1063cf047e85455e30ec97887c92ad779

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

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

  context 'file' do
    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

  context 'urls' do
    it 'succeeds for example.com' do
      url =  'http://pac-host.example.com/proxy.pac'
      stub_request(:any, url).to_return(body: valid_proxy_pac)

      use_proxy :pac, url
      visit 'http://example.com'
      expect(proxy_pac).to return_proxy('PROXY localhost2:8080')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
proxy_tester-0.1.10 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.8 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.6 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.5 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.4 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.3 spec/matchers/returns_proxy_spec.rb
proxy_tester-0.1.2 spec/matchers/returns_proxy_spec.rb