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

Fix code coverage (eval) for delegates #1046

Open
bkuhlmann opened this issue Dec 30, 2022 · 0 comments
Open

Fix code coverage (eval) for delegates #1046

bkuhlmann opened this issue Dec 30, 2022 · 0 comments

Comments

@bkuhlmann
Copy link

Overview

With the release of SimpleCov 0.22.0 and the addition of the enable_coverage_for_eval feature, I'm seeing issues with code coverage on delegates.

I'm thinking SimpleCov shouldn't consider this a violation? I realize I could use # :nocov: comments on code but that would touch a lot of files.

I think this is a bug?

Screenshots/Screencasts

2022-12-29_18-51-18-Firefox

Steps to Recreate

Here's a snippet of source code for a simple class in Rails to reproduce the error:

module Tasks
  class View
    delegate(*%i[id completed_at created_at description to_param updated_at], to: :record)

    def initialize record
      @record = record
    end

    private

    attr_reader :record
  end
end

Here's a snippet of my spec_helper.rb in case it helps:

SimpleCov.start "rails" do
  add_filter %r(^/spec/)
  enable_coverage :branch
  enable_coverage_for_eval
  minimum_coverage_by_file line: 95, branch: 95
end

The corresponding spec has no tests written for the delegate since that would be essentially testing Rails and seems unnecessary.

Environment

  • Ruby: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin22.2.0]
  • SimpleCov: 0.22.0
  • Rails: 7.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant