Sha256: 41e738a6291e855cf9f916dd5176c47cbefd08c1b8d6b7656bfe6df11d247448

Contents?: true

Size: 1.25 KB

Versions: 68

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

require 'puppet/network/http'
require 'puppet/network/http/connection'

describe Puppet::Network::HTTP::NoCachePool do
  let(:site) { Puppet::Network::HTTP::Site.new('https', 'rubygems.org', 443) }
  let(:verifier) { double('verifier', :setup_connection => nil) }

  it 'yields a started connection' do
    http  = double('http', start: nil, finish: nil)

    factory = Puppet::Network::HTTP::Factory.new
    allow(factory).to receive(:create_connection).and_return(http)
    pool = Puppet::Network::HTTP::NoCachePool.new(factory)

    expect { |b|
      pool.with_connection(site, verifier, &b)
    }.to yield_with_args(http)
  end

  it 'yields a new connection each time' do
    http1  = double('http1', start: nil, finish: nil)
    http2  = double('http2', start: nil, finish: nil)

    factory = Puppet::Network::HTTP::Factory.new
    allow(factory).to receive(:create_connection).and_return(http1, http2)
    pool = Puppet::Network::HTTP::NoCachePool.new(factory)

    expect { |b|
      pool.with_connection(site, verifier, &b)
    }.to yield_with_args(http1)

    expect { |b|
      pool.with_connection(site, verifier, &b)
    }.to yield_with_args(http2)
  end

  it 'has a close method' do
    Puppet::Network::HTTP::NoCachePool.new.close
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
puppet-6.12.0 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.12.0-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.12.0-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.4.5 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.4.5-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.4.5-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.4.5-universal-darwin spec/unit/network/http/nocache_pool_spec.rb
puppet-6.12.0-universal-darwin spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.1 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.1-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.1-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.1-universal-darwin spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.0 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.0-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.0-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.11.0-universal-darwin spec/unit/network/http/nocache_pool_spec.rb
puppet-6.10.1 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.10.1-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.10.1-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.10.1-universal-darwin spec/unit/network/http/nocache_pool_spec.rb