+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
+ end
+
+ describe 'after running ensure_resource("user", ["username1", "username2"], {})' do
+ before(:each) { subject.execute('User', ['username1', 'username2'], {}) }
+
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') }
+ it { expect(-> { catalogue }).to contain_user('username2').without_ensure }
+ end
+
+ describe 'when providing already set params' do
+ let(:params) { { 'ensure' => 'present' } }
+
+ before(:each) { subject.execute('User', ['username2', 'username3'], params) }
+
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(-> { catalogue }).to contain_user('username1').with(params) }
+ it { expect(-> { catalogue }).to contain_user('username2').with(params) }
+ end
+
+ context 'when trying to add params' do
+ it {
+ is_expected.to run \
+ .with_params('User', 'username1', 'ensure' => 'present', 'shell' => true) \
+ .and_raise_error(Puppet::Resource::Catalog::DuplicateResourceError, %r{User\[username1\] is already declared})
+ }