I have a puppet cookbook rspec sample test like below
it {
is_expected.to contain_file('/etc/resolv.conf')
.with(
'ensure' => 'file',
'owner' => 'root',
'group' => 'root',
'mode' => '0444',
'validate_cmd' => '/var/tmp/checkdns_nameservers.sh',
)
.with_content(resolvconf_contents)
.that_notifies('Service[sshd]')
.that_notifies('Service[nscd]')
}
The problem is that this just checks the existence of validate_cmd in the manifest.
I have to mock the validate_cmd function and returns true/false and Based on that I have to check the contents of the file newly created. How can I mock the validate_cmd command using rspec module ? Any help would be highly appreciated !!