source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/acceptance/try_get_value_spec.rb@ 30960

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

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper_acceptance'
3
4describe 'try_get_value function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5 describe 'success' do
6 it 'gets a value' do
7 pp = <<-EOS
8 $data = {
9 'a' => { 'b' => 'passing'}
10 }
11
12 $tests = try_get_value($data, 'a/b')
13 notice(inline_template('tests are <%= @tests.inspect %>'))
14 EOS
15
16 apply_manifest(pp, :catch_failures => true) do |r|
17 expect(r.stdout).to match(/tests are "passing"/)
18 end
19 end
20 end
21 describe 'failure' do
22 it 'uses a default value' do
23 pp = <<-EOS
24 $data = {
25 'a' => { 'b' => 'passing'}
26 }
27
28 $tests = try_get_value($data, 'c/d', 'using the default value')
29 notice(inline_template('tests are <%= @tests.inspect %>'))
30 EOS
31
32 apply_manifest(pp, :catch_failures => true) do |r|
33 expect(r.stdout).to match(/using the default value/)
34 end
35 end
36
37 it 'raises error on incorrect number of arguments' do
38 pp = <<-EOS
39 $o = try_get_value()
40 EOS
41
42 apply_manifest(pp, :expect_failures => true) do |r|
43 expect(r.stderr).to match(/wrong number of arguments/i)
44 end
45 end
46 end
47end
Note: See TracBrowser for help on using the repository browser.