You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm the author of a gem called ruby-marc-spec that for domain-nomenclature reasons, has a main module called MARC::Spec, with source in a corresponding directory lib/marc/spec.
I recently noticed that SimpleCov was only covering the root file, lib/marc/spec.rb, and ignoring all the files under lib/marc/spec.
Coverage task fails with Coverage (99.87%) is below the expected minimum coverage (100.00%).
Generated HTML report in artifacts/rcov includes all source files under lib, including lib/marc/spec/queries/query_executor.rb, which has an uncovered line 47.
Actual
Coverage task suceeds.
Generated HTML report shows only lib/marc/spec.rb, with 100% coverage.
Discussion
The issue is with the filters in test_frameworks.rb, plain strings which each produce a StringFilter that will check for the presence of the substring anywhere in the file path. A regex filter, e.g. %r{^/spec/}, would instead exclude these directories only at the root of the project, which seems to be the intent.
(I also wonder about the similar bundler_filter.rb, but that one seems less likely to produce accidental false positives.)
Workarounds
In my case, the test_frameworks profile was being pulled in by the rails profile, which I didn't need (lazy cut-and-paste from a Rails project). I dropped back to the default profile and added a custom regex filter for the /spec directory to my .simplecov:
Summary
I'm the author of a gem called ruby-marc-spec that for domain-nomenclature reasons, has a main module called
MARC::Spec
, with source in a corresponding directorylib/marc/spec
.I recently noticed that SimpleCov was only covering the root file,
lib/marc/spec.rb
, and ignoring all the files underlib/marc/spec
.Steps to reproduce
0.1.1
.bundle install
.bundle exec rake coverage
.Expected
Coverage (99.87%) is below the expected minimum coverage (100.00%).
artifacts/rcov
includes all source files underlib
, includinglib/marc/spec/queries/query_executor.rb
, which has an uncovered line 47.Actual
lib/marc/spec.rb
, with 100% coverage.Discussion
The issue is with the filters in
test_frameworks.rb
, plain strings which each produce aStringFilter
that will check for the presence of the substring anywhere in the file path. A regex filter, e.g.%r{^/spec/}
, would instead exclude these directories only at the root of the project, which seems to be the intent.(I also wonder about the similar
bundler_filter.rb
, but that one seems less likely to produce accidental false positives.)Workarounds
In my case, the
test_frameworks
profile was being pulled in by therails
profile, which I didn't need (lazy cut-and-paste from a Rails project). I dropped back to the default profile and added a custom regex filter for the/spec
directory to my.simplecov
:Another workaround for a Rails user would be to explicitly remove the
"/spec/"
filter (or whichever other problem filter):System info
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin21]
The text was updated successfully, but these errors were encountered: