class Fitting::Report::Responses

Public Class Methods

new(responses) click to toggle source
# File lib/fitting/report/responses.rb, line 6
def initialize(responses)
  @responses = responses
  @responses = []
  responses.to_a.map do |response|
    @responses.push(Fitting::Report::Response.new(response))
  end
end

Public Instance Methods

cram_into_the_appropriate_response(test) click to toggle source
# File lib/fitting/report/responses.rb, line 37
def cram_into_the_appropriate_response(test)
  @responses.map do |response|
    if response.status.to_s == test.status &&
        JSON::Validator.fully_validate(response.body, test.body) == []
      response.add_test(test)
      return
    end
  end
end
is_there_a_suitable_response?(test) click to toggle source
# File lib/fitting/report/responses.rb, line 27
def is_there_a_suitable_response?(test)
  return false if @responses.nil?
  @responses.map do |response|
    return true if response.status.to_s == test.status &&
        JSON::Validator.fully_validate(response.body, test.body) == []
  end

  false
end
join(tests) click to toggle source
# File lib/fitting/report/responses.rb, line 18
def join(tests)
  tests.to_a.map do |test|
    if is_there_a_suitable_response?(test)
      cram_into_the_appropriate_response(test)
      test.mark_response
    end
  end
end
to_a() click to toggle source
# File lib/fitting/report/responses.rb, line 14
def to_a
  @responses
end