Sha256: 4a2f4ca47e897d58e89b6c881fbc15d2068a05f2c2914cfff5069efb371c035d

Contents?: true

Size: 976 Bytes

Versions: 3

Compression:

Stored size: 976 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe File do
  let(:simple) do
    <<-EOS.strip_heredoc
      function FindProxyForURL(url, host) {
        return "DIRECT";
      }
    EOS
  end

  let(:client_ip_pac) do
    <<-EOS.strip_heredoc
      function FindProxyForURL(url, host) {
        if ( myIpAddress() == '127.0.0.2' ) {
          return "DIRECT";
        } else {
          return "PROXY localhost:8080";
        }
      }
    EOS
  end

  let(:time_pac) do
    <<-EOS.strip_heredoc
      function FindProxyForURL(url, host) {
        if ( timeRange(8, 18) ) {
          return "PROXY localhost:8080";
        } else {
          return "DIRECT";
        }
      }
    EOS
  end

  context '#find' do
    it 'returns result of proxy.pac' do
      javascript = double('javascript')
      expect(javascript).to receive(:call).with('FindProxyForURL', 'http://localhost', 'localhost')

      ProxyPacRb::File.new(javascript).find('http://localhost')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxy_pac_rb-0.3.8 spec/file_spec.rb
proxy_pac_rb-0.3.7 spec/file_spec.rb
proxy_pac_rb-0.3.6 spec/file_spec.rb