inspec/test/artifact/artifact_helper.rb
Ryan Davis 947365719a Fix artifact-habitat testing for inspec.
Needed a fallback on `ENV["project_root"]` not being defined.

Signed-off-by: Ryan Davis <zenspider@chef.io>
2020-02-10 18:34:00 -08:00

24 lines
574 B
Ruby

require "minitest/autorun"
require "open3"
TEST_CLI_OPTS = "--chef-license=accept-no-persist".freeze
class ArtifactTest < Minitest::Test
make_my_diffs_pretty!
def run_cmd(cmd)
env = { "PATH" => ENV["PATH"] }
pwd = ENV["project_root"] || `git rev-parse --show-toplevel`.chomp
opts = { chdir: pwd }
Open3.capture3(env, cmd, opts)
end
def assert_artifact(inspec_command)
stdout, stderr, status = run_cmd "inspec #{inspec_command} #{TEST_CLI_OPTS}"
assert_empty stderr.sub(/#< CLIXML\n/, "")
assert stdout
assert status
end
end