In Ruby, * is used to represent the name of a file.
For example, /home/user/*.rb will return all files ending with .rb. I want to do something similar in Chef InSpec.
For example:
describe file ('home/user/*') do
it {should_not exist }
end
It should give me all the files inside /home/user directory and check that no file exists inside this directory. In other words, I want to check if this directory is empty or not in Chef.
How can I do that?
* for globs is mostly a shell feature, and as you might expect the file resource doesn't support them. Use a command resource instead:
describe command('ls /home/user') do
its(:stdout) { is_expected.to eq "\n" }
end