Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / pick_default_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'pick_default function' do
4   describe 'success' do
5     pp1 = <<-DOC
6       $a = undef
7       $o = pick_default($a, 'default')
8       notice(inline_template('picked is <%= @o.inspect %>'))
9     DOC
10     it 'pick_defaults a default value' do
11       apply_manifest(pp1, :catch_failures => true) do |r|
12         expect(r.stdout).to match(%r{picked is "default"})
13       end
14     end
15
16     pp2 = <<-DOC
17       $a = undef
18       $b = undef
19       $o = pick_default($a,$b)
20       notice(inline_template('picked is <%= @o.inspect %>'))
21     DOC
22     it 'pick_defaults with no value' do
23       apply_manifest(pp2, :catch_failures => true) do |r|
24         expect(r.stdout).to match(%r{picked is ""})
25       end
26     end
27
28     pp3 = <<-DOC
29       $a = "something"
30       $b = "long"
31       $o = pick_default($a, $b, 'default')
32       notice(inline_template('picked is <%= @o.inspect %>'))
33     DOC
34     it 'pick_defaults the first set value' do
35       apply_manifest(pp3, :catch_failures => true) do |r|
36         expect(r.stdout).to match(%r{picked is "something"})
37       end
38     end
39   end
40   describe 'failure' do
41     pp4 = <<-DOC
42       $o = pick_default()
43       notice(inline_template('picked is <%= @o.inspect %>'))
44     DOC
45     it 'raises error with no values' do
46       apply_manifest(pp4, :expect_failures => true) do |r|
47         expect(r.stderr).to match(%r{Must receive at least one argument})
48       end
49     end
50   end
51 end