我正在尝试为我的模块编写一些 rspec 测试。他们中的大多数人现在都在使用hiera。
我有一个 .fixures.yml:
fixtures:
repositories:
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
hiera-puppet: https://github.com/puppetlabs/hiera-puppet.git
symlinks:
mongodb: "#{source_dir}"
和一个 spec/classes/mongodb_spec.rb:
require 'spec_helper'
describe 'mongodb', :type => 'class' do
context "On an Ubuntu install, admin and single user" do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04'
}
end
it {
should contain_user('XXXX').with( { 'uid' => '***' } )
should contain_group('XXXX').with( { 'gid' => '***' } )
should contain_package('mongodb').with( { 'name' => 'mongodb' } )
should contain_service('mongodb').with( { 'name' => 'mongodb' } )
}
end
end
但是当我运行规范测试时,我得到:
# rake spec
/usr/bin/ruby1.8 -S rspec spec/classes/mongodb_spec.rb --color
F
Failures:
1) mongodb On an Ubuntu install, admin and single user
Failure/Error: should contain_user('XXXX').with( { 'uid' => '***' } )
LoadError:
no such file to load -- hiera_puppet
# ./spec/fixtures/modules/hiera-puppet/lib/puppet/parser/functions/hiera.rb:3:in `function_hiera'
# ./spec/classes/mongodb_spec.rb:15
Finished in 0.05415 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/classes/mongodb_spec.rb:14 # mongodb On an Ubuntu install, admin and single user
rake aborted!
/usr/bin/ruby1.8 -S rspec spec/classes/mongodb_spec.rb --color failed
Tasks: TOP => spec_standalone
(See full trace by running task with --trace)
模块规范测试相对较新,hiera 也是如此。到目前为止,我一直无法找到任何合适的解决方案。(关于 puppet-dev 的来回讨论很有趣,但没有帮助)。
我需要进行哪些更改才能使其正常工作?由于公司政策的原因,从 gem 安装 puppet 并破解 rubylib 并不是一个可行的解决方案。
我正在使用 Ubuntu 12.04 LTS + Puppet 2.7.17 + hiera 0.3.0。