0
我正在用InSpec創建我的測試。這是我對Apache的測試:如何使用InSpec創建上下文?
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
我會想在輸出中包括家庭風味或版本或拱,以瞭解和獲得更清晰的輸出,我的測試。
有什麼建議嗎?
我認爲你正在尋找'control'請參閱[文檔](http://inspec.io/docs/reference/dsl_inspec/) – Tensibai