Sha256: 16b7d2ea02f9688e306c282770d3eab6d78d4a37bd56d93a85b70f6144844514

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'net/http'
require 'puppet/forge/repository'
require 'puppet/forge/cache'

describe Puppet::Forge::Repository do
  describe 'instances' do

    let(:repository) { Puppet::Forge::Repository.new('http://fake.com') }

    describe '#retrieve' do
      before do
        @uri = URI.parse('http://some.url.com')
      end

      it "should access the cache" do
        repository.cache.expects(:retrieve).with(@uri)
        repository.retrieve(@uri)
      end
    end

    describe 'http_proxy support' do
      before :each do
        ENV["http_proxy"] = nil
      end

      after :each do
        ENV["http_proxy"] = nil
      end

      it "should support environment variable for port and host" do
        ENV["http_proxy"] = "http://test.com:8011"
        repository.http_proxy_host.should == "test.com"
        repository.http_proxy_port.should == 8011
      end

      it "should support puppet configuration for port and host" do
        ENV["http_proxy"] = nil
        Puppet.settings.stubs(:[]).with(:http_proxy_host).returns('test.com')
        Puppet.settings.stubs(:[]).with(:http_proxy_port).returns(7456)

        repository.http_proxy_port.should == 7456
        repository.http_proxy_host.should == "test.com"
      end

      it "should use environment variable before puppet settings" do
        ENV["http_proxy"] = "http://test1.com:8011"
        Puppet.settings.stubs(:[]).with(:http_proxy_host).returns('test2.com')
        Puppet.settings.stubs(:[]).with(:http_proxy_port).returns(7456)

        repository.http_proxy_host.should == "test1.com"
        repository.http_proxy_port.should == 8011
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
puppet-2.7.26 spec/unit/forge/repository_spec.rb
puppet-2.7.25 spec/unit/forge/repository_spec.rb
puppet-2.7.24 spec/unit/forge/repository_spec.rb
puppet-2.7.23 spec/unit/forge/repository_spec.rb
puppet-2.7.22 spec/unit/forge/repository_spec.rb
puppet-2.7.21 spec/unit/forge/repository_spec.rb
puppet-2.7.20 spec/unit/forge/repository_spec.rb
puppet-2.7.20.rc1 spec/unit/forge/repository_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/forge/repository_spec.rb
puppet-2.7.19 spec/unit/forge/repository_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/forge/repository_spec.rb
puppet-2.7.18 spec/unit/forge/repository_spec.rb
puppet-2.7.17 spec/unit/forge/repository_spec.rb
puppet-2.7.16 spec/unit/forge/repository_spec.rb
puppet-2.7.14 spec/unit/forge/repository_spec.rb