serverspec - can 'should_be_owned_by' chec

2019-08-12 17:10发布

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

标签: serverspec
1条回答
成全新的幸福
2楼-- · 2019-08-12 17:40

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
查看更多
登录 后发表回答