1 | require 'spec_helper'
|
---|
2 |
|
---|
3 | describe 'defined_with_params' do
|
---|
4 | describe 'when no resource is specified' do
|
---|
5 | it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
|
---|
6 | end
|
---|
7 | describe 'when compared against a resource with no attributes' do
|
---|
8 | let :pre_condition do
|
---|
9 | 'user { "dan": }'
|
---|
10 | end
|
---|
11 | it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
|
---|
12 | it { is_expected.to run.with_params('User[bob]', {}).and_return(false) }
|
---|
13 | it { is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) }
|
---|
14 | end
|
---|
15 |
|
---|
16 | describe 'when compared against a resource with attributes' do
|
---|
17 | let :pre_condition do
|
---|
18 | 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
|
---|
19 | end
|
---|
20 | it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
|
---|
21 | it { is_expected.to run.with_params('User[dan]', '').and_return(true) }
|
---|
22 | it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}).and_return(true) }
|
---|
23 | it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false}).and_return(true) }
|
---|
24 | it { is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false}).and_return(false) }
|
---|
25 | end
|
---|
26 |
|
---|
27 | describe 'when passing undef values' do
|
---|
28 | let :pre_condition do
|
---|
29 | 'file { "/tmp/a": ensure => present }'
|
---|
30 | end
|
---|
31 |
|
---|
32 | it { is_expected.to run.with_params('File[/tmp/a]', {}).and_return(true) }
|
---|
33 | it { is_expected.to run.with_params('File[/tmp/a]', { 'ensure' => 'present', 'owner' => :undef }).and_return(true) }
|
---|
34 | end
|
---|
35 | end
|
---|