我想检查我的 Chef 迷你测试中的文件内容。
示例文件:
THIS IS A TEST
#################
## DO NOT FIND ##
#################
FIND THIS
AND THIS
现在我想验证这个文件的内容。我用过default_test.rb有一个示例,目前正在执行以下操作:
# = Checking file content =
it "will check the file" do
file('/tmp/foo')
.must_include 'THIS IS A TEST'
file('/tmp/foo')
.must_include 'FIND THIS'
file('/tmp/foo')
.must_include 'FIND THIS'
end
必须有一个比这样链接更好、更干净的解决方案。有人知道吗?
最佳答案
您可以使用循环。
it "has the rights lines in /tmp/foo" do
['THIS IS A TEST', 'FIND THIS', 'AND THIS'].each do |line|
file('/tmp/foo').must_include line
end
end
关于ruby - Chef Minitest 检查文件的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20546996/