rspec Error

215 views
Skip to first unread message

Afroz Hussain

unread,
Mar 25, 2015, 9:35:47 AM3/25/15
to puppet...@googlegroups.com
Hi All,

I am currently using 3.7.4 version of puppet and tried setting up rspec(http://rspec-puppet.com/ )  to run some test cases. I have installed ruby 2.2.0 with the help of rvm but still getting below errors:

# cd /etc/puppet/modules/apache/
# rspec spec/classes/apache_spec.rb
/usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/hooks.rb:512:in `all_hooks_for': return from proc-closure (LocalJumpError)
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/hooks.rb:564:in `process'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/flat_map.rb:11:in `map'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/flat_map.rb:11:in `flat_map'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/hooks.rb:563:in `process'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/hooks.rb:429:in `register_globals'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/example_group.rb:394:in `set_it_up'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/example_group.rb:361:in `subclass'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/example_group.rb:253:in `describe'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/dsl.rb:43:in `__send__'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/dsl.rb:43:in `describe'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/dsl.rb:82:in `__send__'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/dsl.rb:82:in `describe'
        from /etc/puppet/modules/apache/spec/classes/apache_spec.rb:3
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in `load'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in `load_spec_files'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224:in `each'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:97:in `setup'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:85:in `run'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:70:in `run'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:38:in `invoke'
        from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.2.2/exe/rspec:4
        from /usr/bin/rspec:19:in `load'
     
Any help will be appreciated!!!

Thanks,
Afroz Hussain

Garrett Honeycutt

unread,
Mar 25, 2015, 11:24:52 AM3/25/15
to puppet...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/1c47e572-b756-45fe-95e9-bf251d5bfeef%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/1c47e572-b756-45fe-95e9-bf251d5bfeef%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Hi Afroz,

Looks like you are not using ruby v2.2.0 as rspec is looking in
'/usr/lib/ruby/gems/1.8'. Be sure to run `rvm use 2.2.0` before running
rspec and familiarize yourself with bundler.

Also ruby v2.2.0 is not supported by v3.7, so you might want to run
rspec with v2.1.0.

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

Afroz Hussain

unread,
Apr 14, 2015, 7:53:14 AM4/14/15
to puppet...@googlegroups.com

Hi Garrett,

Thank you very much for your response.

I am getting below errors after changing 2.1.0 :

ruby -S rspec spec/classes/init_spec.rb
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- puppet (LoadError)
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /usr/local/rvm/gems/ruby-2.1.0/gems/rspec-puppet-2.0.1/lib/rspec-puppet.rb:1:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `require'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        from /etc/puppet/modules/aetos/spec/spec_helper.rb:1:in `<top (required)>'

I have reverted the changes since puppet is not working. I have listed out installed gems which might give you some hint and I am using puppet-3.6.2 this time and still getting old errors.

Any help will be appreciated.

Thanks,
Afroz Hussain

Afroz Hussain

unread,
Apr 14, 2015, 7:55:28 AM4/14/15
to puppet...@googlegroups.com
Sorry Missed to post the installed gems:

*** LOCAL GEMS ***

colored (1.2)
cri (2.6.1)
diff-lcs (1.2.5)
faraday (0.8.9)
faraday_middleware (0.9.1)
faraday_middleware-multi_json (0.0.6)
hiera (1.3.4)
hiera-puppet (1.0.0)
json (1.5.5)
json_pure (1.8.1)
kwalify (0.7.2)
log4r (1.1.10)
metaclass (0.0.4)
mocha (1.1.0)
multi_json (1.8.4)
multipart-post (1.2.0)
net-scp (1.2.1)
net-ssh (2.9.1)
passenger (5.0.6)
puppet-lint (1.1.0)
puppet-syntax (2.0.0)
puppetlabs_spec_helper (0.10.1)
r10k (1.4.0)
rack (1.6.0)
rake (10.4.2)
rspec (3.2.0, 2.99.0)
rspec-core (3.2.2, 3.1.7, 2.99.2)
rspec-expectations (3.2.0, 3.1.2, 2.99.2)
rspec-mocks (3.2.1, 3.1.3, 2.99.2)
rspec-puppet (2.0.1, 1.0.1)
rspec-support (3.2.2, 3.1.2)
rubygems-update (2.4.6)
semver (1.0.1)
systemu (2.6.4, 2.5.2)



On Wednesday, 25 March 2015 19:05:47 UTC+5:30, Afroz Hussain wrote:

Garrett Honeycutt

unread,
Apr 14, 2015, 6:25:32 PM4/14/15
to puppet...@googlegroups.com
Hi Afroz,

You are missing the puppet gem. Suggest creating a Gemfile[1] and using
bundler.

[1] - https://github.com/ghoneycutt/puppet-module-pam/blob/master/Gemfile

Afroz Hussain

unread,
Apr 15, 2015, 8:38:07 AM4/15/15
to puppet...@googlegroups.com
Hi Garrett,

Thanks for your prompt support.

I have configured fresh puppet master and setup rspec. I got the some luck but all the test cases are failing:

apache]# bundle exec rake spec
/usr/bin/ruby -I/usr/local/share/gems/gems/rspec-core-3.2.3/lib:/usr/local/share/gems/gems/rspec-support-3.2.2/lib /usr/local/share/gems/gems/rspec-core-3.2.3/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color
F
Failures:
  1) apache The main class should be present in the catalog should contain Class[apache]
     Failure/Error: should contain_class('apache')
     Puppet::Error:
       Could not find class apache for hostname on node hostname
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:220:in `block in evaluate_classes'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:219:in `collect'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:219:in `evaluate_classes'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/functions/include.rb:31:in `block in <top (required)>'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/functions.rb:164:in `block (2 levels) in newfunction'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util/profiler.rb:51:in `profile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/functions.rb:157:in `block in newfunction'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/ast/function.rb:42:in `evaluate'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/ast.rb:61:in `safeevaluate'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/ast/block_expression.rb:11:in `block in evaluate'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/ast/block_expression.rb:10:in `each'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/ast/block_expression.rb:10:in `evaluate'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/ast.rb:61:in `safeevaluate'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/resource/type.rb:127:in `evaluate_code'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/resource.rb:79:in `evaluate'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:425:in `evaluate_main'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:131:in `block (2 levels) in compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util/profiler.rb:51:in `profile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:131:in `block in compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/context.rb:64:in `override'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet.rb:244:in `override'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:117:in `compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/parser/compiler.rb:34:in `compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/indirector/catalog/compiler.rb:95:in `block (2 levels) in compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util/profiler.rb:51:in `profile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/indirector/catalog/compiler.rb:93:in `block in compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util.rb:161:in `block in benchmark'
     # /usr/share/ruby/benchmark.rb:296:in `realtime'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/util.rb:160:in `benchmark'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/indirector/catalog/compiler.rb:92:in `compile'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/indirector/catalog/compiler.rb:52:in `find'
     # /usr/local/share/gems/gems/puppet-3.7.5/lib/puppet/indirector/indirection.rb:201:in `find'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/support.rb:162:in `build_catalog_without_cache'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/support.rb:171:in `build_catalog'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/support.rb:21:in `load_catalogue'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/example/class_example_group.rb:7:in `catalogue'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/support.rb:7:in `block in subject'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/matchers/create_generic.rb:82:in `call'
     # /usr/local/share/gems/gems/rspec-puppet-2.0.1/lib/rspec-puppet/matchers/create_generic.rb:82:in `matches?'
     # ./spec/classes/init_spec.rb:5:in `block (3 levels) in <top (required)>'

Finished in 0.05202 seconds (files took 0.41678 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/classes/init_spec.rb:4 # apache The main class should be present in the catalog should contain Class[apache]
/usr/bin/ruby -I/usr/local/share/gems/gems/rspec-core-3.2.3/lib:/usr/local/share/gems/gems/rspec-support-3.2.2/lib /usr/local/share/gems/gems/rspec-core-3.2.3/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color failed

apache]# more manifests/init.pp
class apache {
}

# spec/classes/init_spec.rb
require 'spec_helper'
describe 'apache', :type => 'class' do
        context 'The main class should be present in the catalog' do
    it {
         should contain_class('apache')
    }
  end

end


Reply all
Reply to author
Forward
0 new messages