Sha256: a6423aef30c05575c2431a9e6041c5d8a2b553f49289cf3529d43cdc6067365e

Contents?: true

Size: 1.52 KB

Versions: 18

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

RSpec.describe ProxyPacDumper 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(:source).and_return(source)
  end

  let(:dumper) { ProxyPacDumper.new }
  let(:destination) { absolute_path('proxy.pac') }

  describe '#dump' do
    before :each do
      allow(proxy_pac).to receive(:source).and_return(source)
    end

    context 'when proxy pac is string' do
      before :each do
        in_current_directory do
          dumper.dump(proxy_pac, type: :string)
        end
      end

      it { expect(destination).to be_existing_file }
      it { expect(destination).to have_content proxy_pac.content }
    end

    context 'when proxy pac is file' do
      let(:source) { 'proxy.pac.in' }

      before :each do
        write_file(source, content)
      end

      before :each do
        in_current_directory do
          dumper.dump(proxy_pac, type: :template)
        end
      end

      around :example do |example|
        in_current_directory { example.call }
      end

      it { expect(destination).to be_existing_file }
      it { expect(destination).to have_content proxy_pac.content }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
proxy_pac_rb-0.6.9 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.8 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.7 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.5 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.4 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.3 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.2 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.1 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.6.0 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.10 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.9 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.8 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.7 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.6 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.5 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.4 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.3 spec/api/proxy_pac_dumper_spec.rb
proxy_pac_rb-0.5.2 spec/api/proxy_pac_dumper_spec.rb