我想通过实施以下example来衡量代码覆盖率Rspec-puppet。
我已将at_exit { RSpec::Puppet::Coverage.report! }
添加到./spec/classes/init_spec.rb
文件的末尾。
init_spec.rb
require 'spec_helper'
describe "vim" do
let(:facts) { { :operatingsystem => 'Ubuntu' } }
it { should contain_class('vim::ubuntu')}
end
at_exit { RSpec::Puppet::Coverage.report! }
运行rspec
会导致:
/etc/puppet/modules/vim/spec/classes/init_spec.rb:12: uninitialized constant RSpec::Puppet::Coverage (NameError)
rake spec
导致:
rake aborted!
no such file to load -- ace
/usr/lib/ruby/vendor_ruby/rake/application.rb:357:in `require'
/usr/lib/ruby/vendor_ruby/rake/application.rb:357:in `standard_rake_options'
/usr/lib/ruby/1.8/optparse.rb:1298:in `call'
/usr/lib/ruby/1.8/optparse.rb:1298:in `parse_in_order'
/usr/lib/ruby/1.8/optparse.rb:1254:in `catch'
/usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'
/usr/lib/ruby/1.8/optparse.rb:1248:in `order!'
/usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'
/usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'
/usr/lib/ruby/vendor_ruby/rake/application.rb:425:in `handle_options'
/usr/lib/ruby/vendor_ruby/rake/application.rb:74:in `init'
/usr/lib/ruby/vendor_ruby/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:72:in `init'
/usr/lib/ruby/vendor_ruby/rake/application.rb:64:in `run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:63:in `run'
/usr/bin/rake:27
答案 0 :(得分:1)
请注意Puppet Labs' rspec-puppet
的{{3}}已过时一年多了。覆盖率代码目前仅在作者的github fork中找到。
从该回购中提取master
可能足以解决您的问题。