由于实施了this问题的答案,我可以使用custom types
对rspec-puppet
进行测试。
但是,我想避免在custom folder
mocking
的每个木偶模块中为cystom types
创建符号链接。
问题是如何在Rspec-Puppet中模拟自定义木偶类型。
我找到了关于模仿自定义木偶Function
的{{3}},但我正在寻找一个模拟Puppet Custom Types
的示例。
Puppet Code
class vim::ubuntu::config {
custom_multiple_files { 'line_numbers':
ensure => 'present',
parent_dir => '/home',
file_name => '.vimrc',
line => 'set number';
}
}
Rspec-puppet代码
require 'spec_helper'
describe "vim::ubuntu::config" do
?
end
答案 0 :(得分:2)
寻找嘲笑示例的好地方是Puppet自己的unit tests的集合。
我不确定是否有需要考虑的专业,但在Puppet的规范测试中,模拟效果如下:
let(:type) { Puppet::Type.type(:custom_file_line) }
it "should do whatever"
type.stubs(:retrieve).returns <value>
# perhaps also needed
Puppet::Type.stubs(:type).with(:custom_file_line).returns(type)
据我所知,这是moccha风格嘲弄。在普通的rspec中,模拟/存根多了involved,rspec-puppet
可能需要这样做。