【问题标题】:Checking non existing file with serverspec使用 serverspec 检查不存在的文件
【发布时间】:2015-03-23 10:18:49
【问题描述】:

我是使用 serverspec 编写测试的新人。我真的很喜欢它,因为它清晰而快速。但是我发现了一个问题。 可以使用文件类型检查文件是否不存在?我尝试在任何地方添加not!,但似乎不起作用。

目前我可以使用以下方法实现预期的行为:

describe command('ls /etc/myfile') do
      its(:stderr) { should match /No such file or directory/ }
end

但我想通过以下方式使其更清洁:

describe file ('/etc/myfile') do
  it { not should be file }
end

有人知道吗?谢谢

【问题讨论】:

    标签: ruby integration-testing


    【解决方案1】:

    'should_not' 期望是您正在寻找的:

      describe file ('/etc/myfile') do
        it { should_not be_a_file }
      end
    

    【讨论】:

    • 谢谢,这绝对是我要找的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 2017-10-02
    • 2016-06-29
    相关资源
    最近更新 更多