本文介绍了如何使用 Rspec-puppet 测试自定义类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 rspec-puppet 测试 custom_type.
I am trying to test a custom_type using rspec-puppet.
傀儡代码
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
it do
should contain_custom_multiple_files('line_numbers').with({
'ensure' => 'present',
'parent_dir' => '/home',
'file_name' => '.vimrc',
'line' => 'set number',
})
end
end
结果
2) vim::ubuntu::config
Failure/Error: })
Puppet::Error:
Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource
type custom_multiple_files at /etc/puppet/modules/vim/spec/fixtures/modules
/vim/manifests/ubuntu/config.pp:7 on node ...
# ./spec/classes/ubuntu_config_spec.rb:10
人偶版
puppet --version
3.4.3
Eclipse 中的自定义模块
结果
Rspec-puppet 找不到自定义类型 custom_multiple_files
,而 puppet 能够在 puppet 运行期间找到并执行自定义类型.
Rspec-puppet cannot find the custom type custom_multiple_files
, while puppet is able to find and execute the custom type during a puppet run.
推荐答案
你需要在你的 spec/fixtures/module 文件夹中有一个模块的副本.您还可以使用符号链接将 spec/fixtures/module 中的引用添加到 custom_type_module.
You'll need to have a copy of your module in your spec/fixtures/module folder. You can also use a symlink to add a reference from spec/fixtures/module to your custom_type_module.
参考:https://github.com/rodjek/rspec-puppet/issues/84
这篇关于如何使用 Rspec-puppet 测试自定义类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!