summaryrefslogtreecommitdiff
path: root/puppet/modules/augeas/spec/defines
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2016-11-04 10:54:28 -0400
committerMicah Anderson <micah@riseup.net>2016-11-04 10:54:28 -0400
commit34a381efa8f6295080c843f86bfa07d4e41056af (patch)
tree9282cf5d4c876688602705a7fa0002bc4a810bde /puppet/modules/augeas/spec/defines
parent0a72bc6fd292bf9367b314fcb0347c4d35042f16 (diff)
parent5821964ff7e16ca7aa9141bd09a77d355db492a9 (diff)
Merge branch 'develop'
Diffstat (limited to 'puppet/modules/augeas/spec/defines')
m---------puppet/modules/augeas0
-rw-r--r--puppet/modules/augeas/spec/defines/augeas_lens_spec.rb112
2 files changed, 112 insertions, 0 deletions
diff --git a/puppet/modules/augeas b/puppet/modules/augeas
deleted file mode 160000
-Subproject 58ab2b90c52a5d951fa41596827bc3b6f52310e
diff --git a/puppet/modules/augeas/spec/defines/augeas_lens_spec.rb b/puppet/modules/augeas/spec/defines/augeas_lens_spec.rb
new file mode 100644
index 00000000..7feeefbd
--- /dev/null
+++ b/puppet/modules/augeas/spec/defines/augeas_lens_spec.rb
@@ -0,0 +1,112 @@
+require 'spec_helper'
+
+describe 'augeas::lens' do
+ let (:title) { 'foo' }
+
+ context 'when not declaring augeas class first' do
+ let (:params) do
+ {
+ :lens_source => '/tmp/foo.aug',
+ }
+ end
+
+ it 'should error' do
+ expect {
+ is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug')
+ }.to raise_error(Puppet::Error, /You must declare the augeas class/)
+ end
+ end
+
+ context 'when declaring augeas class first' do
+
+ on_supported_os.each do |os, facts|
+ context "on #{os}" do
+ let(:facts) do
+ facts.merge({
+ :augeasversion => :undef,
+ })
+ end
+
+ context 'With standard augeas version' do
+
+ let(:pre_condition) do
+ "class { '::augeas': }"
+ end
+
+ context 'when no lens_source is passed' do
+ it 'should error' do
+ expect {
+ is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug')
+ }.to raise_error(Puppet::Error, /Must pass lens_source/)
+ end
+ end
+
+ context 'when lens_source is passed' do
+ let (:params) do
+ {
+ :lens_source => '/tmp/foo.aug',
+ }
+ end
+
+ it { is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') }
+ it { is_expected.to contain_exec('Typecheck lens foo') }
+ it { is_expected.not_to contain_file('/usr/share/augeas/lenses/tests/test_foo.aug') }
+ it { is_expected.not_to contain_exec('Test lens foo') }
+ end
+
+ context 'when lens_source and test_source are passed' do
+ let (:params) do
+ {
+ :lens_source => '/tmp/foo.aug',
+ :test_source => '/tmp/test_foo.aug',
+ }
+ end
+
+ it { is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') }
+ it { is_expected.to contain_exec('Typecheck lens foo') }
+ it { is_expected.to contain_file('/usr/share/augeas/lenses/tests/test_foo.aug') }
+ it { is_expected.to contain_exec('Test lens foo') }
+ end
+ end
+
+ context 'when stock_since is passed and augeas is older' do
+ let (:params) do
+ {
+ :lens_source => '/tmp/foo.aug',
+ :stock_since => '1.2.3',
+ }
+ end
+
+ let(:pre_condition) do
+ "class { '::augeas': version => '1.0.0' }"
+ end
+
+ it { is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') }
+ it { is_expected.to contain_exec('Typecheck lens foo') }
+ end
+
+ context 'when stock_since is passed and augeas is newer' do
+ let (:params) do
+ {
+ :lens_source => '/tmp/foo.aug',
+ :stock_since => '1.2.3',
+ }
+ end
+
+ let(:pre_condition) do
+ "class { '::augeas': version => '1.3.0' }"
+ end
+
+ it do
+ pending "undefined method `negative_failure_message'"
+ is_expected.not_to contain_file('/usr/share/augeas/lenses/foo.aug')
+ end
+ it do
+ pending "undefined method `negative_failure_message'"
+ is_expected.not_to contain_exec('Typecheck lens foo')
+ end
+ end
+ end
+ end
+ end
+end