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) }
7 describe 'when compared against a resource with no attributes' do
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) }
15 context 'should run with UTF8 and double byte characters' do
16 it { is_expected.to run.with_params('User[ĵĭмოү]', {}).and_return(false) }
17 it { is_expected.to run.with_params('User[ポーラ]', {}).and_return(false) }
21 describe 'when compared against a resource with attributes' do
23 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
25 it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
26 it { is_expected.to run.with_params('User[dan]', '').and_return(true) }
27 it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}).and_return(true) }
28 it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false}).and_return(true) }
29 it { is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false}).and_return(false) }
32 describe 'when passing undef values' do
34 'file { "/tmp/a": ensure => present }'
37 it { is_expected.to run.with_params('File[/tmp/a]', {}).and_return(true) }
38 it { is_expected.to run.with_params('File[/tmp/a]', { 'ensure' => 'present', 'owner' => :undef }).and_return(true) }
41 describe 'when the reference is a' do
45 context 'reference' do
46 it { is_expected.to run.with_params(Puppet::Resource.new('User[dan]'), {}).and_return(true) }
48 if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0
52 subject.call([['User[dan]'], {}])
53 }.to raise_error ArgumentError, /not understood: 'Array'/
59 describe 'when passed a defined type' do
61 'test::deftype { "foo": }'
63 it { is_expected.to run.with_params('Test::Deftype[foo]', {}).and_return(true) }
64 it { is_expected.to run.with_params('Test::Deftype[bar]', {}).and_return(false) }
65 it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[foo]'), {}).and_return(true) }
66 it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[bar]'), {}).and_return(false) }