Class: Fitting::Route::Responses

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/route/responses.rb

Instance Method Summary collapse

Constructor Details

#initialize(routes, coverage) ⇒ Responses

Returns a new instance of Responses.



4
5
6
7
# File 'lib/fitting/route/responses.rb', line 4

def initialize(routes, coverage)
  @routes = routes
  @coverage = coverage
end

Instance Method Details

#statisticsObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fitting/route/responses.rb', line 9

def statistics
  valid_count = @coverage.coverage.size
  valid_percentage = @coverage.cover_ratio
  total_count = @routes.size
  invalid_count = @coverage.not_coverage.size
  invalid_percentage = (100.0 - @coverage.cover_ratio).round(2)

  [
    "API responses conforming to the blueprint: #{valid_count} (#{valid_percentage}% of #{total_count}).",
    "API responses with validation errors or untested: #{invalid_count} (#{invalid_percentage}% of #{total_count})."
  ].join("\n")
end