Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / validate_string_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
3
4 describe 'validate_string function' do
5   describe 'success' do
6     it 'validates a single argument' do
7       pp = <<-EOS
8       $one = 'string'
9       validate_string($one)
10       EOS
11
12       apply_manifest(pp, :catch_failures => true)
13     end
14     it 'validates an multiple arguments' do
15       pp = <<-EOS
16       $one = 'string'
17       $two = 'also string'
18       validate_string($one,$two)
19       EOS
20
21       apply_manifest(pp, :catch_failures => true)
22     end
23     it 'validates undef' do
24       pp = <<-EOS
25       validate_string(undef)
26       EOS
27
28       apply_manifest(pp, :catch_failures => true)
29     end
30     it 'validates a non-string' do
31       {
32         %{validate_string({ 'a' => 'hash' })} => "Hash",
33         %{validate_string(['array'])}         => "Array",
34         %{validate_string(false)}             => "FalseClass",
35       }.each do |pp,type|
36         expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
37       end
38     end
39   end
40   describe 'failure' do
41     it 'handles improper number of arguments'
42   end
43 end