522ed3b84050de68ca29c7878f2fc3c799e8c5cc
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / getparam_spec.rb
1 require 'spec_helper'
2
3 describe 'getparam' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a reference/) }
6   it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, /Must specify name of a parameter/) }
7   it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
8   it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
9   it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
10
11   describe 'when compared against a user resource with no params' do
12     let(:pre_condition) { 'user { "one": }' }
13
14     it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') }
15     it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
16     it { is_expected.to run.with_params('User[one]', 'shell').and_return('') }
17   end
18
19   describe 'when compared against a user resource with params' do
20     let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' }
21
22     it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') }
23     it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
24     it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') }
25     it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) }
26   end
27
28   describe 'when compared against a user resource with UTF8 and double byte params' do
29     let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' }
30
31     it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') }
32     it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') }
33
34   end
35 end