Skip to content

Commit 3e132bd

Browse files
committed
(MODULES-3829) Add tests for ensure_resources
Prior to this commit, we didn't have tests for the ensure_resources function (only for the ensure_resource function). This meant that we weren't catching a bug in the ensure_resources function. In order to prevent this in the future, add some tests which test the specific functionality of ensure_resources.
1 parent 85bdbcf commit 3e132bd

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'spec_helper'
2+
3+
describe 'ensure_resources' do
4+
describe 'given a title hash of multiple resources' do
5+
before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700' }}, {'ensure' => 'present'}]) }
6+
7+
it { expect(lambda { catalogue }).to contain_user('dan').with_uid('600') }
8+
it { expect(lambda { catalogue }).to contain_user('dan').with_gid('mygroup') }
9+
it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
10+
11+
it { expect(lambda { catalogue }).to contain_user('alex').with_uid('700') }
12+
it { expect(lambda { catalogue }).to contain_user('alex').with_gid('mygroup') }
13+
it { expect(lambda { catalogue }).to contain_user('alex').with_ensure('present') }
14+
end
15+
16+
describe 'given a title hash of a single resource' do
17+
before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }}, {'ensure' => 'present'}]) }
18+
19+
it { expect(lambda { catalogue }).to contain_user('dan').with_uid('600') }
20+
it { expect(lambda { catalogue }).to contain_user('dan').with_gid('mygroup') }
21+
it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
22+
end
23+
end

0 commit comments

Comments
 (0)