Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / parseyaml_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'parseyaml function' do
4   describe 'success' do
5     pp1 = <<-DOC
6       $a = "---\nhunter: washere\ntests: passing\n"
7       $o = parseyaml($a)
8       $tests = $o['tests']
9       notice(inline_template('tests are <%= @tests.inspect %>'))
10     DOC
11     it 'parses valid yaml' do
12       apply_manifest(pp1, :catch_failures => true) do |r|
13         expect(r.stdout).to match(%r{tests are "passing"})
14       end
15     end
16   end
17
18   describe 'failure' do
19     pp2 = <<-DOC
20       $a = "---\nhunter: washere\ntests: passing\n:"
21       $o = parseyaml($a, {'tests' => 'using the default value'})
22       $tests = $o['tests']
23       notice(inline_template('tests are <%= @tests.inspect %>'))
24     DOC
25     it 'returns the default value on incorrect yaml' do
26       apply_manifest(pp2, :catch_failures => true) do |r|
27         expect(r.stdout).to match(%r{tests are "using the default value"})
28       end
29     end
30
31     pp3 = <<-DOC
32       $a = "---\nhunter: washere\ntests: passing\n:"
33       $o = parseyaml($a)
34       $tests = $o['tests']
35       notice(inline_template('tests are <%= @tests.inspect %>'))
36     DOC
37     it 'raises error on incorrect yaml' do
38       apply_manifest(pp3, :expect_failures => true) do |r|
39         expect(r.stderr).to match(%r{(syntax error|did not find expected key)})
40       end
41     end
42
43     pp4 = <<-DOC
44       $o = parseyaml()
45     DOC
46     it 'raises error on incorrect number of arguments' do
47       apply_manifest(pp4, :expect_failures => true) do |r|
48         expect(r.stderr).to match(%r{wrong number of arguments}i)
49       end
50     end
51   end
52 end