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

前端之家收集整理的这篇文章主要介绍了linux – 如何使用serverspec测试文件缺失?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
serverspec guide on resource types没有解释如何测试文件的缺失,而不是它的存在.这是我能想到的最好的:
  1. describe command('/bin/bash -c "[[ ! -e /var/foo ]]"') do
  2. its(:exit_status) { should eq 0 }
  3. end

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

  1. describe file('/var/foo') do
  2. it { should_not be_file }
  3. it { should_not be_directory }
  4. it { should_not be_socket }
  5. it { should_not be_symlink }
  6. end

有一个更好的方法吗?

解决方法

serverspec文件对象现在响应.exists ?,所以这适用:
  1. describe file('/var/foo') do
  2. it { should_not exist }
  3. end

serverspec v2.17.0中的功能was added.

猜你在找的Linux相关文章