1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'parsejson function' do
6 it 'parses valid json' do
8 $a = '{"hunter": "washere", "tests": "passing"}'
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 'raises error on incorrect json' do
23 $a = '{"hunter": "washere", "tests": "passing",}'
24 $ao = parsejson($a, 'tests are using the default value')
25 notice(inline_template('a is <%= @ao.inspect %>'))
28 apply_manifest(pp, :catch_failures => true) do |r|
29 expect(r.stdout).to match(/tests are using the default value/)
33 it 'raises error on incorrect json' do
35 $a = '{"hunter": "washere", "tests": "passing",}'
37 notice(inline_template('a is <%= @ao.inspect %>'))
40 apply_manifest(pp, :expect_failures => true) do |r|
41 expect(r.stderr).to match(/expected next name/)
45 it 'raises error on incorrect number of arguments' do
50 apply_manifest(pp, :expect_failures => true) do |r|
51 expect(r.stderr).to match(/wrong number of arguments/i)