Sha256: c2e0a2b37f5485193d28c3e27b95d8d5ad746f317f802e3e4fc815c86aa44f93
Contents?: true
Size: 1.94 KB
Versions: 4
Compression:
Stored size: 1.94 KB
Contents
require 'fitting/statistics/template_cover_error' require 'fitting/statistics/template_cover_error_enum' require 'fitting/statistics/template_cover_error_one_of' require 'fitting/report/combinations' require 'fitting/report/combination' module Fitting module Report class Response def initialize(response) @response = response @tests = Fitting::Report::Tests.new([]) @id = SecureRandom.hex end def status @response['status'] || @response[:status] end def body @response['body'] || @response[:body] end attr_reader :id, :tests def add_test(test) @tests.push(test) end def combinations return @combinations if @combinations cmbntns = [] combinations = Fitting::Cover::JSONSchema.new(body).combi + Fitting::Cover::JSONSchemaEnum.new(body).combi + Fitting::Cover::JSONSchemaOneOf.new(body).combi if combinations != [] combinations.map do |combination| cmbntns.push( Fitting::Report::Combination.new( json_schema: combination[0], type: combination[1][0], combination: combination[1][1] ) ) end end @combinations = Fitting::Report::Combinations.new(cmbntns) end def cover_percent return '0%' if @tests.size.zero? return '100%' if @combinations.size.zero? "#{(@combinations.size_with_tests + 1) * 100 / (@combinations.size + 1)}%" end def details { cover_percent: cover_percent, tests_without_combinations: @tests.without_combinations, combinations_details: @combinations.to_a.map do |c| { json_schema: c.id, tests_size: c.tests.size, type: c.type, name: c.name } end } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fitting-2.18.3 | lib/fitting/report/response.rb |
fitting-2.18.2 | lib/fitting/report/response.rb |
fitting-2.18.1 | lib/fitting/report/response.rb |
fitting-2.18.0 | lib/fitting/report/response.rb |