我是使用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
有人有任何想法吗?感谢
答案 0 :(得分:1)
'should_not'期望正是您所期待的:
describe file ('/etc/myfile') do
it { should_not be_a_file }
end