Update stdlib and concat to 6.1.0 both
[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, %r{Must specify a type}) }
6   it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, %r{Must specify a title}) }
7
8   describe 'given a title hash of multiple resources' do
9     before(:each) do
10       subject.execute('user', { 'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700' } }, 'ensure' => 'present')
11     end
12
13     # this lambda is required due to strangeness within rspec-puppet's expectation handling
14     it { expect(-> { catalogue }).to contain_user('dan').with_ensure('present') }
15     it { expect(-> { catalogue }).to contain_user('alex').with_ensure('present') }
16     it { expect(-> { catalogue }).to contain_user('dan').with('gid' => 'mygroup', 'uid' => '600') }
17     it { expect(-> { catalogue }).to contain_user('alex').with('gid' => 'mygroup', 'uid' => '700') }
18   end
19
20   describe 'given a title hash of a single resource' do
21     before(:each) { subject.execute('user', { 'dan' => { 'gid' => 'mygroup', 'uid' => '600' } }, 'ensure' => 'present') }
22
23     # this lambda is required due to strangeness within rspec-puppet's expectation handling
24     it { expect(-> { catalogue }).to contain_user('dan').with_ensure('present') }
25     it { expect(-> { catalogue }).to contain_user('dan').with('gid' => 'mygroup', 'uid' => '600') }
26   end
27 end