serverspec - can 'should_be_owned_by' check multiple owners

和自甴很熟 提交于 2019-12-11 10:35:13

问题


I'm new to ServerSpec, Rspec, ruby so don't have much knowledge of the specifics of the grammar available. I'd like to write a test that does something like:

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

That test runs but seems to only check the first owner and not the second.

Is there a standard way to perform a test where there may be multiple acceptable values?

Thanks


回答1:


I can not find it in the official file documentation, but you can use a grep regular expression pattern there:

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

Since RSpec 3.0 you can also use .or to make compound expectations:

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


来源:https://stackoverflow.com/questions/34324797/serverspec-can-should-be-owned-by-check-multiple-owners

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!