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

ruby-grape / grape / 33252712683
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: mount-refresh-internal
DEFAULT BRANCH: master
Ran 29 Aug 2026 12:31PM 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

29 Aug 2026 12:30PM UTC coverage: 96.998% (+0.01%) from 96.988%
33252712683

push

github

ericproulx
Add Grape::PrecompiledJson for bodies that are already JSON

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 Rack ca... (continued)

1247 of 1338 branches covered (93.2%)

Branch coverage included in aggregate %.

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

3891 of 3959 relevant lines covered (98.28%)

27158.54 hits per line

Jobs
ID Job ID Ran Files Coverage
1 run-4.0-gemfiles/multi_json_1_20.gemfile - 33252712683.1 29 Aug 2026 12:31PM UTC 168
47.38
GitHub Action Run
2 run-3.4-gemfiles/rails_8_1.gemfile - 33252712683.2 29 Aug 2026 12:32PM UTC 169
95.75
GitHub Action Run
3 run-3.4-gemfiles/rails_7_2.gemfile - 33252712683.3 29 Aug 2026 12:31PM UTC 169
95.75
GitHub Action Run
4 run-3.3-Gemfile - 33252712683.4 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
5 run-4.0-gemfiles/grape_entity.gemfile - 33252712683.5 29 Aug 2026 12:31PM UTC 168
50.01
GitHub Action Run
6 run-4.0-gemfiles/multi_xml_0_8.gemfile - 33252712683.6 29 Aug 2026 12:31PM UTC 168
46.78
GitHub Action Run
7 run-3.4-gemfiles/rack_3_0.gemfile - 33252712683.7 29 Aug 2026 12:32PM UTC 168
95.75
GitHub Action Run
8 run-4.0-gemfiles/grape_swagger.gemfile - 33252712683.8 29 Aug 2026 12:31PM UTC 168
55.07
GitHub Action Run
9 run-4.0-gemfiles/rack_3_2.gemfile - 33252712683.9 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
10 run-3.4-gemfiles/rails_8_0.gemfile - 33252712683.10 29 Aug 2026 12:31PM UTC 169
95.75
GitHub Action Run
11 run-3.3-gemfiles/rails_7_2.gemfile - 33252712683.11 29 Aug 2026 12:32PM UTC 169
95.75
GitHub Action Run
12 run-4.0-gemfiles/dry_validation.gemfile - 33252712683.12 29 Aug 2026 12:31PM UTC 168
57.74
GitHub Action Run
13 run-4.0-gemfiles/hashie.gemfile - 33252712683.13 29 Aug 2026 12:31PM UTC 168
61.75
GitHub Action Run
14 run-3.4-gemfiles/rack_2_2.gemfile - 33252712683.14 29 Aug 2026 12:32PM UTC 168
95.71
GitHub Action Run
15 run-4.0-Gemfile - 33252712683.15 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
16 run-4.0-gemfiles/rack_2_2.gemfile - 33252712683.16 29 Aug 2026 12:32PM UTC 168
95.71
GitHub Action Run
17 run-3.4-Gemfile - 33252712683.17 29 Aug 2026 12:32PM UTC 168
95.75
GitHub Action Run
18 run-4.0-gemfiles/rails_7_2.gemfile - 33252712683.18 29 Aug 2026 12:31PM UTC 169
95.75
GitHub Action Run
19 run-3.3-gemfiles/rack_2_2.gemfile - 33252712683.19 29 Aug 2026 12:32PM UTC 168
95.71
GitHub Action Run
20 run-4.0-gemfiles/multi_xml.gemfile - 33252712683.20 29 Aug 2026 12:31PM UTC 168
46.74
GitHub Action Run
21 run-4.0-gemfiles/rails_8_1.gemfile - 33252712683.21 29 Aug 2026 12:32PM UTC 169
95.75
GitHub Action Run
22 run-4.0-gemfiles/rails_8_0.gemfile - 33252712683.22 29 Aug 2026 12:31PM UTC 169
95.75
GitHub Action Run
23 run-3.4-gemfiles/rack_3_1.gemfile - 33252712683.23 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
24 run-3.3-gemfiles/rack_3_2.gemfile - 33252712683.24 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
25 run-4.0-gemfiles/rack_3_1.gemfile - 33252712683.25 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
26 run-3.3-gemfiles/rack_3_0.gemfile - 33252712683.26 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
27 run-4.0-gemfiles/multi_json.gemfile - 33252712683.27 29 Aug 2026 12:31PM UTC 168
47.34
GitHub Action Run
28 run-3.3-gemfiles/rails_8_1.gemfile - 33252712683.28 29 Aug 2026 12:31PM UTC 169
95.75
GitHub Action Run
29 run-4.0-gemfiles/rack_3_0.gemfile - 33252712683.29 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
30 run-3.4-gemfiles/rack_3_2.gemfile - 33252712683.30 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
31 run-3.3-gemfiles/rack_3_1.gemfile - 33252712683.31 29 Aug 2026 12:31PM UTC 168
95.75
GitHub Action Run
32 run-3.3-gemfiles/rails_8_0.gemfile - 33252712683.32 29 Aug 2026 12:31PM UTC 169
95.75
GitHub Action Run
Source Files on build 33252712683
  • 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 #33252712683
  • 226676ed on github
  • Prev Build on master (#33120993402)
  • Next Build on precompiled_json (#33252737439)
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