summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider/package/nim_spec.rb
blob: 2018f650623596ed5c93ce47710d39940888bdd9 (plain)
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
#!/usr/bin/env ruby

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

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

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(:source).returns "mysource"
        @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
        it "should install a package" do
            @resource.stubs(:should).with(:ensure).returns(:installed)
            @provider.expects(:nimclient).with("-o", "cust", "-a", "installp_flags=acgwXY", "-a", "lpp_source=mysource", "-a", "filesets='mypackage'")
            @provider.install
        end

        it "should install a versioned package" do
            @resource.stubs(:should).with(:ensure).returns("1.2.3.4")
            @provider.expects(:nimclient).with("-o", "cust", "-a", "installp_flags=acgwXY", "-a", "lpp_source=mysource", "-a", "filesets='mypackage 1.2.3.4'")
            @provider.install
        end
    end
 end