Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running rake with .simplecov and rspec runs coverage report twice, second report at 0% #581

Open
ybakos opened this issue May 16, 2017 · 6 comments

Comments

@ybakos
Copy link

ybakos commented May 16, 2017

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.

@PragTob
Copy link
Collaborator

PragTob commented May 17, 2017

Thanks for the report! You don't happen to have an example repository to reproduce this, do you? :)

@ybakos
Copy link
Author

ybakos commented May 19, 2017

@PragTob Yes, a Rails app that exhibits this behavior is here:

https://github.com/osu-cascades/ecotone-web/tree/simplecov-581

Steps to reproduce:

  1. git clone git@github.com:osu-cascades/ecotone-web.git
  2. git checkout simplecov-581
  3. rpec
  4. Notice that one coverage report was generated.
  5. rake
  6. Notice that two coverage reports were generated. The original, and the second at 0% coverage, which overwrites the first.

Files to notice:

Thank you!

@PragTob
Copy link
Collaborator

PragTob commented May 29, 2017

@ybakos thank you very much for creating a sample to reproduce this error! ❤️

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 🚀

@ivanovv
Copy link

ivanovv commented Aug 28, 2017

@ybakos (and others interested) - the Gemfile line should be

gem 'simplecov', require: false

In your Gemfile it is

gem 'simplecov'

@ybakos
Copy link
Author

ybakos commented Aug 30, 2017

@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.

ybakos added a commit to osu-cascades/ecotone-web that referenced this issue Aug 30, 2017
See simplecov-ruby/simplecov#581 (comment)
This doesn't really solve the issue, but I'm doing it anyway.
@ybakos
Copy link
Author

ybakos commented Aug 2, 2019

See the description here:

infertux/bashcov@26177e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants