diff --git a/files/default/handler/audit_report.rb b/files/default/handler/audit_report.rb index 8622be75..0733269d 100644 --- a/files/default/handler/audit_report.rb +++ b/files/default/handler/audit_report.rb @@ -174,7 +174,7 @@ def send_report(reporter, server, user, profiles, report) Chef::Log.warn "unable to determine chef-server url required by inspec report collector '#{reporter}'. Skipping..." end elsif reporter == 'json-file' - timestamp = Time.now.utc.to_s.tr(' ', '_') + timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S') Collector::JsonFile.new(report, timestamp).send_report else Chef::Log.warn "#{reporter} is not a supported InSpec report collector" diff --git a/spec/unit/libraries/json_file_spec.rb b/spec/unit/libraries/json_file_spec.rb index 6bef2e8e..f18a72cd 100644 --- a/spec/unit/libraries/json_file_spec.rb +++ b/spec/unit/libraries/json_file_spec.rb @@ -9,10 +9,10 @@ describe 'Collector::JsonFile methods' do it 'writes the report to a file on disk' do report = 'some info' - timestamp = Time.now.utc.to_s.tr(' ', '_') + timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S') @jsonfile = Collector::JsonFile.new(report, timestamp).send_report expected_file_path = File.expand_path("../../../../inspec-#{timestamp}.json", __FILE__) expect(File).to exist("#{expected_file_path}") File.delete("#{expected_file_path}") end -end \ No newline at end of file +end