linux – 如何使用serverspec测试文件缺失?

serverspec guide on resource types没有解释如何测试文件的缺失,而不是它的存在.这是我能想到的最好的:
describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do
  its(:exit_status) { should eq 0 }
end

这似乎非常笨重,但比leveraging the builtins更好:

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文件对象现在响应.exists ?,所以这适用:
describe file('/var/foo') do
  it { should_not exist }
end

serverspec v2.17.0中的功能was added.

相关文章

linux常用进程通信方式包括管道(pipe)、有名管道(FIFO)、...
Linux性能观测工具按类别可分为系统级别和进程级别,系统级别...
本文详细介绍了curl命令基础和高级用法,包括跳过https的证书...
本文包含作者工作中常用到的一些命令,用于诊断网络、磁盘占满...
linux的平均负载表示运行态和就绪态及不可中断状态(正在io)的...
CPU上下文频繁切换会导致系统性能下降,切换分为进程切换、线...