ensure_resources_spec.rb 1.4 KB

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