Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chef infra Inspec测试多个实体_Chef Infra_Inspec - Fatal编程技术网

Chef infra Inspec测试多个实体

Chef infra Inspec测试多个实体,chef-infra,inspec,Chef Infra,Inspec,我正在为我的厨师食谱编写inspec测试,其中有5个文件需要测试它们的模式。它们都应具有相同的模式0755 describe file('/dev') do its('mode') { should cmp '00755' } end 这是我用的sytax。但这只测试1个文件(/dev)。是否可以使用单个测试块测试多个文件?它并不完全是“单个测试块”,但您可以迭代文件列表: %w(/dev /tmp).each do |path| describe file(path) its(

我正在为我的厨师食谱编写inspec测试,其中有5个文件需要测试它们的模式。它们都应具有相同的模式0755

describe file('/dev') do
 its('mode') { should cmp '00755' }
end

这是我用的sytax。但这只测试1个文件(/dev)。是否可以使用单个测试块测试多个文件?

它并不完全是“单个测试块”,但您可以迭代文件列表:

%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