]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/defined_with_params_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / defined_with_params_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 require 'rspec-puppet'
5 describe 'defined_with_params' do
6   describe 'when a resource is not specified' do
7     it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
8   end
9   describe 'when compared against a resource with no attributes' do
10     let :pre_condition do
11       'user { "dan": }'
12     end
13     it do
14       is_expected.to run.with_params('User[dan]', {}).and_return(true)
15       is_expected.to run.with_params('User[bob]', {}).and_return(false)
16       is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false)
17     end
18   end
19
20   describe 'when compared against a resource with attributes' do
21     let :pre_condition do
22       'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
23     end
24     it do
25       is_expected.to run.with_params('User[dan]', {}).and_return(true)
26       is_expected.to run.with_params('User[dan]', '').and_return(true)
27       is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}
28                             ).and_return(true)
29       is_expected.to run.with_params('User[dan]',
30                              {'ensure' => 'present', 'managehome' => false}
31                             ).and_return(true)
32       is_expected.to run.with_params('User[dan]',
33                              {'ensure' => 'absent', 'managehome' => false}
34                             ).and_return(false)
35     end
36   end
37 end