我正在使用 InSpec 创建测试。这是我对 Apache 的测试:
require 'inspec'
if os[:family] == 'redhat'
describe package 'httpd' do
it { should be_installed }
end
describe service 'httpd' do
it { should be_enabled }
it { should be_running }
end
describe file '/etc/httpd/conf/httpd.conf' do
it { should be_file }
end
end
describe port(80) do
it { should_not be_listening }
end
describe port(9000) do
it { should be_listening }
end
我的问题与上下文有关。在使用 InSpec 之前,我使用 ChefSpec,我喜欢您如何创建上下文并且输出显示您的上下文。对于上面的示例,输出是这样的:
System Package
✔ httpd should be installed
Service httpd
✔ should be enabled
✔ should be running
File /etc/httpd/conf/httpd.conf
✔ should be file
Port 80
✔ should not be listening
Port 9000
✔ should be listening
我想在输出中包含家庭风味或版本或拱门,以便了解并为我的测试获得更清晰的输出。
有什么建议吗?