2019-06-11 22:24:35 +00:00
|
|
|
require "functional/helper"
|
2016-03-25 00:31:19 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "command tests" do
|
2016-03-25 00:31:19 +00:00
|
|
|
include FunctionalHelper
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "version" do
|
|
|
|
it "provides the version number on stdout" do
|
|
|
|
out = inspec("version")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-09-30 22:31:55 +00:00
|
|
|
_(out.stdout).must_equal Inspec::VERSION + "\n"
|
|
|
|
_(out.stderr).must_equal ""
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out
|
2016-03-25 00:31:19 +00:00
|
|
|
end
|
2017-05-17 13:41:38 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "prints the version as JSON when the format is specified as JSON" do
|
|
|
|
out = inspec("version --format=json")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-09-30 22:31:55 +00:00
|
|
|
_(out.stdout).must_equal %({"version":"#{Inspec::VERSION}"}\n)
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-09-30 22:31:55 +00:00
|
|
|
_(out.stderr).must_equal ""
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out
|
2017-05-17 13:41:38 +00:00
|
|
|
end
|
2016-03-25 00:31:19 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "check" do
|
|
|
|
it "verifies that a profile is ok" do
|
|
|
|
out = inspec("check " + example_profile)
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-09-30 22:31:55 +00:00
|
|
|
_(out.stdout).must_match(/Valid.*true/)
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-09-30 22:31:55 +00:00
|
|
|
_(out.stderr).must_equal ""
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out
|
2016-03-25 00:31:19 +00:00
|
|
|
end
|
|
|
|
end
|
2019-01-26 20:47:27 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "help" do
|
|
|
|
let(:outputs) do
|
2019-01-28 01:46:42 +00:00
|
|
|
[
|
2019-06-11 22:24:35 +00:00
|
|
|
inspec("help").stdout,
|
|
|
|
inspec("--help").stdout,
|
|
|
|
inspec("").stdout,
|
2019-01-26 20:47:27 +00:00
|
|
|
]
|
2019-06-11 22:24:35 +00:00
|
|
|
end
|
2019-01-26 20:47:27 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "outputs the same message regardless of invocation" do
|
2019-09-30 22:31:55 +00:00
|
|
|
_(outputs.uniq.length).must_equal 1
|
2019-01-26 20:47:27 +00:00
|
|
|
end
|
2019-01-28 01:46:42 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "outputs both core commands and v2 CLI plugins" do
|
2019-01-28 01:46:42 +00:00
|
|
|
commands = %w{
|
|
|
|
archive
|
|
|
|
artifact
|
|
|
|
check
|
|
|
|
compliance
|
2021-05-07 11:12:18 +00:00
|
|
|
automate
|
2019-01-28 01:46:42 +00:00
|
|
|
detect
|
|
|
|
env
|
|
|
|
exec
|
|
|
|
habitat
|
|
|
|
help
|
|
|
|
init
|
|
|
|
json
|
|
|
|
plugin
|
|
|
|
shell
|
|
|
|
supermarket
|
|
|
|
vendor
|
|
|
|
version
|
|
|
|
}
|
|
|
|
outputs.each do |output|
|
|
|
|
commands.each do |subcommand|
|
2021-05-07 11:12:18 +00:00
|
|
|
_(output).must_include(subcommand)
|
2019-01-28 01:46:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-09-18 09:19:24 +00:00
|
|
|
|
|
|
|
it "has an About section" do
|
|
|
|
outputs.each do |output|
|
|
|
|
_(output).must_include("About Chef InSpec")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "mentions Chef's patents" do
|
|
|
|
outputs.each do |output|
|
|
|
|
_(output).must_include("Patents: chef.io/patents")
|
|
|
|
end
|
|
|
|
end
|
2019-01-26 20:47:27 +00:00
|
|
|
end
|
2016-03-25 00:31:19 +00:00
|
|
|
end
|