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

ably / ably-ruby / 4287920241

pending completion
4287920241

push

github

Quintin Willison
Add features workflow.

3630 of 5199 relevant lines covered (69.82%)

322.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.33
/lib/ably/rest/middleware/parse_json.rb
1
require 'faraday'
10✔
2
require 'json'
10✔
3

4
module Ably
10✔
5
  module Rest
10✔
6
    module Middleware
10✔
7
      class ParseJson < Faraday::Middleware
10✔
8
        def on_complete(env)
10✔
9
          if env.response_headers['Content-Type'] == 'application/json'
×
10
            env.body = parse(env.body) unless env.response_headers['Ably-Middleware-Parsed'] == true
×
11
            env.response_headers['Ably-Middleware-Parsed'] = true
×
12
          end
13
        end
14

15
        def parse(body)
10✔
16
          if body.length > 0
×
17
            JSON.parse(body)
×
18
          else
19
            body
×
20
          end
21
        rescue JSON::ParserError => e
22
          raise Ably::Exceptions::InvalidResponseBody, "Expected JSON response: #{e.message}"
×
23
        end
24
      end
25
    end
26
  end
27
end
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