class Fitting::Report::Response
Public Class Methods
new(response)
click to toggle source
# File lib/fitting/report/response.rb, line 10 def initialize(response) @response = response @tests = Fitting::Report::Tests.new([]) @id = SecureRandom.hex end
Public Instance Methods
add_test(test)
click to toggle source
# File lib/fitting/report/response.rb, line 28 def add_test(test) @tests.push(test) end
body()
click to toggle source
# File lib/fitting/report/response.rb, line 20 def body @response['body'] || @response[:body] end
combinations()
click to toggle source
# File lib/fitting/report/response.rb, line 36 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
cover_percent()
click to toggle source
# File lib/fitting/report/response.rb, line 56 def cover_percent return '0%' if @tests.size == 0 return '100%' if @combinations.size == 0 "#{(@combinations.size_with_tests + 1) * 100 / (@combinations.size + 1)}%" end
details()
click to toggle source
# File lib/fitting/report/response.rb, line 62 def details { cover_percent: cover_percent, tests_without_combinations: @tests.without_combinations, combinations_details: @combinations.to_a.map { |c| {json_schema: c.id, tests_size: c.tests.size, type: c.type, name: c.name} } } end
id()
click to toggle source
# File lib/fitting/report/response.rb, line 24 def id @id end
status()
click to toggle source
# File lib/fitting/report/response.rb, line 16 def status @response['status'] || @response[:status] end
tests()
click to toggle source
# File lib/fitting/report/response.rb, line 32 def tests @tests end