summaryrefslogtreecommitdiff
path: root/spec/functions/ensure_resources_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/functions/ensure_resources_spec.rb')
-rw-r--r--spec/functions/ensure_resources_spec.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/spec/functions/ensure_resources_spec.rb b/spec/functions/ensure_resources_spec.rb
index aea723e..7cca671 100644
--- a/spec/functions/ensure_resources_spec.rb
+++ b/spec/functions/ensure_resources_spec.rb
@@ -1,22 +1,25 @@
require 'spec_helper'
-describe 'test::ensure_resources', type: :class do
- let(:params) {{ resource_type: 'user', title_hash: title_param, attributes_hash: {'ensure' => 'present'} }}
+describe 'ensure_resources' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) }
+ it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) }
describe 'given a title hash of multiple resources' do
+ before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}}, {'ensure' => 'present'}]) }
- let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}} }
-
- it { is_expected.to compile }
- it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) }
- it { is_expected.to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700', 'ensure' => 'present'}) }
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
+ it { expect(lambda { catalogue }).to contain_user('alex').with_ensure('present') }
+ it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) }
+ it { expect(lambda { catalogue }).to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700'}) }
end
describe 'given a title hash of a single resource' do
+ before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }}, {'ensure' => 'present'}]) }
- let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }} }
-
- it { is_expected.to compile }
- it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) }
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
+ it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) }
end
end