source: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_spec.rb@ 7549de9

0.5 app-cordova debian/bullseye debian/jessie
Last change on this file since 7549de9 was 1c22429, checked in by Joachim Langenbach <joachim.langenbach@…>, 10 years ago
  • gnuboat_epd adds the apt repository from gnuboat to install epd-fuse package
  • Property mode set to 100755
File size: 1.2 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper_acceptance'
3
4describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5 describe 'success' do
6 it 'picks a default value' do
7 pp = <<-EOS
8 $a = undef
9 $o = pick($a, 'default')
10 notice(inline_template('picked is <%= @o.inspect %>'))
11 EOS
12
13 apply_manifest(pp, :catch_failures => true) do |r|
14 expect(r.stdout).to match(/picked is "default"/)
15 end
16 end
17 it 'picks the first set value' do
18 pp = <<-EOS
19 $a = "something"
20 $b = "long"
21 $o = pick($a, $b, 'default')
22 notice(inline_template('picked is <%= @o.inspect %>'))
23 EOS
24
25 apply_manifest(pp, :catch_failures => true) do |r|
26 expect(r.stdout).to match(/picked is "something"/)
27 end
28 end
29 end
30 describe 'failure' do
31 it 'raises error with all undef values' do
32 pp = <<-EOS
33 $a = undef
34 $b = undef
35 $o = pick($a, $b)
36 notice(inline_template('picked is <%= @o.inspect %>'))
37 EOS
38
39 apply_manifest(pp, :expect_failures => true) do |r|
40 expect(r.stderr).to match(/must receive at least one non empty value/)
41 end
42 end
43 end
44end
Note: See TracBrowser for help on using the repository browser.