Sha256: c5eee2bbac3c9c5d9685fdc1d04edac37588cd507ad44446d060b32982ca1a5e
Contents?: true
Size: 733 Bytes
Versions: 6
Compression:
Stored size: 733 Bytes
Contents
require 'json' module InfinumJsonApiSetup module RSpec module Matchers module Util class BodyParser # @param [String] attribute def initialize(attribute) @attribute = attribute end # @param [ActionDispatch::TestResponse] response # @return [Array] def process(response) [true, JSON.parse(response.body).fetch(attribute)] rescue JSON::ParserError => _e [false, 'Failed to parse response body'] rescue KeyError => _e [false, "Failed to extract #{attribute} from response body"] end private attr_reader :attribute end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems