summaryrefslogtreecommitdiff
path: root/spec/unit/ensure_resources_spec.rb
blob: aea723e9d7f3eb8b2ed4548e3a4b3a34dfbc311f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'spec_helper'

describe 'test::ensure_resources', type: :class do
  let(:params) {{ resource_type: 'user', title_hash: title_param, attributes_hash: {'ensure' => 'present'} }}

  describe 'given a title hash of multiple resources' do

    let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700'}} }

    it { is_expected.to compile }
    it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) }
    it { is_expected.to contain_user('alex').with({ 'gid' => 'mygroup', 'uid' => '700', 'ensure' => 'present'}) }
  end

  describe 'given a title hash of a single resource' do

    let(:title_param) { {'dan' => { 'gid' => 'mygroup', 'uid' => '600' }} }

    it { is_expected.to compile }
    it { is_expected.to contain_user('dan').with({ 'gid' => 'mygroup', 'uid' => '600', 'ensure' => 'present'}) }
  end
end