@@ -356,21 +356,30 @@ def ClientShowcase.from_file(path = Dir.glob('*.geekspec').first)
356356 end
357357
358358 def ClientShowcase . map_response ( spec , resp )
359- if ( r = spec . return ) . is_a? ReturnTypeAndObject
359+ if ( r = spec . return ) . is_a? Spectrum :: Interface :: ReturnTypeAndObject
360360 json = JSON . parse ( resp . body )
361361 mapper = "map_resp_#{ r . name } "
362362 if ClientShowcase . respond_to? ( mapper )
363363 case r . type
364- when 'object' then return ClientShowcase . send ( mapper , json )
365- when 'array' then return json . map { |it | ClientShowcase . send ( mapper , it ) }
364+ when 'object' then return ClientShowcase . send ( mapper , json , resp )
365+ when 'array' then return json . map { |it | ClientShowcase . send ( mapper , it , resp ) }
366366 end
367367 end
368368 return json
369- elsif spec . return . is_a? ReturnTypesAndNames
370- return JSON . parse ( resp . body )
369+ elsif spec . return . is_a? Spectrum :: Interface :: ReturnTypesAndNames
370+ return JSON . parse ( resp . body ) # plain map
371371 end
372372
373- resp
373+ mapper = "map_resp_text_#{ spec . return } "
374+ if ClientShowcase . respond_to? ( mapper ) then ClientShowcase . send ( mapper , resp . body , resp ) else resp . body end
375+ end
376+
377+ def ClientShowcase . map_resp_text_datetime ( body , _ )
378+ if body . match ( /[0-9]+/ )
379+ Time . at ( 0 , body . to_i , :millisecond )
380+ else
381+ Time . new ( body )
382+ end
374383 end
375384
376385 def ClientShowcase . setup_auth ( req , auth )
0 commit comments