Sha256: fef9696936e43cc28a711eaf7e2776d123cf63debd04f2ac3ada12a5c705edaf

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

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

RSpec.describe 'Readability', type: [:proxy_pac, :aruba] do
  let(:content) do
    <<-EOS.strip_heredoc.chomp
      function FindProxyForURL(url, host) {
        return "DIRECT";
      }
    EOS
  end

  context 'when is file' do
    let(:root_path) { expand_path('.') }

    subject { 'proxy.pac' }

    context 'when proxy pac exist' do
      before :each do
        write_file 'proxy.pac', content
      end

      it { expect(proxy_pac).to be_readable }
    end

    context 'when proxy pac does not exist' do
      it { expect(proxy_pac).not_to be_readable }
    end
  end

  context 'when is url' do
    subject { 'http://www.example.com/proxy.pac' }

    context 'when is readable' do
      before(:each) { stub_request(:get, subject).to_return(body: content, status: 200) }
      it { expect(proxy_pac).to be_readable }
    end
    context 'when is not readable' do
      before(:each) { stub_request(:get, subject).to_raise(StandardError) }
      it { expect(proxy_pac).not_to be_readable }
    end
  end

  context 'when is string' do
    context 'it is always readable' do
      subject do
        <<-EOS.strip_heredoc.chomp
        function FindProxyForURL(url, host) {
          return "DIRECT";
        }
        EOS
      end

      it { expect(proxy_pac).to be_readable }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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