我想查看我的厨师minitest中文件的内容。
示例文件:
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
必须有一个更好,更清洁的解决方案,而不是像这样链接它。谁知道?
答案 0 :(得分:2)
你可以使用一个循环。
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