Sha256: 6e18bc82366fe4584bf8b97d5a88a54aa6d59e9bf0ee4900c86e90dc5ca0e61a

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

module ProxyPacRb
  module Rspec
    # Helpers for proxy.pac tests
    module Helpers
      def proxy_pac
        source = if subject.nil? || Addressable::URI.parse(subject).host || /FindProxyForURL/ === subject
                   subject
                 else
                   File.join(root_path, subject)
                 end

        file = ProxyPacRb::ProxyPacFile.new(source: source)

        _proxy_pac_loader.load(file)
        _proxy_pac_linter.lint(file)
        _proxy_pac_parser.parse(file)

        file
      end

      def time
        '1970-01-01 00:00:00'
      end

      def client_ip
        '127.0.0.1'
      end

      def root_path
        @root_path ||= Dir.getwd
      end

      private

      def _environment
        Environment.new(time: time, client_ip: client_ip)
      end

      def _proxy_pac_parser
        ProxyPacRb::ProxyPacParser.new(environment: _environment)
      end

      def _proxy_pac_loader
        ProxyPacRb::ProxyPacLoader.new
      end

      def _proxy_pac_linter
        ProxyPacRb::ProxyPacLinter.new
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
proxy_pac_rb-0.5.9 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.8 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.7 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.6 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.5 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.4 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.3 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.2 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.1 lib/proxy_pac_rb/rspec/helpers.rb
proxy_pac_rb-0.5.0 lib/proxy_pac_rb/rspec/helpers.rb