InSpec describe file with file names created during run time


#1

I have a cookbook that generates .err files. The file names contain time stamp and change for each kitchen converge. The files should be 0 size when no errors.

Is there a way to use describe file or other resources in this case?


#2

@Victor you can use plain ruby around describe blocks:

['/tmp/file'].each { |filename|
  describe file(filename) do
    it { should exist }
    it { should be_file }
  end
}

you could easily determine various files and loop arounds those:

files = command('find /tmp/*').stdout.split
files.each { |filename|
  describe file(filename) do
    it { should exist }
    it { should be_file }
  end
}

Let me know if that was helpful


#3

Thanks chris-rock. It’s very helpful.