Sha256: 7ac325be594b5b2929743e974e8b226b0740098783bbe84b2301770e70e775b6

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true
require 'spec_helper'
require 'proxy_pac_rb/rspec'

RSpec.describe 'Compare to proxy.pac-files', type: :proxy_pac do
  subject do
    <<-EOS.strip_heredoc.chomp
      function FindProxyForURL(url, host) {
        return "DIRECT";
      }
    EOS
  end

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

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

  context 'when expected is a ProxyPacFile' do
    it { expect(proxy_pac).to be_the_same_proxy_pac_file file_b }
  end

  context 'when actual a ProxyPacFile and' do
    it { expect(file_b).to be_the_same_proxy_pac_file proxy_pac }
  end

  context 'when both are ProxyPacFile' do
    let(:already_proxy_pac) { ProxyPacFile.new(source: file_b) }

    before :each do
      loader = ProxyPacRb::ProxyPacLoader.new
      loader.load(already_proxy_pac)
    end

    it { expect(already_proxy_pac).to be_the_same_proxy_pac_file proxy_pac }
  end

  context 'when file "a" and file "b" are strings' do
    context 'when both are eqal' do
      it { expect(file_a).to be_the_same_proxy_pac_file file_b }
    end

    context 'when both are not eqal' do
      let(:file_a) do
        <<-EOS.strip_heredoc.chomp
        function FindProxyForURL(url, host) {
          return "DIRECT";
        }
        EOS
      end

      let(:file_b) do
        <<-EOS.strip_heredoc.chomp
        function FindProxyForURL(url, host) {
          return "PROXY localhost:8080";
        }
        EOS
      end

      it { expect(file_a).not_to be_the_same_proxy_pac_file file_b }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxy_pac_rb-2.1.0 spec/rspec/compare_proxy_pac_files_spec.rb
proxy_pac_rb-2.0.0 spec/rspec/compare_proxy_pac_files_spec.rb
proxy_pac_rb-1.0.0 spec/rspec/compare_proxy_pac_files_spec.rb