diff options
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/acceptance/is_string_spec.rb | 11 | ||||
-rwxr-xr-x | spec/acceptance/validate_string_spec.rb | 7 | ||||
-rw-r--r-- | spec/aliases/string_spec.rb | 3 | ||||
-rwxr-xr-x | spec/functions/validate_string_spec.rb | 1 |
4 files changed, 21 insertions, 1 deletions
diff --git a/spec/acceptance/is_string_spec.rb b/spec/acceptance/is_string_spec.rb index 94d8e96..f526888 100755 --- a/spec/acceptance/is_string_spec.rb +++ b/spec/acceptance/is_string_spec.rb @@ -95,6 +95,17 @@ describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o expect(r.stdout).to match(/Notice: output correct/) end end + it 'is_strings undef' do + pp = <<-EOS + $a = undef + $o = is_string($a) + notice(inline_template('is_string is <%= @o.inspect %>')) + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/is_string is true/) + end + end end describe 'failure' do it 'handles improper argument counts' diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb index 8956f48..ae3468f 100755 --- a/spec/acceptance/validate_string_spec.rb +++ b/spec/acceptance/validate_string_spec.rb @@ -20,6 +20,13 @@ describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(f apply_manifest(pp, :catch_failures => true) end + it 'validates undef' do + pp = <<-EOS + validate_string(undef) + EOS + + apply_manifest(pp, :catch_failures => true) + end it 'validates a non-string' do { %{validate_string({ 'a' => 'hash' })} => "Hash", diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index 8e01d55..853b5af 100644 --- a/spec/aliases/string_spec.rb +++ b/spec/aliases/string_spec.rb @@ -6,6 +6,7 @@ if Puppet.version.to_f >= 4.0 [ '', 'one', + nil, ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -23,7 +24,7 @@ if Puppet.version.to_f >= 4.0 ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::String = String/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a String/) } end end end diff --git a/spec/functions/validate_string_spec.rb b/spec/functions/validate_string_spec.rb index b5ce763..0907ede 100755 --- a/spec/functions/validate_string_spec.rb +++ b/spec/functions/validate_string_spec.rb @@ -18,6 +18,7 @@ describe 'validate_string' do describe 'valid inputs' do it { is_expected.to run.with_params('') } + it { is_expected.to run.with_params(nil) } it { is_expected.to run.with_params('one') } it { is_expected.to run.with_params('one', 'two') } end |