Sha256: 25f09f44d4512a2e67f0357a7d263588263d4cab25f9f2992143f572fe8d320f

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

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

describe Puppet::Type.type(:package).provider(:aptrpm) do
  let :type do Puppet::Type.type(:package) end
  let :pkg do
    type.new(:name => 'faff', :provider => :aptrpm, :source => '/tmp/faff.rpm')
  end

  it { should be_versionable }

  context "when retrieving ensure" do
    def rpm
      pkg.provider.expects(:rpm).
        with('-q', 'faff', '--nosignature', '--nodigest', '--qf',
             "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n")
    end

    it "should report absent packages" do
      rpm.raises(Puppet::ExecutionFailure, "couldn't find rpm")
      pkg.property(:ensure).retrieve.should == :absent
    end

    it "should report present packages correctly" do
      rpm.returns("faff-1.2.3-1 0 1.2.3-1 5 i686\n")
      pkg.property(:ensure).retrieve.should == "1.2.3-1-5"
    end
  end

  it "should try and install when asked" do
    pkg.provider.expects(:aptget). with('-q', '-y', 'install', 'faff'). returns(0)
    pkg.provider.install
  end

  it "should try and purge when asked" do
    pkg.provider.expects(:aptget).with('-y', '-q', 'remove', '--purge', 'faff').returns(0)
    pkg.provider.purge
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/provider/package/aptrpm_spec.rb
puppet-3.1.1 spec/unit/provider/package/aptrpm_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/provider/package/aptrpm_spec.rb
puppet-3.1.0 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.1.0.rc2 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.1.0.rc1 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.2 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.2.rc3 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.2.rc2 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.2.rc1 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.1 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.1.rc1 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.0.0 spec/unit/provider/package/aptrpm_spec.rb