我想在我的主厨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
必须有一个比这样链接起来更好,更干净的解决方案。有人知道吗
您可以使用一个循环。
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句