I am fairly new to InSpec and just started testing a cookbook that installs a ruby using rvm. I first try to simply do:
describe command('ruby -v') do
it { should exist }
its('stdout') { should include ruby['ruby_version']}
end
This however failed. After some tinkering I discovered that I need to run the following for the test to succeed:
describe command('source /etc/profile && ruby -v') do
it { should exist }
its('stdout') { should include ruby['ruby_version']}
end
I wonder why this is needed? If this is indeed needed and not a erroneous assumption on my side: Is there any way to move that into a helper or even better run it once and have it persist?
EDIT:
This also seems to only work in the InSpec shell, but not when run using kitchen test
. When run this way it throws:
sudo: source: command not found\n
in stderr.
Thanks,
stiller-leser