如何正确设置puppet-rspec?

时间:2015-06-19 01:18:00

标签: unit-testing rspec puppet rspec-puppet

我按照here

的说明操作
gem install rvm
gem install bundle

# Demo dir

# Gemfile
source "https://rubygems.org"

gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper',  :require => false
gem 'puppet', '~> 3.7.5'
gem 'rspec-puppet-facts'

# spec_helper.rb
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts     

现在,当我运行bundle exec rake spec时,我收到以下错误:

/usr/bin/ruby -I/usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib:/usr/lib/ruby/gems/1.8/gems/rspec-support-3.3.0/lib /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color

Total resources:   0
Touched resources: 0
Resource coverage:  -nan%
Untouched resources:


/usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:516:in `all_hooks_for': return from proc-closure (LocalJumpError)
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:568:in `process'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/flat_map.rb:12:in `map'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/flat_map.rb:12:in `flat_map'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:567:in `process'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:433:in `register_globals'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/example_group.rb:395:in `set_it_up'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/example_group.rb:362:in `subclass'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/example_group.rb:254:in `describe'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:43:in `__send__'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:43:in `describe'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:82:in `__send__'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:82:in `describe'
    from /etc/puppet/modules/demo/spec/classes/example_spec.rb:3
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1327:in `load'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1327:in `load_spec_files'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1325:in `each'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:102:in `setup'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:88:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:73:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:41:in `invoke'
    from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/exe/rspec:4
/usr/bin/ruby -I/usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib:/usr/lib/ruby/gems/1.8/gems/rspec-support-3.3.0/lib /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color failed

有关如何解决这个问题的任何想法?或者有人可以提供一些明确的说明,说明如何在CentOS 6.5机器上运行它?

1 个答案:

答案 0 :(得分:1)

Gemfile更新为以下内容并运行bundle update

source 'https://rubygems.org'

if puppetversion = ENV['PUPPET_GEM_VERSION']
  gem 'puppet', puppetversion, :require => false
else
  gem 'puppet', '3.7.5' 
end


gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
gem 'rspec-puppet-facts' 


# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
  gem 'rspec', '~> 2.0'
end