serverspec - 可以'should_be_owned_by'检查多个所有者

时间:2015-12-17 00:41:48

标签: serverspec

我是ServerSpec,Rspec,ruby的新手,所以对可用语法的细节知之甚少。我想写一个类似的测试:

describe file("foo") do
    it { should_be_owned_by 'bill' or 'ted' }
end

该测试运行但似乎只检查第一个所有者而不是第二个。

是否存在可能存在多个可接受值的标准方法?

由于

1 个答案:

答案 0 :(得分:0)

我在the official file documentation找不到它,但你可以在那里使用 grep 正则表达式模式:

describe file('foo') do
  it { should_be_owned_by 'bill\|ted' }
end

自RSpec 3.0起,您还可以使用.or to make compound expectations

describe file('foo') do
  it { should be_owned_by('bill').or be_owned_by('ted') }
end
相关问题