rodjek / rspec-puppet

RSpec tests for your Puppet manifests
http://rspec-puppet.com
MIT License
364 stars 203 forks source link

rspec-puppet on puppet 6.17 breaks due to removal of default_env #796

Closed KeithWard closed 4 years ago

KeithWard commented 4 years ago

It looks like default_env was removed in puppet 6.17 - specifically in this commit:

https://github.com/puppetlabs/puppet/commit/94df3c1a3992d89b2d7d5db8a70373c135bdd86b

This results in an exceptiion similar to the following when rspec tries to run tests:

 Failure/Error: require 'puppetlabs_spec_helper/module_spec_helper'
 NameError:
   undefined local variable or method `default_env' for Puppet::Util:Module
 # ./vendor/bundle/ruby/2.5.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet/monkey_patches.rb:139:in `get_env'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:501:in `extralibs'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:76:in `initialize'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:43:in `new'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:43:in `create'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet.rb:240:in `base_context'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/test/test_helper.rb:53:in `initialize'
 # ./vendor/bundle/ruby/2.5.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:77:in `block in <top (required)>'
 # ./vendor/bundle/ruby/2.5.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:34:in `<top (required)>'
 # ./vendor/bundle/ruby/2.5.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `require'
 # ./vendor/bundle/ruby/2.5.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `<top (required)>'
 # ./spec/spec_helper.rb:7:in `require'
 # ./spec/spec_helper.rb:7:in `<top (required)>'

Not sure about what way to go about fixing this.

edestecd commented 4 years ago

Same on puppet 5.5.21

edestecd commented 4 years ago
An error occurred while loading ./spec/classes/profile_core_spec.rb.
 Failure/Error: require 'puppetlabs_spec_helper/module_spec_helper'
 NameError:
   undefined local variable or method `default_env' for Puppet::Util:Module
 # ./vendor/bundle/ruby/2.4.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet/monkey_patches.rb:139:in `get_env'
 # ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/node/environment.rb:512:in `extralibs'
 # ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/node/environment.rb:50:in `create'
 # ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet.rb:209:in `base_context'
 # ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/test/test_helper.rb:53:in `initialize'
 # ./vendor/bundle/ruby/2.4.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:77:in `block in <top (required)>'
 # ./vendor/bundle/ruby/2.4.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:34:in `<top (required)>'
 # ./vendor/bundle/ruby/2.4.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `require'
 # ./vendor/bundle/ruby/2.4.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `<top (required)>'
 # ./spec/spec_helper.rb:5:in `require'
 # ./spec/spec_helper.rb:5:in `<top (required)>'
 # ./spec/classes/profile_core_spec.rb:3:in `require'
 # ./spec/classes/profile_core_spec.rb:3:in `<top (required)>'
 No examples found.
 Finished in 0.00004 seconds (files took 1.57 seconds to load)
 0 examples, 0 failures, 1 error occurred outside of examples
nmaludy commented 4 years ago

+1 same problem here

sgnn7 commented 4 years ago

Got a quick fix for this up in a PR that hopefully someone from the maintainers can validate and/or improve since this is my first time dabbling in this repo: https://github.com/rodjek/rspec-puppet/pull/797

joshcooper commented 4 years ago

See also https://tickets.puppetlabs.com/browse/PUP-10586

dlucredativ commented 4 years ago

@sgnn7 @scotje was it intentional that 2.7.10 bases on 2.7.8 and not 2.7.9?

sgnn7 commented 4 years ago

was it intentional that 2.7.10 bases on 2.7.8 and not 2.7.9?

@dlucredativ I don't know enough about this gem to answer that - the fix is independent of the base version though

dlucredativ commented 4 years ago

was it intentional that 2.7.10 bases on 2.7.8 and not 2.7.9?

@dlucredativ I don't know enough about this gem to answer that - the fix is independent of the base version though

Ok it seems that you only created 73fbbe2f and @scotje cherry-picked it into b6807ebe. I just don't know why.

scotje commented 4 years ago

2.7.9 unintentionally included commits intended for 2.8.x (or 3.x) as they break some peoples existing tests. We yanked the 2.7.9 release and released 2.7.10 which is just 2.7.8 plus only the fix for default_env.