rspec-由于 gem 不可用,人偶测试失败
rspec-puppet testing fails due to unavailable gems
我正在尝试为 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
谁能帮我设置一下?
您需要 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,这可能对您有所帮助。
我正在尝试为 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
谁能帮我设置一下?
您需要 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,这可能对您有所帮助。