Class: Fitting::Report::Response
- Inherits:
-
Object
- Object
- Fitting::Report::Response
- Defined in:
- lib/fitting/report/response.rb
Instance Method Summary collapse
- #add_test(test) ⇒ Object
- #body ⇒ Object
- #combinations ⇒ Object
- #cover_percent ⇒ Object
- #details ⇒ Object
- #id ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
- #tests ⇒ Object
Constructor Details
Instance Method Details
#add_test(test) ⇒ Object
28 29 30 |
# File 'lib/fitting/report/response.rb', line 28 def add_test(test) @tests.push(test) end |
#body ⇒ Object
20 21 22 |
# File 'lib/fitting/report/response.rb', line 20 def body @response['body'] end |
#combinations ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 ⇒ Object
56 57 58 59 60 |
# 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 ⇒ Object
62 63 64 65 66 67 68 |
# 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 ⇒ Object
24 25 26 |
# File 'lib/fitting/report/response.rb', line 24 def id @id end |
#status ⇒ Object
16 17 18 |
# File 'lib/fitting/report/response.rb', line 16 def status @response['status'] end |
#tests ⇒ Object
32 33 34 |
# File 'lib/fitting/report/response.rb', line 32 def tests @tests end |