summaryrefslogtreecommitdiff
path: root/puppet/modules/augeas/spec/classes/augeas_spec.rb
diff options
context:
space:
mode:
authorMicah <micah@leap.se>2016-05-24 10:19:32 -0400
committerMicah <micah@leap.se>2016-05-24 10:19:32 -0400
commit40cfe3ca5f29428b237627d167f2405ea9193dbb (patch)
tree39184f1c6f3917de887be3fe048f83c124f39ce8 /puppet/modules/augeas/spec/classes/augeas_spec.rb
parent2f6047b81d9cce2da82971197ee60d5bcc3010d9 (diff)
parent99500c162d8bd5ed017112e7568272ad08adff6c (diff)
Merge commit '99500c162d8bd5ed017112e7568272ad08adff6c' as 'puppet/modules/augeas'
Diffstat (limited to 'puppet/modules/augeas/spec/classes/augeas_spec.rb')
-rw-r--r--puppet/modules/augeas/spec/classes/augeas_spec.rb149
1 files changed, 149 insertions, 0 deletions
diff --git a/puppet/modules/augeas/spec/classes/augeas_spec.rb b/puppet/modules/augeas/spec/classes/augeas_spec.rb
new file mode 100644
index 00000000..ab4241f4
--- /dev/null
+++ b/puppet/modules/augeas/spec/classes/augeas_spec.rb
@@ -0,0 +1,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