Sha256: e3640e59adb61376f02d4a024085491eb1aacbdd4762a101f145d406b8d5b2e5

Contents?: true

Size: 1.65 KB

Versions: 92

Compression:

Stored size: 1.65 KB

Contents

#! /usr/bin/env ruby
require '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.expects(:withenv).once.with({:PKG_PATH => path}).yields
      @provider.expects(:pkgadd).once.with("mypackage")

      expect { @provider.install }.to_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.expects(:withenv).once.with({:PACKAGESITE => path}).yields
        @provider.expects(:pkgadd).once.with('-r', "mypackage")

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

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
puppet-3.8.7 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.6 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.5 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.4 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.3 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.2 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.1 spec/unit/provider/package/freebsd_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/provider/package/freebsd_spec.rb