summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-11-30 16:23:08 -0800
committerPete Higgins <pete@peterhiggins.org>2020-12-01 16:12:04 -0800
commit3615e74f34bb872dadad72aeb0644569b32ed640 (patch)
treea5cc211deafb6b3b81d8a4d0bf180e9f42717dd0
parent59d5ae6941533799649eeee9b28f46ac010e516e (diff)
downloadchef-3615e74f34bb872dadad72aeb0644569b32ed640.tar.gz
Simplify integration test input and make output deterministic.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--spec/integration/audit/audit_spec.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/spec/integration/audit/audit_spec.rb b/spec/integration/audit/audit_spec.rb
index b562e608ab..98776308de 100644
--- a/spec/integration/audit/audit_spec.rb
+++ b/spec/integration/audit/audit_spec.rb
@@ -23,19 +23,18 @@ describe "chef-client with audit mode" do
let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai" }
when_the_repository "has a custom profile" do
+ let(:report_file) { path_to("report_file.json") }
+
before do
directory "profiles/my-profile" do
file "inspec.yml", <<~FILE
---
name: my-profile
- title: a minimal profile
FILE
directory "controls" do
file "my_control.rb", <<~FILE
control "my control" do
- title "Home directory exists"
- impact 0.0
describe Dir.home do
it { should be_kind_of String }
end
@@ -47,7 +46,9 @@ describe "chef-client with audit mode" do
file "attributes.json", <<~FILE
{
"audit": {
- "reporter": ["json-file"],
+ "json_file": {
+ "location": "#{report_file}"
+ },
"profiles": {
"my-profile": {
"path": "#{path_to("profiles/my-profile")}"
@@ -62,7 +63,7 @@ describe "chef-client with audit mode" do
result = shell_out!("#{chef_client} --local-mode --json-attributes #{path_to("attributes.json")}", cwd: chef_dir)
result.error!
- inspec_report = JSON.parse(File.read(Dir["#{Chef::Config[:cache_path]}/audit_reports/audit-*.json"].last))
+ inspec_report = JSON.parse(File.read(report_file))
expect(inspec_report["profiles"].length).to eq(1)
profile = inspec_report["profiles"].first