由于实现了custom types问题的答案,我能够使用rspec-puppet测试这。
但是,我希望避免在每个木偶模块中创建一个指向custom folder的符号链接,该链接由mocking cystom types编写。
问题是如何在Rspec-木偶中模拟自定义木偶类型。
我已经找到了一个关于自定义木偶Function的模拟的Function,但是我正在寻找一个例子来模拟木偶自定义Types。
伪码
class vim::ubuntu::config {
custom_multiple_files { 'line_numbers':
ensure => 'present',
parent_dir => '/home',
file_name => '.vimrc',
line => 'set number';
}
}Rspec-傀儡代码
require 'spec_helper'
describe "vim::ubuntu::config" do
?
end发布于 2014-04-14 23:28:04
一个寻找嘲讽例子的好地方是木偶自己的单元测试集合。
我不确定是否有需要考虑的特长,但在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)据我所知,这是明茶风格的嘲弄。在普通的rspec中,嘲弄/顽固性更多一些所涉及的,这对于rspec-puppet来说可能是必要的。
https://stackoverflow.com/questions/23060142
复制相似问题