Ruby Chef Minitest检查文件内容
我想在chef minitest中检查文件的内容 示例文件:Ruby Chef Minitest检查文件内容,ruby,unit-testing,chef-infra,minitest,Ruby,Unit Testing,Chef Infra,Minitest,我想在chef minitest中检查文件的内容 示例文件: THIS IS A TEST ################# ## DO NOT FIND ## ################# FIND THIS AND THIS 现在我想验证这个文件的内容。我使用了一个示例,目前正在执行以下操作: # = Checking file content = it "will check the file" do file('/tmp/foo') .must_include '
THIS IS A TEST
#################
## DO NOT FIND ##
#################
FIND THIS
AND THIS
现在我想验证这个文件的内容。我使用了一个示例,目前正在执行以下操作:
# = 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
请不要忘记将答案标记为正确!:)完成。很抱歉。