Skip to content

Commit

Permalink
(MODULES-3829) Add tests for ensure_resources
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HAIL9000 committed Dec 2, 2016
1 parent 85bdbcf commit 3e132bd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/functions/ensure_resources_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'

describe 'ensure_resources' do
describe 'given a title hash of multiple resources' do
before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700' }}, {'ensure' => 'present'}]) }

it { expect(lambda { catalogue }).to contain_user('dan').with_uid('600') }
it { expect(lambda { catalogue }).to contain_user('dan').with_gid('mygroup') }
it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }

it { expect(lambda { catalogue }).to contain_user('alex').with_uid('700') }
it { expect(lambda { catalogue }).to contain_user('alex').with_gid('mygroup') }
it { expect(lambda { catalogue }).to contain_user('alex').with_ensure('present') }
end

describe 'given a title hash of a single resource' do
before { subject.call(['user', {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }}, {'ensure' => 'present'}]) }

it { expect(lambda { catalogue }).to contain_user('dan').with_uid('600') }
it { expect(lambda { catalogue }).to contain_user('dan').with_gid('mygroup') }
it { expect(lambda { catalogue }).to contain_user('dan').with_ensure('present') }
end
end

0 comments on commit 3e132bd

Please sign in to comment.