Skip to content

Commit

Permalink
ensure json file outputs a json file (#247)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
  • Loading branch information
chris-rock authored Jun 19, 2017
1 parent 0f9668c commit c329aa7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spec/unit/libraries/json_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

describe 'Reporter::JsonFile methods' do
it 'writes the report to a file on disk' do
report = 'some info'
report = { 'data' => 'some info' }
timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
expected_file_path = File.expand_path("inspec-#{timestamp}.json", File.dirname(__FILE__))
@jsonfile = Reporter::JsonFile.new({file: expected_file_path}).send_report(report)
expect(File).to exist("#{expected_file_path}")
# we sent a ruby hash and expect valid json in the file
content = JSON.parse(File.read expected_file_path)
expect(content).to eq(report)
File.delete("#{expected_file_path}")
end
end

0 comments on commit c329aa7

Please sign in to comment.