Sha256: 48a3e1db32aa63be969b0d022829d01c4e4e13dc062efdaa199ec0de4151d04c

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

require 'fitting/records/unit/json_schema'

module Fitting
  class Records
    class Unit
      class Response
        def initialize(documented_response, tested_responses)
          @documented_response = documented_response
          @tested_responses = tested_responses
        end

        def status
          @status ||= @documented_response['status']
        end

        def json_schemas
          @json_schemas ||= @documented_response['json_schemas'].inject([]) do |res, documented_json_schema|
            res.push(Fitting::Records::Unit::JsonSchema.new(documented_json_schema, tested_bodies))
          end
        end

        def tested_bodies
          @tested_bodies ||= @tested_responses.inject([]) do |res, tested_response|
            next res unless status == tested_response.status.to_s

            res.push(tested_response.body)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fitting-2.18.3 lib/fitting/records/unit/response.rb
fitting-2.18.2 lib/fitting/records/unit/response.rb
fitting-2.18.1 lib/fitting/records/unit/response.rb
fitting-2.18.0 lib/fitting/records/unit/response.rb