annotate modules/stdlib/spec/acceptance/values_spec.rb @ 37:addb0ea390a1 puppet-3.6

Update Puppet "stdlib" module
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:09:45 +0000
parents
children c42fb28cff86
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 #! /usr/bin/env ruby -S rspec
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 require 'spec_helper_acceptance'
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 describe 'success' do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 it 'returns an array of values' do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 pp = <<-EOS
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 $arg = {
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 'a' => 1,
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 'b' => 2,
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 'c' => 3,
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 }
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 $output = values($arg)
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 notice(inline_template('<%= @output.sort.inspect %>'))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 EOS
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 if is_future_parser_enabled?
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 else
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 describe 'failure' do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 it 'handles non-hash arguments' do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 pp = <<-EOS
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 $arg = "foo"
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 $output = values($arg)
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 notice(inline_template('<%= @output.inspect %>'))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 EOS
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires hash/)
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 end