|
13 | 13 | end |
14 | 14 |
|
15 | 15 | context 'with correct JSON data' do |
| 16 | + it 'is able to parse JSON this is a null' do |
| 17 | + is_expected.to run.with_params('null').and_return(nil) |
| 18 | + end |
| 19 | + |
| 20 | + it 'is able to parse JSON that is a string' do |
| 21 | + is_expected.to run.with_params('"a string"').and_return('a string') |
| 22 | + end |
| 23 | + |
16 | 24 | it 'is able to parse JSON data with a Hash' do |
17 | 25 | is_expected.to run.with_params('{"a":"1","b":"2"}') |
18 | 26 | .and_return('a' => '1', 'b' => '2') |
|
49 | 57 |
|
50 | 58 | context 'with incorrect JSON data' do |
51 | 59 | it 'raises an error with invalid JSON and no default' do |
52 | | - is_expected.to run.with_params('') |
53 | | - .and_raise_error(PSON::ParserError) |
| 60 | + is_expected.to run.with_params('error') |
| 61 | + .and_raise_error(Puppet::Util::Json::ParseError) |
54 | 62 | end |
55 | 63 |
|
56 | 64 | it 'supports a structure for a default value' do |
57 | 65 | is_expected.to run.with_params('', 'a' => '1') |
58 | 66 | .and_return('a' => '1') |
59 | 67 | end |
60 | 68 |
|
61 | | - ['', 1, 1.2, nil, true, false, [], {}, :yaml].each do |value| |
| 69 | + [1, 1.2, nil, true, false, [], {}, :yaml].each do |value| |
62 | 70 | it "returns the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do |
63 | 71 | is_expected.to run.with_params(value, 'default_value') |
64 | 72 | .and_return('default_value') |
|
0 commit comments