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

ruby-grape / grape / 25609976233 / 17
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: refactor/de-morgan-conditions
DEFAULT BRANCH: master
Ran 09 May 2026 07:37PM 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:36PM UTC coverage: 95.684% (+0.002%) from 95.682%
25609976233.17

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

1037 of 1145 branches covered (90.57%)

Branch coverage included in aggregate %.

3397 of 3489 relevant lines covered (97.36%)

1008.49 hits per line

Source Files on job run-3.4-gemfiles/rack_3_1.gemfile - 25609976233.17
  • 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 25609976233
  • 84225334 on github
  • Prev Job for on refactor/validates-pure-helpers (#25608800647.37)
  • Next Job for on refactor/validates-pure-helpers (#25610197149.31)
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