我安装了 simplecov gem 并添加了

require 'simplecov'
SimpleCov.start

到 spec_helper.rb 文件,现在如果我在 some_file_spec.rb 文件中包含 spec_helper.rb 并尝试运行它,我会得到这个
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuratio
n.rb:116:in `require': no such file to load -- rspec/core/mocking/with_rspec (Lo
adError)
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core
/configuration.rb:116:in `mock_framework'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core
/configuration.rb:376:in `configure_mock_framework'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core
/command_line.rb:19:in `run'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core
/runner.rb:55:in `run_in_process'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core
/runner.rb:46:in `run'
        from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core
/runner.rb:10:in `block in autorun'
Coverage report generated for c:/Ruby192/bin/rspec player_spec.rb to c:/Users/Ko
Le/Documents/NetBeansProjects/CHCGame/spec/coverage. 0.0% covered.

没有 simplecov 一切正常,但我需要我的 ruby​​ 类的代码覆盖率数据。
在此先感谢您提供的任何提示。我在win7 32下工作

最佳答案

我似乎通过删除 rspec 并将 rspec 和 simplecov 捆绑安装来解决了这个问题。希望这有助于某人

关于ruby rspec 不适用于 simplecov,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5434614/

10-16 16:07