Sha256: 247164bbef3bb450e9e8fc2ec4051f84a06baaab2d18fd59ee625d850f105ca5
Contents?: true
Size: 1.43 KB
Versions: 5
Compression:
Stored size: 1.43 KB
Contents
module Calabash module IOS # @!visibility private module Routes # @!visibility private module ResponseParser def parse_response_body(response) body = response.body begin hash = JSON.parse(body) rescue TypeError, JSON::ParserError => e raise Calabash::IOS::RouteError, "Could not parse response '#{body}: #{e}'" end outcome = hash['outcome'] case outcome when 'FAILURE' reason = hash['reason'] if reason.nil? || reason.empty? hash['reason'] = 'Server provided no reason.' end details = hash['details'] if details.nil? || details.empty? hash['details'] = 'Server provided no details.' end when 'SUCCESS' # Backdoor route returns a 'result' key. Grr. # Legacy API: will be removed in Calabash iOS Server > 0.14.3 if !(hash.has_key?('results') || hash.has_key?('result')) raise Calabash::IOS::RouteError, "Server responded with '#{outcome}'" \ "but response #{hash} does not contain 'results' key" end else raise Calabash::IOS::RouteError, 'Server responded with an invalid outcome:' \ "'#{hash['outcome']}'" end hash end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems