Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken coverage rake task. #10

Merged
merged 1 commit into from
Jul 2, 2012
Merged

Conversation

mafalb
Copy link
Contributor

@mafalb mafalb commented Jun 9, 2012

$ rake coverage
...
/Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/puppetlabs_spec/matchers.rb:8:in alias_method': undefined methodshould' for module `RSpec::Matchers::BlockAliases' (NameError)
from /Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/puppetlabs_spec/matchers.rb:8
...

$ rake coverage
(in /Users/mafalb/puppet/modules/mdraid)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S rcov -Ispec:lib --exclude spec ./spec/classes/mdmonitor_off_spec.rb ./spec/classes/mdmonitor_spec.rb ./spec/classes/mdraid_rm_spec.rb ./spec/classes/mdraid_spec.rb
/Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/puppetlabs_spec/matchers.rb:8:in `alias_method': undefined method `should' for module `RSpec::Matchers::BlockAliases' (NameError)
	from /Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/puppetlabs_spec/matchers.rb:8
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/puppetlabs_spec_helper.rb:12
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/puppet_spec_helper.rb:1
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/puppetlabs_spec_helper-0.1.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
	from ./spec/spec_helper.rb:2
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from ./spec/classes/mdmonitor_off_spec.rb:25
	from /Library/Ruby/Gems/1.8/gems/rcov-1.0.0/bin/rcov:539:in `load'
	from /Library/Ruby/Gems/1.8/gems/rcov-1.0.0/bin/rcov:539
	from /usr/bin/rcov:19:in `load'
	from /usr/bin/rcov:19
rake aborted!
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S rcov -Ispec:lib --exclude spec ./spec/classes/mdmonitor_off_spec.rb ./spec/classes/mdmonitor_spec.rb ./spec/classes/mdraid_rm_spec.rb ./spec/classes/mdraid_spec.rb failed

(See full trace by running task with --trace)
@mafalb mafalb closed this Jun 9, 2012
@mafalb mafalb reopened this Jun 9, 2012
@justinstoller
Copy link
Member

This error is because the puppetlabs_spec_helper/module_spec_helper is requiring the puppetlabs_spec_helper/puppet_spec_helper which is requiring the puppetlabs_spec_helper/puppetlabs_spec_helper which depends on RSpec already being loaded to work properly. It is specifically failing because puppetlabs_spec_helper/puppetlabs_spec_helper requires puppetlabs_spec_helper/puppetlabs_spec_helper/matchers which is also needs RSpec loaded. Your patch works because it pulls in rspec-puppet, which will pull in RSpec.... I think it would be best to make that underlying dependency explicit, ie require 'rspec' at the top of puppetlabs_spec_helper/puppetlabs_spec_helper.

Also, if you're looking at the dependency chain puppetlabs_spec_helper/puppet_spec_helper should require puppetlabs_spec_helper/puppetlabs_spec_helper after it requires its other dependencies. And puppetlabs_spec_helper/puppet_spec_helper doesn't need to require 'puppetlabs_spec_helper/puppetlabs_spec/files' because it will be required by puppetlabs_spec_helper/puppetlabs_spec_helper, I think.

@branan
Copy link

branan commented Jun 27, 2012

It is probably quite true that the correct fix is to refactor the requires a bit more.. I'd personally be happy to see this get merged in so that at least the task isn't broken.

justinstoller added a commit that referenced this pull request Jul 2, 2012
fix broken coverage rake task.
@justinstoller justinstoller merged commit f01b026 into puppetlabs:master Jul 2, 2012
@chelnak chelnak added the bug label Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants