Skip to content

Update coverage

gitlab-qa-bot requested to merge update-coverage into master

Created by: myronmarston

I recently learned that # :nocov: can be used to tag a chunk of code so simplecov doesn't consider it. Before learning that, I never bothered to try to get our coverage up because we have so many places where we do alternate method implementations for certain versions of ruby or for windows or whatever. With # :nocov:, it's trivial to tag those so that we can actually meaningfully consider coverage.

I've written a bit about my test coverage philosophy in the past. Besides all the alternate method implementations, keeping coverage up for RSpec's actually not hard, and I think we get enough value out of it to enforce it. I've seen a couple PRs from contributors where they added tests but because of how it was written it wasn't even executing the implementation it was intended to. Enforcing coverage will cause our travis build to catch such things for us.

In this PR, I've gotten coverage up to 100% and configured simplecov to enforce it on our "main" builds (travis builds for MRI >= 2.0), and I've stopped loading simplecov for other builds. The uncovered code generally fell into 3 categories:

  • Dead code that can be deleted. There was a fair bit of it. Often it's private methods that aren't called but in some cases it was logically unreachable code and/or conditional code in a private method that would only be hit if a caller passed a certain arg that none of the callers pass.
  • Code that's not for MRI >= 2.0. I just tagged it with # :nocov:.
  • Code that can and should be covered by a test. In one case (ad53e7f8), the act of trying to add coverage showed me that there was a long-standing bug.

Ideally, I'd like to see this same treatment done for expectations/mocks/support. Anyone want to take that on?

/cc @rspec/rspec

Merge request reports