Obligatory sorry if I'm being a noob but... I'm pretty new to rspec/ruby etc and I'm struggling to figure a few things out. Given the following rspec-puppet snippet:
if os == 'Ubuntu'
let(:facts) do
{
architecture: 'amd64',
operatingsystem: 'Ubuntu',
}
end
it { is_expected.to contain_service('docker').with_hasrestart('true') }
context 'It should include default prerequired_packages' do
it { is_expected.to contain_package('cgroup-lite').with_ensure('present') }
it { is_expected.to contain_package('apparmor').with_ensure('present') }
end
end
We've got these functions(objects?) like contain_service() and contain_package() that seem to have methods like with_hasrestart and with_ensure. What I'm trying to understand is, what are these functions? Are they part of rspec-puppet? I can't seem to find them in GitHub, and the docs don't really explain it. I'm trying to find all the available methods for each to better understand this all - and the source code would be great. Can anyone offer up some info/docs that explain it please?
Many thanks,
Dave
Edit: Looks like I didn't RTFM enough. It appears these are "matchers" and searching for contain_package in the code would never work.
Answering my own post, but I doubt anyone will actually need this.
These are "matchers", specifically a generic one here. They're part of the
rspec-puppetpackage: https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/matchers/create_generic.rbYou can essentially do
contain_<puppet resource>and those methods likewith_ensureare likewith_<resource parameter>.