File: freebsd_spec.rb

package info (click to toggle)
puppet 5.5.10-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,116 kB
  • sloc: ruby: 250,669; sh: 1,620; xml: 218; makefile: 151; sql: 103
file content (51 lines) | stat: -rw-r--r-- 1,620 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'spec_helper'

describe Puppet::Type.type(:package).provider(:freebsd) 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 = subject()
    @provider.resource = @resource
  end

  it "should have an install method" do
    @provider = subject()
    expect(@provider).to respond_to(:install)
  end

  context "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