inspec/test/functional/inspec_test.rb

79 lines
1.5 KiB
Ruby
Raw Normal View History

require "functional/helper"
2016-03-25 00:31:19 +00:00
describe "command tests" do
2016-03-25 00:31:19 +00:00
include FunctionalHelper
describe "version" do
it "provides the version number on stdout" do
out = inspec("version")
out.stdout.must_equal Inspec::VERSION + "\n"
out.stderr.must_equal ""
assert_exit_code 0, out
2016-03-25 00:31:19 +00:00
end
it "prints the version as JSON when the format is specified as JSON" do
out = inspec("version --format=json")
out.stdout.must_equal %({"version":"#{Inspec::VERSION}"}\n)
out.stderr.must_equal ""
assert_exit_code 0, out
end
2016-03-25 00:31:19 +00:00
end
describe "check" do
it "verifies that a profile is ok" do
out = inspec("check " + example_profile)
out.stdout.must_match(/Valid.*true/)
out.stderr.must_equal ""
assert_exit_code 0, out
2016-03-25 00:31:19 +00:00
end
end
describe "help" do
let(:outputs) do
[
inspec("help").stdout,
inspec("--help").stdout,
inspec("").stdout,
]
end
it "outputs the same message regardless of invocation" do
outputs.uniq.length.must_equal 1
end
it "outputs both core commands and v2 CLI plugins" do
commands = %w{
archive
artifact
check
compliance
detect
env
exec
habitat
help
init
json
plugin
shell
supermarket
vendor
version
}
outputs.each do |output|
commands.each do |subcommand|
output.must_include("inspec " + subcommand)
end
end
end
end
2016-03-25 00:31:19 +00:00
end