7cca6719980b4164bf501e0e6938568b20d288e6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / ensure_resources_spec.rb
1 require 'spec_helper'
2
3 describe 'ensure_resources' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) }
6   it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) }
7
8   describe 'given a title hash of multiple resources' do
9     before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}}, {'ensure' => 'present'}]) }
10
11     # this lambda is required due to strangeness within rspec-puppet's expectation handling
12     it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
13     it { expect(lambda { catalogue }).to contain_user('alex').with_ensure('present') }
14     it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) }
15     it { expect(lambda { catalogue }).to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700'}) }
16   end
17
18   describe 'given a title hash of a single resource' do
19     before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }}, {'ensure' => 'present'}]) }
20
21     # this lambda is required due to strangeness within rspec-puppet's expectation handling
22     it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
23     it { expect(lambda { catalogue }).to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600'}) }
24   end
25 end