2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/reporters"
|
2018-05-31 17:42:09 +00:00
|
|
|
|
|
|
|
describe Inspec::Reporters::Yaml do
|
2022-02-07 11:27:45 +00:00
|
|
|
RUBY3_PLUS = Gem.ruby_version >= Gem::Version.new("3.0")
|
|
|
|
|
2018-05-31 17:42:09 +00:00
|
|
|
let(:report) do
|
2019-11-09 03:08:20 +00:00
|
|
|
data = YAML.load_file("test/fixtures/reporters/run_data.yml")
|
2018-05-31 17:42:09 +00:00
|
|
|
Inspec::Reporters::Yaml.new({ run_data: data })
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "#render" do
|
|
|
|
it "confirm render output" do
|
2022-05-05 00:17:10 +00:00
|
|
|
if ( windows? || darwin? ) && RUBY3_PLUS
|
|
|
|
# On Ruby 3+, empty scalar values are generated without a trailing space
|
2022-02-07 11:27:45 +00:00
|
|
|
# this affects the title: and desc: fields
|
2022-05-05 00:17:10 +00:00
|
|
|
output = File.read("test/fixtures/reporters/yaml_output_ruby3plus")
|
2022-02-07 11:27:45 +00:00
|
|
|
else
|
|
|
|
output = File.read("test/fixtures/reporters/yaml_output")
|
|
|
|
end
|
|
|
|
|
2018-05-31 17:42:09 +00:00
|
|
|
report.render
|
2019-09-30 22:31:55 +00:00
|
|
|
_(report.rendered_output).must_equal output
|
2018-05-31 17:42:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|