厨师Minitest检查文件的内容

时间:2013-12-12 15:05:54

标签: ruby unit-testing chef minitest

我想查看我的厨师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

必须有一个更好,更清洁的解决方案,而不是像这样链接它。谁知道?

1 个答案:

答案 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
相关问题