|
2 | 2 |
|
3 | 3 | require 'spec_helper_acceptance'
|
4 | 4 |
|
5 |
| -describe 'Emitting JSON' do |
| 5 | +describe 'Generating JSON' do |
6 | 6 | let(:test_module_path) do
|
7 | 7 | sut_module_path(%r{Module test})
|
8 | 8 | end
|
|
50 | 50 | }
|
51 | 51 | end
|
52 | 52 |
|
53 |
| - [ |
54 |
| - { title: '--format json and STDOUT', cmd_line: '--format json' }, |
55 |
| - { title: '--emit-json-stdout', cmd_line: '--emit-json-stdout' }, |
56 |
| - ].each do |testcase| |
57 |
| - it "emits JSON to stdout when using #{testcase[:title]}" do |
58 |
| - output = run_shell("puppet strings generate #{testcase[:cmd_line]} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"").stdout.chomp |
59 |
| - expect(JSON.parse(output)).to eq(expected) |
60 |
| - end |
| 53 | + it 'renders JSON to stdout when using --format json' do |
| 54 | + output = run_shell("puppet strings generate --format json \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"").stdout.chomp |
| 55 | + expect(JSON.parse(output)).to eq(expected) |
61 | 56 | end
|
62 | 57 |
|
63 |
| - [ |
64 |
| - { title: '--format json and --out', cmd_line: '--format json --out "TMPFILE"' }, |
65 |
| - { title: '--emit-json', cmd_line: '--emit-json "TMPFILE"' }, |
66 |
| - ].each do |testcase| |
67 |
| - it "writes JSON to a file when using #{testcase[:title]}" do |
68 |
| - tmpfile = File.join(remote_tmp_path, 'json_output.json') |
69 |
| - cmd = "puppet strings generate #{testcase[:cmd_line].gsub('TMPFILE', tmpfile)} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"" |
70 |
| - run_shell(cmd) |
71 |
| - output = JSON.parse(file(tmpfile).content) |
72 |
| - expect(output).to eq(expected) |
73 |
| - end |
| 58 | + it 'writes JSON to a file when using --format json --out' do |
| 59 | + tmpfile = File.join(remote_tmp_path, 'json_output.json') |
| 60 | + run_shell("puppet strings generate --format json --out #{tmpfile} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"") |
| 61 | + output = JSON.parse(file(tmpfile).content) |
| 62 | + expect(file(tmpfile)).to contain expected |
74 | 63 | end
|
75 | 64 | end
|
0 commit comments