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

ruby-grape / grape / 33321195155
97%

Build:
DEFAULT BRANCH: master
Ran 30 Aug 2026 04:00PM UTC
Jobs 32
Files 169
Run time 1min
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

30 Aug 2026 04:00PM UTC coverage: 96.981% (+0.01%) from 96.971%
33321195155

push

github

web-flow
Add Grape::PrecompiledJson for bodies that are already JSON (#2869)

The JSON formatters encode whatever the endpoint returned, so a String holding
pre-rendered JSON -- a blob cached in Redis, a json_agg column read straight
from Postgres, output from another serializer -- comes back encoded a second
time: '{"a":1}' becomes "\"{\\\"a\\\":1}\"".

The workarounds for this were accidents of implementation rather than
documented behaviour: :serializable_hash happens to return a String untouched,
and :binary has no formatter class at all, so it falls through to
DEFAULT_LAMBDA_FORMATTER -- but answers application/octet-stream.

PrecompiledJson marks one body as already rendered:

  get '/cached' do
    body Grape::PrecompiledJson.new(Rails.cache.read('payload'))
  end

Formatter::Json and Formatter::SerializableHash return it verbatim; everything
unwrapped encodes exactly as before. The opt-in is per response rather than per
API on purpose. A formatter that passed every String through could not tell
pre-rendered JSON from an endpoint returning 'hello', and would answer with a
bare hello -- invalid JSON, silently, and not something a type check can catch
since a String is precisely what it is looking for. A marker never has to
guess.

An Array is joined without its members being parsed, which is what makes a
cached collection cheap: N rendered blobs are spliced together rather than
round-tripped. This is load-bearing rather than a convenience -- handing an
encoder an array of wrappers renders them as ordinary objects
([{"value":"..."}]), so the join has to happen here. Array#join calls to_s, so
members may themselves be PrecompiledJson.

For the same reason a wrapper is only valid as the whole body; nesting one
inside a Hash is documented as unsupported, since no encoder knows to unwrap
it. A value that is neither String nor Array raises
Grape::Exceptions::InvalidFormatter, which the formatter middleware already
rescues into a 500, rather than letting a body... (continued)

1242 of 1334 branches covered (93.1%)

Branch coverage included in aggregate %.

10 of 10 new or added lines in 3 files covered. (100.0%)

3898 of 3966 relevant lines covered (98.29%)

27154.37 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-4.0-gemfiles/rack_3_0.gemfile - 33321195155.1 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
2 run-4.0-gemfiles/rack_2_2.gemfile - 33321195155.2 30 Aug 2026 04:00PM UTC 168
95.69
GitHub Action Run
3 run-3.3-gemfiles/rack_2_2.gemfile - 33321195155.3 30 Aug 2026 04:00PM UTC 168
95.69
GitHub Action Run
4 run-3.4-gemfiles/rails_8_0.gemfile - 33321195155.4 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
5 run-4.0-gemfiles/grape_swagger.gemfile - 33321195155.5 30 Aug 2026 04:00PM UTC 168
55.27
GitHub Action Run
6 run-4.0-gemfiles/dry_validation.gemfile - 33321195155.6 30 Aug 2026 04:00PM UTC 168
57.76
GitHub Action Run
7 run-4.0-gemfiles/multi_json.gemfile - 33321195155.7 30 Aug 2026 04:00PM UTC 168
47.36
GitHub Action Run
8 run-4.0-gemfiles/rails_7_2.gemfile - 33321195155.8 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
9 run-3.4-gemfiles/rack_3_2.gemfile - 33321195155.9 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
10 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33321195155.10 30 Aug 2026 04:00PM UTC 168
46.79
GitHub Action Run
11 run-3.3-gemfiles/rack_3_2.gemfile - 33321195155.11 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
12 run-4.0-gemfiles/multi_xml.gemfile - 33321195155.12 30 Aug 2026 04:00PM UTC 168
46.75
GitHub Action Run
13 run-3.3-gemfiles/rack_3_0.gemfile - 33321195155.13 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
14 run-4.0-Gemfile - 33321195155.14 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
15 run-4.0-gemfiles/rack_3_2.gemfile - 33321195155.15 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
16 run-3.3-Gemfile - 33321195155.16 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
17 run-4.0-gemfiles/hashie.gemfile - 33321195155.17 30 Aug 2026 04:00PM UTC 168
61.71
GitHub Action Run
18 run-3.4-Gemfile - 33321195155.18 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
19 run-3.3-gemfiles/rails_8_0.gemfile - 33321195155.19 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
20 run-4.0-gemfiles/rack_3_1.gemfile - 33321195155.20 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
21 run-4.0-gemfiles/grape_entity.gemfile - 33321195155.21 30 Aug 2026 04:00PM UTC 168
50.06
GitHub Action Run
22 run-3.3-gemfiles/rails_7_2.gemfile - 33321195155.22 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
23 run-3.3-gemfiles/rack_3_1.gemfile - 33321195155.23 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
24 run-3.4-gemfiles/rack_3_1.gemfile - 33321195155.24 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
25 run-4.0-gemfiles/rails_8_0.gemfile - 33321195155.25 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
26 run-3.4-gemfiles/rails_7_2.gemfile - 33321195155.26 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
27 run-3.4-gemfiles/rails_8_1.gemfile - 33321195155.27 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
28 run-3.4-gemfiles/rack_2_2.gemfile - 33321195155.28 30 Aug 2026 04:00PM UTC 168
95.69
GitHub Action Run
29 run-3.4-gemfiles/rack_3_0.gemfile - 33321195155.29 30 Aug 2026 04:00PM UTC 168
95.73
GitHub Action Run
30 run-3.3-gemfiles/rails_8_1.gemfile - 33321195155.30 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
31 run-4.0-gemfiles/rails_8_1.gemfile - 33321195155.31 30 Aug 2026 04:00PM UTC 169
95.73
GitHub Action Run
32 run-4.0-gemfiles/multi_json_1_20.gemfile - 33321195155.32 30 Aug 2026 04:00PM UTC 168
47.39
GitHub Action Run
Source Files on build 33321195155
  • Tree
  • List 169
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #33321195155
  • 2561ae6a on github
  • Prev Build on master (#33320781540)
  • Next Build on master (#33321531189)
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