1 require 'spec_helper_acceptance'
3 describe 'parsejson function' do
6 $a = '{"hunter": "washere", "tests": "passing"}'
9 notice(inline_template('tests are <%= @tests.inspect %>'))
11 it 'parses valid json' do
12 apply_manifest(pp1, :catch_failures => true) do |r|
13 expect(r.stdout).to match(%r{tests are "passing"})
20 $a = '{"hunter": "washere", "tests": "passing",}'
21 $ao = parsejson($a, 'tests are using the default value')
22 notice(inline_template('a is <%= @ao.inspect %>'))
24 it 'raises error on incorrect json - default value is used' do
25 apply_manifest(pp2, :catch_failures => true) do |r|
26 expect(r.stdout).to match(%r{tests are using the default value})
31 $a = '{"hunter": "washere", "tests": "passing",}'
33 notice(inline_template('a is <%= @ao.inspect %>'))
35 it 'raises error on incorrect json' do
36 apply_manifest(pp3, :expect_failures => true) do |r|
37 expect(r.stderr).to match(%r{expected next name})
44 it 'raises error on incorrect number of arguments' do
45 apply_manifest(pp4, :expect_failures => true) do |r|
46 expect(r.stderr).to match(%r{wrong number of arguments}i)