Sha256: 858ea3043e402ebf4e6dc08ca2c5fc42782d0bbd5ebe5a38d60b7517fc1239c5

Contents?: true

Size: 1.71 KB

Versions: 14

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../../spec_helper'

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

describe provider_class do
  before :each do
    # Create a mock resource
    @resource = stub 'resource'

    # A catch all; no parameters set
    @resource.stubs(:[]).returns(nil)

    # But set name and source
    @resource.stubs(:[]).with(:name).returns   "mypackage"
    @resource.stubs(:[]).with(:ensure).returns :installed

    @provider = provider_class.new
    @provider.resource = @resource
  end

  it "should have an install method" do
    @provider = provider_class.new
    @provider.should respond_to(:install)
  end

  describe "when installing" do
    before :each do
      @resource.stubs(:should).with(:ensure).returns(:installed)
    end

    it "should install a package from a path to a directory" do
      # For better or worse, trailing '/' is needed. --daniel 2011-01-26
      path = '/path/to/directory/'
      @resource.stubs(:[]).with(:source).returns(path)
      Puppet::Util::Execution.expects(:withenv).once.with({:PKG_PATH => path}).yields
      @provider.expects(:pkgadd).once.with("mypackage")

      expect { @provider.install }.should_not raise_error
    end

    %w{http https ftp}.each do |protocol|
      it "should install a package via #{protocol}" do
        # For better or worse, trailing '/' is needed. --daniel 2011-01-26
        path = "#{protocol}://localhost/"
        @resource.stubs(:[]).with(:source).returns(path)
        Puppet::Util::Execution.expects(:withenv).once.with({:PACKAGESITE => path}).yields
        @provider.expects(:pkgadd).once.with('-r', "mypackage")

        expect { @provider.install }.should_not raise_error
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.17 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.16 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.15 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.14 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.13 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.12 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.11 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.10 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.9 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.8 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.7 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.6 spec/unit/provider/package/freebsd_spec.rb
puppet-2.6.5 spec/unit/provider/package/freebsd_spec.rb