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

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

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

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper_acceptance'
3
4describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5 describe 'success' do
6 it 'pick_defaults a default value' do
7 pp = <<-EOS
8 $a = undef
9 $o = pick_default($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 'pick_defaults with no value' do
18 pp = <<-EOS
19 $a = undef
20 $b = undef
21 $o = pick_default($a,$b)
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 ""/)
27 end
28 end
29 it 'pick_defaults the first set value' do
30 pp = <<-EOS
31 $a = "something"
32 $b = "long"
33 $o = pick_default($a, $b, 'default')
34 notice(inline_template('picked is <%= @o.inspect %>'))
35 EOS
36
37 apply_manifest(pp, :catch_failures => true) do |r|
38 expect(r.stdout).to match(/picked is "something"/)
39 end
40 end
41 end
42 describe 'failure' do
43 it 'raises error with no values' do
44 pp = <<-EOS
45 $o = pick_default()
46 notice(inline_template('picked is <%= @o.inspect %>'))
47 EOS
48
49 apply_manifest(pp, :expect_failures => true) do |r|
50 expect(r.stderr).to match(/Must receive at least one argument/)
51 end
52 end
53 end
54end
Note: See TracBrowser for help on using the repository browser.