simplecov
                                
                                 simplecov copied to clipboard
                                
                                    simplecov copied to clipboard
                            
                            
                            
                        running rake with .simplecov and rspec runs coverage report twice, second report at 0%
Project is Rails 5.x with rspec.
When configuring simplecov via spec/rails_helper.rb like this:
require 'simplecov'
SimpleCov.start 'rails'
running rake results in the expected behavior of simplecov generating a report once.
If I change the rails_helper.rb config to just:
require 'simplecov'
And use a .simplecov config file like this:
SimpleCov.start 'rails'
The coverage report is generated twice. The first report is as expected, but then gets overwritten by the second report, which displays 0% coverage for all classes.
If I just run rspec instead of rake, then only one genuine coverage report is generated.
Thanks for the report! You don't happen to have an example repository to reproduce this, do you? :)
@PragTob Yes, a Rails app that exhibits this behavior is here:
https://github.com/osu-cascades/ecotone-web/tree/simplecov-581
Steps to reproduce:
- git clone [email protected]:osu-cascades/ecotone-web.git
- git checkout simplecov-581
- rpec
- Notice that one coverage report was generated.
- rake
- Notice that two coverage reports were generated. The original, and the second at 0% coverage, which overwrites the first.
Files to notice:
Thank you!
@ybakos thank you very much for creating a sample to reproduce this error! :heart:
Sadly, I won't get into working on it too soon I fear :| Maybe one of the others can or PRs are also welcome, time is tight right now. This should speedup the process a lot though :rocket:
@ybakos (and others interested) - the Gemfile line should be
gem 'simplecov', require: false
In your Gemfile it is
gem 'simplecov'
@ivanovv Thank you, but this doesn't seem to solve the described issue.
Gemfile:
gem 'simplecov', require: false
rails_helper.rb:
require 'simplecov'
# ...
.simplecov:
SimpleCov.start 'rails' do
  add_filter "application_cable"
  add_filter "jobs"
end
Running rake causes the coverage report to be generated twice, with the second overwriting the first and reporting 0% coverage.
See the description here:
https://github.com/infertux/bashcov/commit/26177e0024bf89f01c6c2fd0dc603004dba03bb0