ruby rspec wont work with simplecov

2019-07-05 06:13发布

问题:

I installed simplecov gem and added

require 'simplecov'  
SimpleCov.start

to the spec_helper.rb file, now if i include spec_helper.rb in my some_file_spec.rb file and try to run it i get this

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.

Everything works fine without the simplecov, but i need the code coverage data for my ruby class. Thanks in advance for any tips you can give me on this. I work under win7 32

回答1:

I seem to have solved this by removing rspec and doing a bundle install of rspec and simplecov together. Hope this helps someone



回答2:

add simplecov gem in gemfile and do bundle install.I think this will solve the problem



回答3:

Verify you are using the needed gemset