summaryrefslogtreecommitdiff
path: root/spec/functions/ensure_resource_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/functions/ensure_resource_spec.rb')
-rwxr-xr-xspec/functions/ensure_resource_spec.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb
index 57b5123..9a17f5b 100755
--- a/spec/functions/ensure_resource_spec.rb
+++ b/spec/functions/ensure_resource_spec.rb
@@ -10,6 +10,32 @@ describe 'ensure_resource' do
is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError)
}
+ context 'given an empty catalog' do
+ describe 'after running ensure_resource("user", "username1", {})' do
+ before { subject.call(['User', 'username1', {}]) }
+
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(lambda { catalogue }).to contain_user('username1').without_ensure }
+ end
+
+ describe 'after running ensure_resource("user", "username1", { gid => undef })' do
+ before { subject.call(['User', 'username1', { 'gid' => :undef }]) }
+
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(lambda { catalogue }).to contain_user('username1').without_ensure }
+ it { expect(lambda { catalogue }).to contain_user('username1').without_gid }
+ end
+
+ describe 'after running ensure_resource("user", "username1", { ensure => present, gid => undef })' do
+ before { subject.call(['User', 'username1', { 'ensure' => 'present', 'gid' => :undef }]) }
+
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
+ it { expect(lambda { catalogue }).to contain_user('username1').without_gid }
+ end
+
+ end
+
context 'given a catalog with "user { username1: ensure => present }"' do
let(:pre_condition) { 'user { username1: ensure => present }' }
@@ -28,8 +54,8 @@ describe 'ensure_resource' do
it { expect(lambda { catalogue }).to contain_user('username2').without_ensure }
end
- describe 'after running ensure_resource("user", "username1", { "gid" => undef })' do
- before { subject.call(['User', 'username1', { "gid" => :undef }]) }
+ describe 'after running ensure_resource("user", "username1", { gid => undef })' do
+ before { subject.call(['User', 'username1', { 'gid' => :undef }]) }
# this lambda is required due to strangeness within rspec-puppet's expectation handling
it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }