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

ruby-grape / grape / 33496838865 / 18
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: router-compile-registered-methods
DEFAULT BRANCH: master
Ran 01 Sep 2026 10:20AM UTC
Files 168
Run time 7s
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

01 Sep 2026 10:19AM UTC coverage: 95.702% (+0.003%) from 95.699%
33496838865.18

Pull #2880

github

ericproulx
Skip the version pattern test when it is the one that matches anything

`Versioner::Path#version_from_first_segment` runs on every request of a
path-versioned API, and tested the candidate segment against `pattern`:

    return unless potential_version.match?(pattern)

`pattern` defaults to `/.*/i`, which matches any segment including the empty
one, so for that value the test can only ever say yes. It is also the only
value it ever has in a Grape application: `Endpoint#build_stack` does not pass
`pattern:` when it builds the versioner, and `version 'v1', using: :path,
pattern: /v.+/` raises `ArgumentError: unknown keyword: :pattern`. The option
is reachable only by constructing the middleware directly, which is what the
specs do.

Name the default and keep it only when an API supplied something else, so the
regexp runs when it can decide something and not otherwise. `pattern` still
answers the default, and a supplied pattern is still enforced — both branches
stay covered by the existing specs, which construct the middleware with
`pattern: /v./i` and assert on a segment that matches and one that does not.

What it buys, measured in one process on the segment the versioner tests:

    seg.match?(/.*/i)                      57 ns
    custom_pattern && !seg.match?(...)     18 ns   (nil, so short-circuits)

That is roughly 39 ns per request of a path-versioned API — about 0.7% of a
minimal request, and nothing at all for an API with no version. End to end it
sits below what the version_throughput harness can resolve (+0.4% median of 9
interleaved runs, against a noise floor of several percent), so no end-to-end
figure is claimed here. Allocation counts are unchanged: `match?` builds no
MatchData.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Pull Request #2880: Skip the version pattern test when it is the one that matches anything

1216 of 1332 branches covered (91.29%)

Branch coverage included in aggregate %.

3861 of 3973 relevant lines covered (97.18%)

1134.66 hits per line

Source Files on job run-3.3-gemfiles/rack_3_0.gemfile - 33496838865.18
  • Tree
  • List 168
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 33496838865
  • 651bb56e on github
  • Prev Job for on perf/skip-default-version-pattern (#33414584203.25)
  • Next Job for on perf/skip-default-version-pattern (#33497654293.18)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc