I am trying to use the net/ssh gem to find an installed package into my Test-Kitchen instance. I do a simple recipe that reuse the build-essential cookbook.
It is my recipe:
node['my-cookbook']['packages'].each do |pkg|
package pkg
end
And these are my attributes:
default['my-cookbook']['packages'] = %w[build-essential git bison]
These are some steps into my feature definition for cucumber.
When(/^I ask for (.*)$/) do |package|
Net::SSH.start(@infrastructure['my-app'].ip,'vagrant', password: 'vagrant') do |ssh|
@out = ssh.exec!("dpkg --get-selections | grep #{package}")
end
end
Then(/^I should see (.*)$/) do |package_respond|
puts @out
@out.should match package_respond
end
When the instance converge, build-essential was installed and the cucumber test was succesful.
The output
puts @out
Was
grep: build-essential: No such file or directory
The test was succesful because the expresion matched. I was expecting
build-essential install
What happened here?? When a package is not installed the console respond with an empty string.
How can I inspect if an specific package was installed into my kitchen instance using the net/ssh gem?
My kithen instance is ubuntu 12.04.
Thanks.