Skip to content

Improve branch test coverage - #3

Closed
dblock wants to merge 1 commit into
add-coverage-100from
improve-branch-coverage
Closed

Improve branch test coverage#3
dblock wants to merge 1 commit into
add-coverage-100from
improve-branch-coverage

Conversation

@dblock

@dblock dblock commented Sep 4, 2026

Copy link
Copy Markdown
Owner

What

Stacked on top of ruby-grape#2896 (which brings line coverage to 100%). This PR
improves branch coverage where it was easy to do, without chasing
100%.

Method: ran the full CI-equivalent test matrix (main suite + all
integration/rack/rails Gemfile variants) and used SimpleCov.collate
to get the true combined coverage, then added direct unit tests for
previously-uncovered branches that were easy/cheap to reach:

  • Grape::Exceptions::Base#translate_message — the Proc, Hash-pattern-match, and plain-value branches.
  • Grape::Exceptions::RequestError — no spec file existed; added one.
  • Grape::Exceptions::Validation — the "message omitted" default branch.
  • Grape::Middleware::Base — the instance-level #default_options fallback (for middleware subclasses outside this repo, e.g. 3rd-party gems).
  • Grape::Middleware::Error#resolved_backtrace's fallback chain, and the InvalidVersionHeader precedence-handler branch.
  • Grape::Namespace.joined_space.
  • Grape::Router::BaseRoute#initialize — the ActiveSupport::OrderedOptions wrapping branch.
  • Grape::Router::Pattern::Path#suffix — the non-path (e.g. header) versioning branch.
  • Grape::Testing — missing-block and no-registered-hooks branches.
  • Grape::Util::Translation#translate — explicit locale: and explicit default: branches.

Result

Full-matrix branch coverage: 95.58% (1278/1337) → 96.40% (1289/1337).
Line coverage stays at 100%. Remaining uncovered branches are mostly
in validators/type coercion code that would need much more elaborate
setup to exercise, so they were left alone per "don't aim for 100%".

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@coveralls

coveralls commented Sep 4, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 33869124388

Coverage at 99.047% (no base build to compare)

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4015
Covered Lines: 4013
Line Coverage: 99.95%
Relevant Branches: 1338
Covered Branches: 1289
Branch Coverage: 96.34%
Branches in Coverage %: Yes
Coverage Strength: 27028.13 hits per line

💛 - Coveralls

…d translation utilities

Adds direct unit tests to exercise previously-uncovered branches:
- Grape::Exceptions::Base#translate_message (Proc/Hash-pattern/plain-value branches)
- Grape::Exceptions::RequestError (new spec file)
- Grape::Exceptions::Validation (message omitted case)
- Grape::Middleware::Base (instance-level #default_options fallback)
- Grape::Middleware::Error (#resolved_backtrace fallback chain, InvalidVersionHeader precedence)
- Grape::Namespace.joined_space
- Grape::Router::BaseRoute#initialize (ActiveSupport::OrderedOptions wrapping)
- Grape::Router::Pattern::Path#suffix (non-path versioning)
- Grape::Testing (missing block / no registered hooks)
- Grape::Util::Translation#translate (explicit locale / explicit default)

Raises the full-matrix branch coverage from 95.58% (1278/1337) to
96.40% (1289/1337), while keeping line coverage at 100%. Not aiming for
100% branch coverage; only the easy, high-signal gaps were closed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock
dblock force-pushed the improve-branch-coverage branch from bd374a9 to 89fa6b8 Compare September 4, 2026 11:41
@dblock

dblock commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

Closing in favor of a PR against ruby-grape/grape master (stacked on ruby-grape#2896).

@dblock dblock closed this Sep 4, 2026
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

Successfully merging this pull request may close these issues.

2 participants