Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / pick_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'pick function' do
4   describe 'success' do
5     pp1 = <<-DOC
6       $a = undef
7       $o = pick($a, 'default')
8       notice(inline_template('picked is <%= @o.inspect %>'))
9     DOC
10     it 'picks 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 = "something"
18       $b = "long"
19       $o = pick($a, $b, 'default')
20       notice(inline_template('picked is <%= @o.inspect %>'))
21     DOC
22     it 'picks the first set value' do
23       apply_manifest(pp2, :catch_failures => true) do |r|
24         expect(r.stdout).to match(%r{picked is "something"})
25       end
26     end
27   end
28
29   describe 'failure' do
30     pp3 = <<-DOC
31       $a = undef
32       $b = undef
33       $o = pick($a, $b)
34       notice(inline_template('picked is <%= @o.inspect %>'))
35     DOC
36     it 'raises error with all undef values' do
37       apply_manifest(pp3, :expect_failures => true) do |r|
38         expect(r.stderr).to match(%r{must receive at least one non empty value})
39       end
40     end
41   end
42 end