Sha256: 20ef377617bf6bad558e3792da94c70c29072b9fa2a5c2a9dcc102a719a96ca4

Contents?: true

Size: 1.43 KB

Versions: 17

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

RSpec.describe ProxyPacLinter 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(:source).and_return(source)
    allow(proxy_pac).to receive(:content).and_return(content)
    allow(proxy_pac).to receive(:valid).and_return(true)
    allow(proxy_pac).to receive(:type?).with(:string).and_return(true)
  end

  describe '#lint' do
    let(:linter) {  ProxyPacLinter.new(silent: true) }
    let(:result) { true }

    before(:each) do
      expect(proxy_pac).to receive(:valid=).with(result)
      allow(proxy_pac).to receive(:message=)
    end

    context 'when is valid' do
      it { linter.lint(proxy_pac) }
    end

    context 'when is proxy.pac does not contain FindProxyForURL' do
      let(:result) { false }
      let(:content) { '' }
      it { linter.lint(proxy_pac) }
    end

    context 'when is proxy.pac cannot be compiled' do
      let(:result) { false }
      let(:content) do
        <<-EOS.strip_heredoc.chomp
          function FindProxyForURL(url, host) {
           asdfasf $$ SDF
          }
        EOS
      end

      it { linter.lint(proxy_pac) }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
proxy_pac_rb-0.6.5 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.6.4 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.6.3 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.6.2 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.6.1 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.6.0 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.10 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.9 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.8 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.7 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.6 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.5 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.4 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.3 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.2 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.1 spec/api/proxy_pac_linter_spec.rb
proxy_pac_rb-0.5.0 spec/api/proxy_pac_linter_spec.rb