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
option to disable line warnings with enable_coverage_for_eval
and rails views
#1057
Comments
I am experiencing this too and am in favor of the ENV var fix. |
I'm also seeing this since enabling Silencing them could work in the meantime but hopefully a better solution that correctly identifies the # of lines for |
I think that the problem is with only one line, require "erb"
example = "hello <%= 'world' %>"
compiler = ERB.new(example)
puts compiler.src get =>
this will then be executed from eval, src is 2 lines, coverage 1 I suppose that if you have nested renders in the same view you will have one line per nested template added to the total count of lines that will be evalueted, but i'm not sure. |
Couldn't find an issue that was directly related to this, please forgive me if I've overlooked something.
Love
enable_coverage_for_eval
since that allows getting coverage metrics for rails views, which was something that until Ruby 3.2, you had to do without. However, turning it on results in a lot of warnings, relative to this method in lib/simplecov/source_file.rb:Reviewing Issue#56, it wasn't clear why this warning occurs, other than we know that we're getting more lines reported for a source file than the code in the file actually has. I have not been able to determine why this is, but suspect it might be due to erb inserting lines in the file.
Below is a copy of the patch I created to allow turning these warnings off with an ENV var. Granted this is a crude fix, but it helps to clean up our test output.
My request is getting the below patch or something like it included in simplecov. Ultimately, these warnings are not helpful in their current form for view specs, since it's not clear why this is an issue or what can be done to resolve it.
$ ruby -e "puts RUBY_DESCRIPTION" ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
Rails 7.0.4.3
RSpec 3.12.0
SimpleCov 0.22.0
tests are run with
bin/rspec spec
manually or via guard.This is an example view spec for devise (v4.8.1) that reproduces the issue (remove the
unless
wrapper on SimpleCov config to get results from specs for a single file):Again, main focus here is to have an env var or config option added to simplecov that allows silencing the warnings from the
coverage_exceeding_source_warn
method.The text was updated successfully, but these errors were encountered: