You can use a cycle.
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
Question
I would like to check the content of a file in my chef minitest.
Example File:
THIS IS A TEST
#################
## DO NOT FIND ##
#################
FIND THIS
AND THIS
Now I want to verify the content of this file. I used default_test.rb has an example, and am currently doing the following:
# = 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
There has got to be a better and cleaner solutions, than chaining it like so. Anyone know?
Solution
You can use a cycle.
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