Sha256: 74caed1c5f4ccda8073c5b51cbdfe304ed6825cefa8e5c52419f6b6df335bd4a

Contents?: true

Size: 1.49 KB

Versions: 20

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'proxy_pac_rb/rack/proxy_pac_compressor'
require 'rack/lint'

RSpec.describe ProxyPacRb::Rack::ProxyPacCompressor, type: :rack_test do
  let(:compressed_content) { %(function FindProxyForURL() {\n    return \"DIRECT\";\n}) }

  before(:each) { get '/' }
  subject(:body) { last_response.body }

  context 'when valid proxy pac is given' do
    let(:app) do
      a = Class.new(Sinatra::Base) do
        before do
          content_type 'application/x-ns-proxy-autoconfig'
        end

        get '/' do
          <<-EOS.strip_heredoc.chomp
          // comment
          function FindProxyForURL(url, host) {
            return "DIRECT";
          }
          EOS
        end
      end

      a.use Rack::Lint
      a.use ProxyPacRb::Rack::ProxyPacCompressor
      a.use Rack::Lint

      a.new
    end

    it { expect(body).to eq compressed_content }
  end

  context 'when invalid proxy pac is given' do
    let(:compressed_content) { %{Unexpected token: string (§$ )} }

    let(:app) do
      a = Class.new(Sinatra::Base) do
        before do
          content_type 'application/x-ns-proxy-autoconfig'
        end

        get '/' do
          <<-EOS.strip_heredoc.chomp
          function FindProxyForURL(url, host) {
            return $"§$ "DIRECT";
          }
          EOS
        end
      end

      a.use Rack::Lint
      a.use ProxyPacRb::Rack::ProxyPacCompressor
      a.use Rack::Lint

      a.new
    end

    it { expect(body).to include compressed_content }
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
proxy_pac_rb-0.8.2 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.8.1 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.8.0 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.7.0 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.9 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.8 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.7 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.5 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.4 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.3 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.2 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.1 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.6.0 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.10 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.9 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.8 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.7 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.6 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.5 spec/rack/proxy_pac_compressor_spec.rb
proxy_pac_rb-0.5.4 spec/rack/proxy_pac_compressor_spec.rb