37
|
1 #! /usr/bin/env ruby -S rspec
|
|
2 require 'spec_helper_acceptance'
|
|
3
|
|
4 describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
|
5 describe 'success' do
|
|
6 it 'returns an array of values' do
|
|
7 pp = <<-EOS
|
|
8 $arg = {
|
|
9 'a' => 1,
|
|
10 'b' => 2,
|
|
11 'c' => 3,
|
|
12 }
|
|
13 $output = values($arg)
|
|
14 notice(inline_template('<%= @output.sort.inspect %>'))
|
|
15 EOS
|
|
16 if is_future_parser_enabled?
|
|
17 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
|
|
18 else
|
|
19 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
|
|
20 end
|
|
21
|
|
22 end
|
|
23 end
|
|
24 describe 'failure' do
|
|
25 it 'handles non-hash arguments' do
|
|
26 pp = <<-EOS
|
|
27 $arg = "foo"
|
|
28 $output = values($arg)
|
|
29 notice(inline_template('<%= @output.inspect %>'))
|
|
30 EOS
|
|
31
|
|
32 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires hash/)
|
|
33 end
|
|
34 end
|
|
35 end
|