如何使用serverspectesting文件缺失?

有关资源types的serverspec指南没有解释如何testing缺less文件,而不是testing它的存在。 这是我能想到的最好的:

describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do its(:exit_status) { should eq 0 } end 

这似乎非常笨重,但比利用内置的更好:

 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 

有一个更好的方法吗?

serverspec File对象现在响应.exists? ,所以这工作:

 describe file('/var/foo') do it { should_not exist } end 

该function已添加到serverspec v2.17.0。