source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/acceptance/values_at_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 8 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper_acceptance'
3
4describe 'values_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5 describe 'success' do
6 it 'returns a specific value' do
7 pp = <<-EOS
8 $one = ['a','b','c','d','e']
9 $two = 1
10 $output = values_at($one,$two)
11 notice(inline_template('<%= @output.inspect %>'))
12 EOS
13
14 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b"\]/)
15 end
16 it 'returns a specific negative index value' do
17 pending("negative numbers don't work")
18 pp = <<-EOS
19 $one = ['a','b','c','d','e']
20 $two = -1
21 $output = values_at($one,$two)
22 notice(inline_template('<%= @output.inspect %>'))
23 EOS
24
25 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["e"\]/)
26 end
27 it 'returns a range of values' do
28 pp = <<-EOS
29 $one = ['a','b','c','d','e']
30 $two = "1-3"
31 $output = values_at($one,$two)
32 notice(inline_template('<%= @output.inspect %>'))
33 EOS
34
35 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d"\]/)
36 end
37 it 'returns a negative specific value and range of values' do
38 pp = <<-EOS
39 $one = ['a','b','c','d','e']
40 $two = ["1-3",0]
41 $output = values_at($one,$two)
42 notice(inline_template('<%= @output.inspect %>'))
43 EOS
44
45 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d", "a"\]/)
46 end
47 end
48 describe 'failure' do
49 it 'handles improper number of arguments' do
50 pp = <<-EOS
51 $one = ['a','b','c','d','e']
52 $output = values_at($one)
53 notice(inline_template('<%= @output.inspect %>'))
54 EOS
55
56 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/)
57 end
58 it 'handles non-indicies arguments' do
59 pp = <<-EOS
60 $one = ['a','b','c','d','e']
61 $two = []
62 $output = values_at($one,$two)
63 notice(inline_template('<%= @output.inspect %>'))
64 EOS
65
66 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/at least one positive index/)
67 end
68
69 it 'detects index ranges smaller than the start range'
70 it 'handles index ranges larger than array'
71 it 'handles non-integer indicies'
72 end
73end
Note: See TracBrowser for help on using the repository browser.