summaryrefslogtreecommitdiff
path: root/spec/classes/augeas_spec.rb
blob: ab4241f4928c19bf81370b32da560f10d25571fb (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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require 'spec_helper'

describe 'augeas' do

  context 'when on an unsupported Operating System' do
    let (:facts) do
      {
        :osfamily => 'MS-DOS',
      }
    end

    it 'should fail' do
      expect { is_expected.to contain_package('ruby-augeas') }.to raise_error(Puppet::Error, /Unsupported OS family/)
    end
  end

  on_supported_os.each do |os, facts|
    context "on #{os}" do
      let(:facts) do
        facts
      end

      context 'without params' do
        case facts[:osfamily]
        when 'Debian'
          it { is_expected.to contain_package('libaugeas0').with(
            :ensure => 'present'
          ) }
          it { is_expected.to contain_package('augeas-tools').with(
            :ensure => 'present'
          ) }
          it { is_expected.to contain_package('augeas-lenses').with(
            :ensure => 'present'
          ) }
          case facts[:lsbdistcodename]
          when 'squeeze', 'lucid', 'precise'
            it { is_expected.to contain_package('ruby-augeas').with(
              :ensure => 'present',
              :name   => 'libaugeas-ruby1.8'
            ) }
          else
            it { is_expected.to contain_package('ruby-augeas').with(
              :ensure => 'present',
              :name   => 'libaugeas-ruby1.9.1'
            ) }
          end
        when 'RedHat'
          it { is_expected.to contain_package('augeas').with(
            :ensure => 'present'
          ) }
          it { is_expected.to contain_package('augeas-libs').with(
            :ensure => 'present'
          ) }
          it { is_expected.to contain_package('ruby-augeas').with(
            :ensure => 'present',
            :name   => 'ruby-augeas'
          ) }
        end
        it { is_expected.to contain_file('/usr/share/augeas/lenses').with(
          :ensure       => 'directory',
          :purge        => 'true',
          :force        => 'true',
          :recurse      => 'true',
          :recurselimit => 1
        ) }
        it { is_expected.to contain_file('/usr/share/augeas/lenses/dist').with(
          :ensure       => 'directory',
          :purge        => 'false'
        ) }
        it { is_expected.to contain_file('/usr/share/augeas/lenses/tests').with(
          :ensure       => 'directory',
          :purge        => 'true',
          :force        => 'true'
        ).without(:recurse) }
      end

      context 'when versions are specified' do
        let (:params) do
          {
            :version      => '1.2.3',
            :ruby_version => '3.2.1',
          }
        end

        case facts[:osfamily]
        when 'Debian'
          it { is_expected.to contain_package('libaugeas0').with(
            :ensure => '1.2.3'
          ) }
          it { is_expected.to contain_package('augeas-tools').with(
            :ensure => '1.2.3'
          ) }
          it { is_expected.to contain_package('augeas-lenses').with(
            :ensure => '1.2.3'
          ) }
          case facts[:lsbdistcodename]
          when 'squeeze', 'lucid', 'precise'
            it { is_expected.to contain_package('ruby-augeas').with(
              :ensure => '3.2.1',
              :name   => 'libaugeas-ruby1.8'
            ) }
          else
            it { is_expected.to contain_package('ruby-augeas').with(
              :ensure => '3.2.1',
              :name   => 'libaugeas-ruby1.9.1'
            ) }
          end
        when 'RedHat'
          it { is_expected.to contain_package('augeas').with(
            :ensure => '1.2.3'
          ) }
          it { is_expected.to contain_package('augeas-libs').with(
            :ensure => '1.2.3'
          ) }
          it { is_expected.to contain_package('ruby-augeas').with(
            :ensure => '3.2.1',
            :name   => 'ruby-augeas'
          ) }
        end

      end

      context 'with a non standard lens_dir' do
        let (:params) do
          {
            :lens_dir => '/opt/augeas/lenses',
          }
        end

        it { is_expected.to contain_file('/opt/augeas/lenses').with(
          :ensure       => 'directory',
          :purge        => 'true',
          :force        => 'true',
          :recurse      => 'true',
          :recurselimit => 1
        ) }
        it { is_expected.to contain_file('/opt/augeas/lenses/dist').with(
          :ensure       => 'directory',
          :purge        => 'false'
        ) }
        it { is_expected.to contain_file('/opt/augeas/lenses/tests').with(
          :ensure       => 'directory',
          :purge        => 'true',
          :force        => 'true'
        ).without(:recurse) }
      end
    end
  end
end