2016-03-25 00:31:19 +00:00
|
|
|
|
|
|
|
require 'functional/helper'
|
|
|
|
|
|
|
|
describe 'command tests' do
|
|
|
|
include FunctionalHelper
|
|
|
|
|
|
|
|
describe 'version' do
|
|
|
|
it 'provides the version number on stdout' do
|
|
|
|
out = inspec('version')
|
|
|
|
out.stderr.must_equal ''
|
|
|
|
out.exit_status.must_equal 0
|
2019-02-13 00:46:15 +00:00
|
|
|
# Tolerate working on an out of date branch
|
2019-02-21 01:44:25 +00:00
|
|
|
output = out.stdout.split("\n").reject { |l| l.start_with?('Your version of InSpec is out of date!') }.join("\n") + "\n"
|
2019-02-13 00:46:15 +00:00
|
|
|
output.must_equal Inspec::VERSION + "\n"
|
2016-03-25 00:31:19 +00:00
|
|
|
end
|
2017-05-17 13:41:38 +00:00
|
|
|
|
|
|
|
it 'prints the version as JSON when the format is specified as JSON' do
|
|
|
|
out = inspec('version --format=json')
|
|
|
|
out.stderr.must_equal ''
|
|
|
|
out.exit_status.must_equal 0
|
|
|
|
out.stdout.must_equal %({"version":"#{Inspec::VERSION}"}\n)
|
|
|
|
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)
|
2016-09-07 11:10:35 +00:00
|
|
|
out.stdout.must_match(/Valid.*true/)
|
2016-03-25 00:31:19 +00:00
|
|
|
out.exit_status.must_equal 0
|
|
|
|
end
|
|
|
|
end
|
2019-01-26 20:47:27 +00:00
|
|
|
|
|
|
|
describe 'help' do
|
2019-01-28 01:46:42 +00:00
|
|
|
let(:outputs) {
|
|
|
|
[
|
2019-01-26 20:47:27 +00:00
|
|
|
inspec('help').stdout,
|
|
|
|
inspec('--help').stdout,
|
|
|
|
inspec('').stdout,
|
|
|
|
]
|
2019-01-28 01:46:42 +00:00
|
|
|
}
|
2019-01-26 20:47:27 +00:00
|
|
|
|
2019-01-28 01:46:42 +00:00
|
|
|
it 'outputs the same message regardless of invocation' do
|
2019-01-26 20:47:27 +00:00
|
|
|
outputs.uniq.length.must_equal 1
|
|
|
|
end
|
2019-01-28 01:46:42 +00:00
|
|
|
|
|
|
|
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
|
2019-01-26 20:47:27 +00:00
|
|
|
end
|
2016-03-25 00:31:19 +00:00
|
|
|
end
|