File: mcx_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (75 lines) | stat: -rw-r--r-- 2,017 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require 'spec_helper'

require 'puppet/type/mcx'

mcx_type = Puppet::Type.type(:mcx)

describe mcx_type, "when validating attributes" do
  properties = [:ensure, :content]
  parameters = [:name, :ds_type, :ds_name]

  parameters.each do |p|
    it "should have a #{p} parameter" do
      expect(mcx_type.attrclass(p).ancestors).to be_include(Puppet::Parameter)
    end

    it "should have documentation for its #{p} parameter" do
      expect(mcx_type.attrclass(p).doc).to be_instance_of(String)
    end
  end

  properties.each do |p|
    it "should have a #{p} property" do
      expect(mcx_type.attrclass(p).ancestors).to be_include(Puppet::Property)
    end

    it "should have documentation for its #{p} property" do
      expect(mcx_type.attrclass(p).doc).to be_instance_of(String)
    end
  end

end

describe mcx_type, "default values" do
  before :each do
    provider_class = mcx_type.provider(mcx_type.providers[0])
    allow(mcx_type).to receive(:defaultprovider).and_return(provider_class)
  end

  it "should be nil for :ds_type" do
    expect(mcx_type.new(:name => '/Foo/bar')[:ds_type]).to be_nil
  end

  it "should be nil for :ds_name" do
    expect(mcx_type.new(:name => '/Foo/bar')[:ds_name]).to be_nil
  end

  it "should be nil for :content" do
    expect(mcx_type.new(:name => '/Foo/bar')[:content]).to be_nil
  end
end

describe mcx_type, "when validating properties" do
  before :each do
    provider_class = mcx_type.provider(mcx_type.providers[0])
    allow(mcx_type).to receive(:defaultprovider).and_return(provider_class)
  end

  it "should be able to create an instance" do
    expect {
      mcx_type.new(:name => '/Foo/bar')
    }.not_to raise_error
  end

  it "should support :present as a value to :ensure" do
    expect {
      mcx_type.new(:name => "/Foo/bar", :ensure => :present)
    }.not_to raise_error
  end

  it "should support :absent as a value to :ensure" do
    expect {
      mcx_type.new(:name => "/Foo/bar", :ensure => :absent)
    }.not_to raise_error
  end
end