关于资源类型的serverspec 指南没有解释如何测试文件的缺失,而不是它的存在。这是我能想到的最好的:
describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do
its(:exit_status) { should eq 0 }
end
Run Code Online (Sandbox Code Playgroud)
这看起来非常笨拙,但比利用内置函数要好:
describe file('/var/foo') do
it { should_not be_file }
it { should_not be_directory }
it { should_not be_socket }
it { should_not be_symlink }
end
Run Code Online (Sandbox Code Playgroud)
有一个更好的方法吗?