Sha256: 0c1d8d149b898ec22521c3fe22ba144d768ac4f99487fc4a8ea46e49a40d3281

Contents?: true

Size: 1.99 KB

Versions: 20

Compression:

Stored size: 1.99 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

provider_class = Puppet::Type.type(:package).provider(:puppet_gem)

describe provider_class do
  let(:resource) do
    Puppet::Type.type(:package).new(
      :name     => 'myresource',
      :ensure   => :installed
    )
  end

  let(:provider) do
    provider = provider_class.new
    provider.resource = resource
    provider
  end

  if Puppet::Util::Platform.windows?
    let(:puppet_gem) { 'gem' }
  else
    let(:puppet_gem) { '/opt/puppetlabs/puppet/bin/gem' }
  end

  before :each do
    resource.provider = provider
  end

  describe "when installing" do
    it "should use the path to the gem" do
      provider_class.expects(:which).with(puppet_gem).returns(puppet_gem)
      provider.expects(:execute).with { |args| args[0] == puppet_gem }.returns ''
      provider.install
    end

    it "should not append install_options by default" do
      provider.expects(:execute).with { |args| args.length == 5 }.returns ''
      provider.install
    end

    it "should allow setting an install_options parameter" do
      resource[:install_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
      provider.expects(:execute).with { |args| args[2] == '--force' && args[3] == '--bindir=/usr/bin' }.returns ''
      provider.install
    end
  end

  describe "when uninstalling" do
    it "should use the path to the gem" do
      provider_class.expects(:which).with(puppet_gem).returns(puppet_gem)
      provider.expects(:execute).with { |args| args[0] == puppet_gem }.returns ''
      provider.install
    end

    it "should not append uninstall_options by default" do
      provider.expects(:execute).with { |args| args.length == 5 }.returns ''
      provider.uninstall
    end

    it "should allow setting an uninstall_options parameter" do
      resource[:uninstall_options] = [ '--force', {'--bindir' => '/usr/bin' } ]
      provider.expects(:execute).with { |args| args[5] == '--force' && args[6] == '--bindir=/usr/bin' }.returns ''
      provider.uninstall
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-6.0.4 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.4-x86-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.4-x64-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.4-universal-darwin spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.3 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.3-x86-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.3-x64-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.3-universal-darwin spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.2 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.2-x86-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.2-x64-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.2-universal-darwin spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.1 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.1-x86-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.1-x64-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.1-universal-darwin spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.0 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.0-x86-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.0-x64-mingw32 spec/unit/provider/package/puppet_gem_spec.rb
puppet-6.0.0-universal-darwin spec/unit/provider/package/puppet_gem_spec.rb