如何衡量代码覆盖率Rspec-Puppet

时间:2014-04-14 12:50:58

标签: tdd code-coverage puppet

我想通过实施以下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

1 个答案:

答案 0 :(得分:1)

请注意Puppet Labs' rspec-puppet的{​​{3}}已过时一年多了。覆盖率代码目前仅在作者的github fork中找到。

从该回购中提取master可能足以解决您的问题。