我正在尝试为rspec-puppet测试编写测试。
该模块具有以下树:
|-- manifests
| `-- test_file.pp
|-- Rakefile
`-- spec
|-- classes
|-- defines
| `-- test_file_spec.rb
|-- fixtures
| |-- manifests
| | `-- site.pp
| `-- modules
| `-- test
| |-- files -> ../../../../files
| |-- lib -> ../../../../lib
| |-- manifests -> ../../../../manifests
| `-- templates -> ../../../../templates
|-- functions
|-- hosts
`-- spec_helper.rb
当我运行“rake rspec”
时,我收到以下错误(in /etc/puppetlabs/puppet/modules/offshore/test)
rake aborted!
no such file to load -- rspec/core/rake_task
/etc/puppetlabs/puppet/modules/offshore/test/Rakefile:2
(See full trace by running task with --trace)
当我运行“rake spec --trace”时,它提供以下内容:
rake aborted!
no such file to load -- rspec/core/rake_task
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/etc/puppetlabs/puppet/modules/offshore/test/Rakefile:2
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2382:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2382:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2067:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2015:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1999:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2067:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1997:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
有人可以帮我设置吗?
答案 0 :(得分:0)
您需要Gemfile
在模块的根目录中包含以下内容:
source 'http://rubygems.org'
group :test do
gem 'rake'
gem 'puppet', ENV['PUPPET_VERSION'] || '~> 3.4.0'
gem 'puppet-lint'
gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git'
gem 'puppet-syntax'
gem 'puppetlabs_spec_helper'
gem 'simplecov'
gem 'metadata-json-lint'
end
然后运行bundle install
然后运行bundle exec rake spec
还有一个有用的工具puppet-retrospec
会自动将规格添加到现有模块中:https://github.com/logicminds/puppet-retrospec,这可能对您有帮助。