Changeset be0859f for src/puppetcode/environments/gnuboat/modules/stdlib/spec/functions/ensure_resource_spec.rb
- Timestamp:
- Jul 31, 2017, 6:42:27 PM (9 years ago)
- Branches:
- 0.5, app-cordova, debian/bullseye, debian/jessie, master
- Children:
- fc9d514
- Parents:
- eb1ccd6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/puppetcode/environments/gnuboat/modules/stdlib/spec/functions/ensure_resource_spec.rb
reb1ccd6 rbe0859f 5 5 it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) } 6 6 it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) } 7 it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) } 7 if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 8 it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(ArgumentError) } 9 else 10 it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) } 11 end 12 8 13 it { 9 14 pending("should not accept numbers as arguments") 10 15 is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError) 11 16 } 17 18 context 'given an empty catalog' do 19 describe 'after running ensure_resource("user", "username1", {})' do 20 before { subject.call(['User', 'username1', {}]) } 21 22 # this lambda is required due to strangeness within rspec-puppet's expectation handling 23 it { expect(lambda { catalogue }).to contain_user('username1').without_ensure } 24 end 25 26 describe 'after running ensure_resource("user", "username1", { gid => undef })' do 27 before { subject.call(['User', 'username1', { 'gid' => :undef }]) } 28 29 # this lambda is required due to strangeness within rspec-puppet's expectation handling 30 it { expect(lambda { catalogue }).to contain_user('username1').without_ensure } 31 it { expect(lambda { catalogue }).to contain_user('username1').without_gid } 32 end 33 34 describe 'after running ensure_resource("user", "username1", { ensure => present, gid => undef })' do 35 before { subject.call(['User', 'username1', { 'ensure' => 'present', 'gid' => :undef }]) } 36 37 # this lambda is required due to strangeness within rspec-puppet's expectation handling 38 it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } 39 it { expect(lambda { catalogue }).to contain_user('username1').without_gid } 40 end 41 42 describe 'after running ensure_resource("test::deftype", "foo", {})' do 43 before { subject.call(['test::deftype', 'foo', {}]) } 44 45 # this lambda is required due to strangeness within rspec-puppet's expectation handling 46 it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure } 47 end 48 end 49 50 context 'given a catalog with UTF8 chars' do 51 describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do 52 before { subject.call(['User', 'Şắოрŀễ Ţëם', {}]) } 53 54 # this lambda is required due to strangeness within rspec-puppet's expectation handling 55 it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } 56 end 57 58 describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { gid => undef })' do 59 before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'gid' => :undef }]) } 60 61 # this lambda is required due to strangeness within rspec-puppet's expectation handling 62 it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } 63 it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } 64 end 65 66 describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { ensure => present, gid => undef })' do 67 before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'ensure' => 'present', 'gid' => :undef }]) } 68 69 # this lambda is required due to strangeness within rspec-puppet's expectation handling 70 it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').with_ensure('present') } 71 it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } 72 end 73 end 12 74 13 75 context 'given a catalog with "user { username1: ensure => present }"' do … … 27 89 it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } 28 90 it { expect(lambda { catalogue }).to contain_user('username2').without_ensure } 91 end 92 93 describe 'after running ensure_resource("user", "username1", { gid => undef })' do 94 before { subject.call(['User', 'username1', { 'gid' => :undef }]) } 95 96 # this lambda is required due to strangeness within rspec-puppet's expectation handling 97 it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } 29 98 end 30 99 … … 53 122 end 54 123 end 124 125 context 'given a catalog with "test::deftype { foo: }"' do 126 let(:pre_condition) { 'test::deftype { "foo": }' } 127 128 describe 'after running ensure_resource("test::deftype", "foo", {})' do 129 before { subject.call(['test::deftype', 'foo', {}]) } 130 131 # this lambda is required due to strangeness within rspec-puppet's expectation handling 132 it { expect(lambda { catalogue }).to contain_test__deftype('foo').without_ensure } 133 end 134 end 55 135 end
Note:
See TracChangeset
for help on using the changeset viewer.
