simplecov-ruby / simplecov

Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites
MIT License
4.77k stars 553 forks source link

Missing model concerns in coverage #588

Closed dchersey closed 7 years ago

dchersey commented 7 years ago

I have a model concern that is included in a model that I have spec's for. Despite the fact that the code in this model is definitely exercised, I don't see the model in my coverage results.

I am using 14.1, and my spec_helper looks like:

require 'factory_girl'
require 'simplecov'
require 'simplecov-cobertura'

SimpleCov.formatters = [
  SimpleCov::Formatter::CoberturaFormatter,
  SimpleCov::Formatter::HTMLFormatter
]

SimpleCov.at_exit do
  SimpleCov.result.format!
end

SimpleCov.coverage_dir(ENV["COVERAGE_REPORTS_DIR"]) if ENV['COVERAGE_REPORTS_DIR']
SimpleCov.start do
  add_filter "/vendor/"
  add_filter "/config/*"
  add_filter "/spec/*"
end

I have tried eager-loading (and this resulted in no files being included), and also defining a filter group both as a path (no files), an absolute path (no files), and a block. When I used the block, I logged each file being considered and simplecov never even asked whether the model concern files should be included; it is as if they did not exist.

My model concerns are in app/models/concerns where they should be.

What else can I try?

Thanks!

PragTob commented 7 years ago

:wave:

Thanks a lot for the bug report! That is... weird. The one think that seems a bit strange to me is why you have a custom at_exit block?

The rest looks fairly standard and should work.

have you tried starting simplecov with the "rails" parameter or adding the following to the config: track_files "{app,lib}/**/*.rb" ? :)

If that also fails, an example project is always the easiest debugging help :D

Thanks for the bug report!

dchersey commented 7 years ago

Thanks!

SimpleCov.start "rails"

did the trick!

PragTob commented 7 years ago

Great then :rocket: