Sha256: d4c7174dbbc50945567ed9704393c0c3b1bcaef19204d86fb6028c0f8d02de14

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

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

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

  context 'when is valid' do
    it { expect(proxy_pac).to be_valid }

    context 'although it makes URI to raise invalid url error' do
      subject do
        <<-EOS.strip_heredoc.chomp
        function FindProxyForURL(url, host) {
          // comment
          if ( dnsDomainIs ( host, "example.org") ) {
            return "PROXY 10.0.0.0:8080";
          }
        }
        EOS
      end

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

  context 'when is not valid' do
    context 'when is not readable' do
      subject { 'function Gargabe' }

      it { expect(proxy_pac).not_to be_valid }
    end

    context 'when contains gargabe' do
      subject do
        <<-EOS.strip_heredoc.chomp
        function FindProxyForURL(url, host) {
          return $ยง"% "DIRECT";
        }
        EOS
      end

      it { expect(proxy_pac).not_to be_valid }
    end

    context 'when undefined variable is referenced' do
      subject do
        <<-EOS.strip_heredoc.chomp
        function FindProxyForURL(url, host) {
          return asdf;
        }
        EOS
      end

      it { expect(proxy_pac).not_to be_valid }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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