• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 25864552952 / 35
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: fix/recompile-settings-mutation-race
DEFAULT BRANCH: master
Ran 14 May 2026 02:09PM UTC
Files 159
Run time 10s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

14 May 2026 02:04PM UTC coverage: 95.74% (-0.02%) from 95.759%
25864552952.35

Pull #2716

github

ericproulx
Refactor DSL::Routing#version: guard clause, kwargs, value object

Three changes that touch the same method:

1. Lift the body out of `if args.any? ... end` into a
   `return @versions&.last if args.empty?` guard.

2. Replace `**options` with explicit kwargs (`using:`, `cascade:`,
   `parameter:`, `strict:`, `vendor:`) and bake the defaults into the
   signature. The per-call `reverse_merge(using: :path)` is gone.

3. Introduce `Grape::DSL::VersionOptions` (built on `Data.define`)
   as the canonical representation of resolved version options.
   Threaded end-to-end:
   - `#version` builds and stores a `VersionOptions` on
     `inheritable_setting.namespace_inheritable[:version_options]`.
   - `Path#uses_path_versioning?`, `Endpoint#build_stack`, and
     `API::Instance#cascade?` read fields via accessors instead of
     `[:key]`.
   - The versioner middleware (`Versioner::Base`) now takes a
     `VersionOptions` directly, not a Hash. `Forwardable.def_delegators`
     forwards `cascade`/`parameter`/`strict`/`vendor` to it; the four
     ivars and per-call assignments are dropped. `DEFAULT_OPTIONS`
     stores a `VersionOptions.new(...)` so direct-mount callers still
     get safe defaults.

Public `.version` DSL surface unchanged — still accepts kwargs the same
way; the value object is an internal-only representation.

`version_options` is read for exactly these five keys across the
codebase: `:using` (`endpoint.rb`, `path.rb`), and `:cascade` /
`:parameter` / `:strict` / `:vendor` (`Versioner::Base`, plus
`:cascade` in `API::Instance#cascade?`). Any other kwarg passed to
`.version` was previously swallowed by the splat with no effect.

Spec fixtures updated:

- `spec/shared/versioning_examples.rb` (14 sites): `**macro_options`
  -> `**macro_options.except(:format)`. The `:format` key stays in
  the macro hash so the test helper (`versioned_helpers.rb`) can still
  build the `HTTP_ACCEPT` header.
- `spec/grape/exceptions/invalid_accept_header_spec.rb`... (continued)
Pull Request #2716: Refactor DSL::Routing#version: guard clause, explicit kwargs, value object

1046 of 1153 branches covered (90.72%)

Branch coverage included in aggregate %.

3426 of 3518 relevant lines covered (97.38%)

1004.15 hits per line

Source Files on job run-3.4-Gemfile - 25864552952.35
  • Tree
  • List 159
  • Changed 5
  • Source Changed 5
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 25864552952
  • 5c4f190f on github
  • Prev Job for on refactor/version-guard-clause (#25854383996.11)
  • Next Job for on refactor/version-guard-clause (#25864940829.20)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc