Inspec 测试多个实体
Inspec test multiple entities
我正在为我的厨师食谱编写 inspec 测试,其中有 5 个文件需要测试其模式。他们都应该有相同的模式 0755.
describe file('/dev') do
its('mode') { should cmp '00755' }
end
这是我正在使用的语法。但这只测试 1 个文件 (/dev)。是否可以使用单个测试块测试多个文件?
不完全是 'single test block',但您可以遍历文件列表:
%w(/dev /tmp).each do |path|
describe file(path)
its(:mode) { should cmp '00755' }
end
end
您可以使用 ruby 代码来测试多个实体
dirs = ["/lib","/bin","/dev"]
dirs.each do |path|
describe file(path) do
its('type') { should eq :directory }
it { should be_directory }
end
end
我正在为我的厨师食谱编写 inspec 测试,其中有 5 个文件需要测试其模式。他们都应该有相同的模式 0755.
describe file('/dev') do
its('mode') { should cmp '00755' }
end
这是我正在使用的语法。但这只测试 1 个文件 (/dev)。是否可以使用单个测试块测试多个文件?
不完全是 'single test block',但您可以遍历文件列表:
%w(/dev /tmp).each do |path|
describe file(path)
its(:mode) { should cmp '00755' }
end
end
您可以使用 ruby 代码来测试多个实体
dirs = ["/lib","/bin","/dev"]
dirs.each do |path|
describe file(path) do
its('type') { should eq :directory }
it { should be_directory }
end
end