File: undef_spec.rb

package info (click to toggle)
ruby-rspec-puppet 2.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,416 kB
  • sloc: ruby: 6,661; makefile: 6
file content (91 lines) | stat: -rw-r--r-- 2,985 bytes parent folder | download | duplicates (2)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'spec_helper'

describe 'undef_test' do
  context "with required_attribute => 'some_string'" do
    context 'and defaults_to_undef unspecified' do
      let(:params) { { :required_attribute => 'some_string' } }

      it { should compile.with_all_deps }

      it { should contain_class('undef_test').with(:required_attribute => 'some_string') }

      it { should contain_class('undef_test').without_defaults_to_undef }

      it 'does not include undef parameters in the parameter count matcher' do
        res = catalogue.resource('Class', 'undef_test').to_hash.dup
        res.delete(:name)
        res.size.should eq(1)

        should contain_class('undef_test').only_with(
          :required_attribute => 'some_string',
          :defaults_to_undef  => nil
        )
      end
    end

    context 'and defaults_to_undef => :undef' do
      let(:params) { { :required_attribute => 'some_string', :defaults_to_undef => :undef } }

      it { should compile.with_all_deps }

      it { should contain_class('undef_test').with(:required_attribute => 'some_string') }

      it { should contain_class('undef_test').without_defaults_to_undef }

      it 'does not include undef parameters in the parameter count matcher' do
        res = catalogue.resource('Class', 'undef_test').to_hash.dup
        res.delete(:name)
        res.size.should eq(1)

        should contain_class('undef_test').only_with(
          :required_attribute => 'some_string',
          :defaults_to_undef  => nil
        )
      end
    end
  end

  context "with required_attribute => :undef", :unless => Puppet.version =~ /^2/ do
    context 'and defaults_to_undef unspecified' do
      let(:params) { { :required_attribute => :undef } }

      it { should compile.with_all_deps }

      it { should contain_class('undef_test').without_required_attribute }

      it { should contain_class('undef_test').without_defaults_to_undef }

      it 'does not include undef parameters in the parameter count matcher' do
        res = catalogue.resource('Class', 'undef_test').to_hash.dup
        res.delete(:name)
        res.size.should eq(0)

        should contain_class('undef_test').only_with(
          :required_attribute => nil,
          :defaults_to_undef  => nil
        )
      end
    end

    context 'and defaults_to_undef => :undef' do
      let(:params) { { :required_attribute => :undef, :defaults_to_undef => :undef } }

      it { should compile.with_all_deps }

      it { should contain_class('undef_test').without_required_attribute }

      it { should contain_class('undef_test').without_defaults_to_undef }

      it 'does not include undef parameters in the parameter count matcher' do
        res = catalogue.resource('Class', 'undef_test').to_hash.dup
        res.delete(:name)
        res.size.should eq(0)

        should contain_class('undef_test').only_with(
          :required_attribute => nil,
          :defaults_to_undef  => nil
        )
      end
    end
  end
end