我正在尝试使用rspec-puppet测试custom_type。
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
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
puppet --version
3.4.3
Eclipse上的自定义模块
结果
Rspec-puppet找不到自定义类型custom_multiple_files
,而puppet能够在木偶运行期间找到并执行自定义类型。
答案 0 :(得分:4)
您需要在spec / fixtures / module文件夹中包含模块的副本。您还可以使用符号链接将spec / fixtures / module中的引用添加到custom_type_module。
答案 1 :(得分:2)
模块根目录下的示例.fixtures.yml文件:
---
fixtures:
repositories:
concat:
repo: 'git://github.com/puppetlabs/puppetlabs-concat.git'
ref: '1.0.0'
stdlib:
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '3.2.0'
symlinks:
keepalived: "#{source_dir}"
请务必加入"要求' puppetlabs_spec_helper / rake_tasks'"在你的Rakefile中并调整上述路径/ repos /模块名称。