1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'try_get_value function' do
9 'a' => { 'b' => 'passing'}
12 $tests = try_get_value($data, 'a/b')
13 notice(inline_template('tests are <%= @tests.inspect %>'))
16 apply_manifest(pp, :catch_failures => true) do |r|
17 expect(r.stdout).to match(/tests are "passing"/)
22 it 'uses a default value' do
25 'a' => { 'b' => 'passing'}
28 $tests = try_get_value($data, 'c/d', 'using the default value')
29 notice(inline_template('tests are <%= @tests.inspect %>'))
32 apply_manifest(pp, :catch_failures => true) do |r|
33 expect(r.stdout).to match(/using the default value/)
37 it 'raises error on incorrect number of arguments' do
42 apply_manifest(pp, :expect_failures => true) do |r|
43 expect(r.stderr).to match(/wrong number of arguments/i)