summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortphoney <tp@puppet.com>2017-07-13 16:12:08 +0100
committertphoney <tp@puppet.com>2017-07-13 17:42:41 +0100
commit01d3004f0a6a1c662aea90edd5b1524139706c61 (patch)
tree80e3dc446807ec73a32ccab0dee8bb0bb1aa09e3
parent54d4937c5b2d8918ee9f89f728c0c29e0d9e774f (diff)
(FM-6239) rewrite of test following std patterns
-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