Sha256: afc7aa3c1355b25a3182894dab0c89bd94dca23e4a6e6cd582b41f4e2747da46

Contents?: true

Size: 1.63 KB

Versions: 112

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'puppet/util/rubygems'

describe Puppet::Util::RubyGems::Source do
  let(:gem_path) { File.expand_path('/foo/gems') }
  let(:gem_lib) { File.join(gem_path, 'lib') }
  let(:fake_gem) { double(:full_gem_path => gem_path) }

  describe "::new" do
    it "returns NoGemsSource if rubygems is not present" do
      expect(described_class).to receive(:has_rubygems?).and_return(false)
      expect(described_class.new).to be_kind_of(Puppet::Util::RubyGems::NoGemsSource)
    end

    it "returns Gems18Source if Gem::Specification responds to latest_specs" do
      expect(described_class).to receive(:has_rubygems?).and_return(true)
      expect(described_class.new).to be_kind_of(Puppet::Util::RubyGems::Gems18Source)
    end
  end

  describe '::NoGemsSource' do
    before(:each) { allow(described_class).to receive(:source).and_return(Puppet::Util::RubyGems::NoGemsSource) }

    it "#directories returns an empty list" do
      expect(described_class.new.directories).to eq([])
    end

    it "#clear_paths returns nil" do
      expect(described_class.new.clear_paths).to be_nil
    end
  end

  describe '::Gems18Source' do
    before(:each) { allow(described_class).to receive(:source).and_return(Puppet::Util::RubyGems::Gems18Source) }

    it "#directories returns the lib subdirs of Gem::Specification.latest_specs" do
      expect(Gem::Specification).to receive(:latest_specs).with(true).and_return([fake_gem])

      expect(described_class.new.directories).to eq([gem_lib])
    end

    it "#clear_paths calls Gem.clear_paths" do
      expect(Gem).to receive(:clear_paths)
      described_class.new.clear_paths
    end
  end
end

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
puppet-6.19.1 spec/unit/util/rubygems_spec.rb
puppet-6.19.1-x86-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.19.1-x64-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.19.1-universal-darwin spec/unit/util/rubygems_spec.rb
puppet-6.19.0 spec/unit/util/rubygems_spec.rb
puppet-6.19.0-x86-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.19.0-x64-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.19.0-universal-darwin spec/unit/util/rubygems_spec.rb
puppet-6.18.0 spec/unit/util/rubygems_spec.rb
puppet-6.18.0-x86-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.18.0-x64-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.18.0-universal-darwin spec/unit/util/rubygems_spec.rb
puppet-6.17.0 spec/unit/util/rubygems_spec.rb
puppet-6.17.0-x86-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.17.0-x64-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.17.0-universal-darwin spec/unit/util/rubygems_spec.rb
puppet-6.16.0 spec/unit/util/rubygems_spec.rb
puppet-6.16.0-x86-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.16.0-x64-mingw32 spec/unit/util/rubygems_spec.rb
puppet-6.16.0-universal-darwin spec/unit/util/rubygems_spec.rb