Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / values_at_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'values_at function' do
4   describe 'success' do
5     pp1 = <<-DOC
6       $one = ['a','b','c','d','e']
7       $two = 1
8       $output = values_at($one,$two)
9       notice(inline_template('<%= @output.inspect %>'))
10     DOC
11     it 'returns a specific value' do
12       expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\["b"\]})
13     end
14
15     pp2 = <<-DOC
16       $one = ['a','b','c','d','e']
17       $two = -1
18       $output = values_at($one,$two)
19       notice(inline_template('<%= @output.inspect %>'))
20     DOC
21     it 'returns a specific negative index value' do
22       pending("negative numbers don't work")
23       expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\["e"\]})
24     end
25
26     pp3 = <<-DOC
27       $one = ['a','b','c','d','e']
28       $two = "1-3"
29       $output = values_at($one,$two)
30       notice(inline_template('<%= @output.inspect %>'))
31     DOC
32     it 'returns a range of values' do
33       expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\["b", "c", "d"\]})
34     end
35
36     pp4 = <<-DOC
37       $one = ['a','b','c','d','e']
38       $two = ["1-3",0]
39       $output = values_at($one,$two)
40       notice(inline_template('<%= @output.inspect %>'))
41     DOC
42     it 'returns a negative specific value and range of values' do
43       expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\["b", "c", "d", "a"\]})
44     end
45   end
46
47   describe 'failure' do
48     pp5 = <<-DOC
49       $one = ['a','b','c','d','e']
50       $output = values_at($one)
51       notice(inline_template('<%= @output.inspect %>'))
52     DOC
53     it 'handles improper number of arguments' do
54       expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
55     end
56
57     pp6 = <<-DOC
58       $one = ['a','b','c','d','e']
59       $two = []
60       $output = values_at($one,$two)
61       notice(inline_template('<%= @output.inspect %>'))
62     DOC
63     it 'handles non-indicies arguments' do
64       expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{at least one positive index})
65     end
66
67     it 'detects index ranges smaller than the start range'
68     it 'handles index ranges larger than array'
69     it 'handles non-integer indicies'
70   end
71 end