Sha256: 89ddb3fc22014cd9b01dba25b92a7b978b92d328920582c49d038a370e2d00b0

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe ProxyPacParser do
  subject(:proxy_pac) { instance_double('ProxyPac::ProxyPacFile') }

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

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

  before :each do
    allow(proxy_pac).to receive(:content).and_return(content)
    allow(proxy_pac).to receive(:valid?).and_return(true)
    allow(proxy_pac).to receive(:source).and_return(source)
    allow(proxy_pac).to receive(:type?).with(:string).and_return(true)
  end

  describe '#parse' do
    context 'when is valid' do
      before(:each) do
        expect(proxy_pac).to receive(:javascript=)
        expect(proxy_pac).to receive(:parsable=).with(true)
      end

      before(:each) { ProxyPacParser.new.parse(proxy_pac) }
    end

    context 'when is invalid' do
      let(:content) do
        <<-EOS.strip_heredoc.chomp
          function FindProxyForURL(url, host) {
           asdfasf $$ SDF
          }
        EOS
      end

      before(:each) do
        expect(proxy_pac).to receive(:message=)
        expect(proxy_pac).to receive(:parsable=).with(false)
      end

      before(:each) { ProxyPacParser.new.parse(proxy_pac) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxy_pac_rb-2.1.0 spec/api/proxy_pac_parser_spec.rb
proxy_pac_rb-2.0.0 spec/api/proxy_pac_parser_spec.rb
proxy_pac_rb-1.0.0 spec/api/proxy_pac_parser_spec.rb