我有一个木偶食谱 rspec 示例测试,如下所示
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]')
}
问题是这只是检查清单中是否存在 validate_cmd 。
我必须模拟 validate_cmd 函数并返回 true/false,基于此我必须检查新创建的文件的内容。如何使用 rspec 模块模拟 validate_cmd 命令?任何帮助将不胜感激!