mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
rename json to minijson and fulljson to json
This commit is contained in:
parent
b14495051a
commit
8258d111ef
5 changed files with 19 additions and 19 deletions
|
@ -21,7 +21,7 @@ end
|
|||
|
||||
# Minimal JSON formatter for inspec. Only contains limited information about
|
||||
# examples without any extras.
|
||||
class InspecRspecJson < RSpec::Core::Formatters::JsonFormatter
|
||||
class InspecRspecMiniJson < RSpec::Core::Formatters::JsonFormatter
|
||||
RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :close
|
||||
|
||||
def dump_summary(summary)
|
||||
|
@ -71,7 +71,7 @@ class InspecRspecJson < RSpec::Core::Formatters::JsonFormatter
|
|||
end
|
||||
end
|
||||
|
||||
class InspecRspecFullJson < InspecRspecJson
|
||||
class InspecRspecJson < InspecRspecMiniJson
|
||||
RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :close
|
||||
|
||||
def add_profile(profile)
|
||||
|
|
|
@ -33,7 +33,7 @@ module Inspec
|
|||
# @return [nil]
|
||||
def add_profile(profile)
|
||||
RSpec.configuration.formatters
|
||||
.find_all { |c| c.is_a? InspecRspecFullJson }
|
||||
.find_all { |c| c.is_a? InspecRspecJson }
|
||||
.each do |fmt|
|
||||
fmt.add_profile(profile)
|
||||
end
|
||||
|
@ -82,9 +82,9 @@ module Inspec
|
|||
end
|
||||
|
||||
FORMATTERS = {
|
||||
'json-min' => 'InspecRspecMiniJson',
|
||||
'json' => 'InspecRspecJson',
|
||||
'fulljson' => 'InspecRspecFullJson',
|
||||
'rspecjson' => 'InspecRspecVanilla',
|
||||
'json-rspec' => 'InspecRspecVanilla',
|
||||
}.freeze
|
||||
|
||||
# Configure the output formatter and stream to be used with RSpec.
|
||||
|
|
|
@ -4,25 +4,25 @@
|
|||
|
||||
require 'functional/helper'
|
||||
|
||||
describe 'inspec exec with fulljson formatter' do
|
||||
describe 'inspec exec with json formatter' do
|
||||
include FunctionalHelper
|
||||
|
||||
it 'can execute a simple file with the fulljson formatter' do
|
||||
out = inspec('exec ' + example_control + ' --format fulljson')
|
||||
it 'can execute a simple file with the json formatter' do
|
||||
out = inspec('exec ' + example_control + ' --format json')
|
||||
out.stderr.must_equal ''
|
||||
out.exit_status.must_equal 0
|
||||
JSON.load(out.stdout).must_be_kind_of Hash
|
||||
end
|
||||
|
||||
it 'can execute the profile with the fulljson formatter' do
|
||||
out = inspec('exec ' + example_profile + ' --format fulljson')
|
||||
it 'can execute the profile with the json formatter' do
|
||||
out = inspec('exec ' + example_profile + ' --format json')
|
||||
out.stderr.must_equal ''
|
||||
out.exit_status.must_equal 0
|
||||
JSON.load(out.stdout).must_be_kind_of Hash
|
||||
end
|
||||
|
||||
describe 'execute a profile with fulljson formatting' do
|
||||
let(:json) { JSON.load(inspec('exec ' + example_profile + ' --format fulljson').stdout) }
|
||||
describe 'execute a profile with json formatting' do
|
||||
let(:json) { JSON.load(inspec('exec ' + example_profile + ' --format json').stdout) }
|
||||
let(:profile) { json['profiles']['profile'] }
|
||||
let(:controls) { profile['controls'] }
|
||||
let(:ex1) { controls['tmp-1.0'] }
|
||||
|
@ -110,7 +110,7 @@ describe 'inspec exec with fulljson formatter' do
|
|||
end
|
||||
|
||||
describe 'with a profile that is not supported on this OS/platform' do
|
||||
let(:out) { inspec('exec ' + File.join(profile_path, 'skippy-profile-os') + ' --format fulljson') }
|
||||
let(:out) { inspec('exec ' + File.join(profile_path, 'skippy-profile-os') + ' --format json') }
|
||||
let(:json) { JSON.load(out.stdout) }
|
||||
|
||||
# TODO: failure handling in json formatters...
|
|
@ -22,8 +22,8 @@ describe 'inspec exec' do
|
|||
out.stdout.must_include '1 example, 0 failures'
|
||||
end
|
||||
|
||||
it 'can execute the profile with the json formatter' do
|
||||
out = inspec('exec ' + example_profile + ' --format json')
|
||||
it 'can execute the profile with the mini json formatter' do
|
||||
out = inspec('exec ' + example_profile + ' --format json-min')
|
||||
out.stderr.must_equal ''
|
||||
out.exit_status.must_equal 0
|
||||
JSON.load(out.stdout).must_be_kind_of Hash
|
||||
|
@ -36,15 +36,15 @@ describe 'inspec exec' do
|
|||
out.stdout.must_include '2 examples, 0 failures'
|
||||
end
|
||||
|
||||
it 'can execute a simple file with the json formatter' do
|
||||
out = inspec('exec ' + example_control + ' --format json')
|
||||
it 'can execute a simple file with the mini json formatter' do
|
||||
out = inspec('exec ' + example_control + ' --format json-min')
|
||||
out.stderr.must_equal ''
|
||||
out.exit_status.must_equal 0
|
||||
JSON.load(out.stdout).must_be_kind_of Hash
|
||||
end
|
||||
|
||||
describe 'execute a profile with json formatting' do
|
||||
let(:json) { JSON.load(inspec('exec ' + example_profile + ' --format json').stdout) }
|
||||
describe 'execute a profile with mini json formatting' do
|
||||
let(:json) { JSON.load(inspec('exec ' + example_profile + ' --format json-min').stdout) }
|
||||
let(:controls) { json['controls'] }
|
||||
let(:ex1) { controls.find{|x| x['id'] == 'tmp-1.0'} }
|
||||
let(:ex2) { controls.find{|x| x['id'] =~ /generated/} }
|
||||
|
|
Loading…
Add table
Reference in a new issue