1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'parseyaml function' do
6 it 'parses valid yaml' do
8 $a = "---\nhunter: washere\ntests: passing\n"
11 notice(inline_template('tests are <%= @tests.inspect %>'))
14 apply_manifest(pp, :catch_failures => true) do |r|
15 expect(r.stdout).to match(/tests are "passing"/)
21 it 'returns the default value on incorrect yaml' do
23 $a = "---\nhunter: washere\ntests: passing\n:"
24 $o = parseyaml($a, {'tests' => 'using the default value'})
26 notice(inline_template('tests are <%= @tests.inspect %>'))
29 apply_manifest(pp, :catch_failures => true) do |r|
30 expect(r.stdout).to match(/tests are "using the default value"/)
34 it 'raises error on incorrect yaml' do
36 $a = "---\nhunter: washere\ntests: passing\n:"
39 notice(inline_template('tests are <%= @tests.inspect %>'))
42 apply_manifest(pp, :expect_failures => true) do |r|
43 expect(r.stderr).to match(/(syntax error|did not find expected key)/)
48 it 'raises error on incorrect number of arguments' do
53 apply_manifest(pp, :expect_failures => true) do |r|
54 expect(r.stderr).to match(/wrong number of arguments/i)