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

ruby-grape / grape / 25610457229 / 24
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: refactor/de-morgan-conditions
DEFAULT BRANCH: master
Ran 09 May 2026 08:01PM UTC
Files 157
Run time 4s
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

09 May 2026 07:59PM UTC coverage: 95.708% (+0.002%) from 95.706%
25610457229.24

Pull #2706

github

ericproulx
Make ParamsScope#validates pure via ValidationsSpec

`Grape::Validations::ParamsScope#validates(attrs, validations)` used
to consume the validations hash destructively across six helpers
(`infer_coercion`, `derive_validator_options`, `validates_presence`,
`coerce_type`, `document_params`, `extract_details`). The caller's
hash was mutated in place; passing a frozen hash would crash the
pipeline.

Introduces `Grape::Validations::ValidationsSpec` — a small frozen
value object that parses the raw hash once and exposes named
accessors. `validates` becomes a thin dispatcher that hands the spec
to the helpers; the raw hash is never written to. Helpers that used
to read/delete are gone:

  * `infer_coercion` → `ValidationsSpec#parse_coerce` (private)
  * `derive_validator_options` → `ValidationsSpec#shared_opts`
  * `validates_presence` → `ParamsScope#validate_presence(spec, ...)`
  * `coerce_type` (the helper) → `ParamsScope#validate_coerce(spec, ...)`
  * `guess_coerce_type` → `ValidationsSpec#guess_coerce_type` (private)
  * `options_key?` → no longer needed; `ValidationsSpec#resolve_value`

`ParamsDocumentation#document_params` now takes the spec instead of
the raw hash and reads via `spec.raw[...]` without deletion. The
`do_not_document` short-circuit no longer mutates either; it just
returns early.

Behaviour preserved:

  * Order of validator dispatch (presence → coerce → others).
  * `:message` belonging to presence is suppressed for later
    validators (it's in `SPEC_CONSUMED_KEYS`).
  * `:allow_blank` and `:length` remain dual-purpose (shared opt + own
    validator entry; doc source + own validator entry).
  * `check_coerce_with` still raises `ArgumentError` at definition
    time when `coerce_with:` is supplied without a type.

Adds:

  * `lib/grape/validations/validations_spec.rb` — value object.
  * `spec/grape/validations/validations_spec_spec.rb` — unit tests
    including a frozen-hash test that asserts `from(frozen_hash)` does
    not raise... (continued)
Pull Request #2706: Make ParamsScope#validates pure via ValidationsSpec

1039 of 1147 branches covered (90.58%)

Branch coverage included in aggregate %.

3398 of 3489 relevant lines covered (97.39%)

1009.36 hits per line

Source Files on job run-3.2-gemfiles/rack_3_2.gemfile - 25610457229.24
  • Tree
  • List 157
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 25610457229
  • 3662c162 on github
  • Prev Job for on refactor/validates-pure-helpers (#25608800647.32)
  • Next Job for on refactor/validates-pure-helpers (#25610530583.16)
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