1 require 'spec_helper_acceptance'
3 describe 'values_at function' do
6 $one = ['a','b','c','d','e']
8 $output = values_at($one,$two)
9 notice(inline_template('<%= @output.inspect %>'))
11 it 'returns a specific value' do
12 expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\["b"\]})
16 $one = ['a','b','c','d','e']
18 $output = values_at($one,$two)
19 notice(inline_template('<%= @output.inspect %>'))
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"\]})
27 $one = ['a','b','c','d','e']
29 $output = values_at($one,$two)
30 notice(inline_template('<%= @output.inspect %>'))
32 it 'returns a range of values' do
33 expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\["b", "c", "d"\]})
37 $one = ['a','b','c','d','e']
39 $output = values_at($one,$two)
40 notice(inline_template('<%= @output.inspect %>'))
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"\]})
49 $one = ['a','b','c','d','e']
50 $output = values_at($one)
51 notice(inline_template('<%= @output.inspect %>'))
53 it 'handles improper number of arguments' do
54 expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
58 $one = ['a','b','c','d','e']
60 $output = values_at($one,$two)
61 notice(inline_template('<%= @output.inspect %>'))
63 it 'handles non-indicies arguments' do
64 expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{at least one positive index})
67 it 'detects index ranges smaller than the start range'
68 it 'handles index ranges larger than array'
69 it 'handles non-integer indicies'