fitting 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fd051bc55d0a84202300a746cb5c75041440924
4
- data.tar.gz: a6be0e42f772ea7dd5505dc46a0eee5b68b90c29
3
+ metadata.gz: 06220f80408936409260ab3c2ae9ec2ca4150688
4
+ data.tar.gz: b47cb00f2e71872775753041f1008d4c26484e35
5
5
  SHA512:
6
- metadata.gz: 2fe0cb6d71f87702f48a83573732f515aa673d616e32f92b479144129423129aca0bb9bbfca65672fa55f9cc695e58fdeea07e038af99a88db70e0fa2706ec77
7
- data.tar.gz: 6f5bdefbe659626a84a41b7682fe0edfb90a7dbb7f3768e7ad55d36787d53e2fa4e422544538b2f186e2e1235c909ae263f751ac055c147c56d24b490ee774a1
6
+ metadata.gz: 4750c9efa6c63c0bda3895adccc1da21561905d261af985a0e4dc7fc735d1af8eb7fc76367776285b21ec2faf879a159aa4a9fe81d81bfb46d35a2a87538987b
7
+ data.tar.gz: 97f88a0b890bcc70bf6ed41f2f2044007dea8b75680aaaf1fe4b883cc2d3d5b0d9e11584456179c1ef6371e66f88d7facf6ad84e37c5313783ecd0760d0cd450
@@ -4,6 +4,7 @@ require 'fitting/documentation/response/route'
4
4
  require 'fitting/documentation/request/route'
5
5
  require 'fitting/storage/responses'
6
6
  require 'fitting/storage/documentation'
7
+ require 'fitting/storage/skip'
7
8
  require 'fitting/report/response'
8
9
  require 'fitting/matchers/response_matcher'
9
10
 
@@ -27,14 +28,25 @@ module RSpec
27
28
 
28
29
  def run_specs(example_groups)
29
30
  origin_run_specs(example_groups)
30
- return if Fitting::Storage::Responses.nil?
31
+
32
+ return if Fitting::Storage::Skip.get
31
33
 
32
34
  response_routes = Fitting::Documentation::Response::Route.new(
33
35
  Fitting::Storage::Documentation.hash,
34
36
  Fitting::Storage::Responses.all
35
37
  )
36
38
  request_routes = Fitting::Documentation::Request::Route.new(response_routes)
37
- puts "Coverage documentation API (responses) by RSpec tests: #{response_routes.cover_ratio}%"
39
+
40
+ valid_count = response_routes.coverage.size
41
+ valid_percentage = response_routes.cover_ratio
42
+ total_count = response_routes.all.size
43
+ invalid_count = response_routes.not_coverage.size
44
+ invalid_percentage = 100.0 - response_routes.cover_ratio
45
+ puts "API responses conforming to the blueprint: #{valid_count} (#{valid_percentage}% of #{total_count})."
46
+ puts "API responses with validation errors or untested: #{invalid_count} (#{invalid_percentage}% of #{total_count})."
47
+ puts
48
+ puts "Conforming responses: \n#{response_routes.coverage.join("\n")} \n\n"
49
+ puts "Non-conforming responses: \n#{response_routes.not_coverage.join("\n")}\n\n"
38
50
  Fitting::Report::Response.new('report_response.yaml', response_routes).save
39
51
  Fitting::Report::Response.new('report_request_by_response.yaml', request_routes).save
40
52
  end
@@ -27,7 +27,7 @@ module Fitting
27
27
  responses
28
28
  end.map do |status, indexes|
29
29
  indexes.times do |index|
30
- route = "#{request['method']} #{request['path']} #{status} #{index}"
30
+ route = "#{request['method']}\t#{request['path']} #{status} #{index}"
31
31
  routes.push(route)
32
32
  end
33
33
  end
@@ -25,10 +25,10 @@ module Fitting
25
25
  end
26
26
 
27
27
  unless @response.valid?
28
- "response not valid json-schema\n"\
29
- "got: #{@response.got}\n"\
30
- "diff: \n#{@response.diff}"\
31
- "expected: \n#{@response.expected}\n"
28
+ "response does not conform to json-schema\n"\
29
+ "schemas: \n#{@response.expected}\n\n"\
30
+ "got: #{@response.got}\n\n"\
31
+ "errors: \n#{@response.diff}\n"
32
32
  end
33
33
  end
34
34
  end
@@ -14,11 +14,11 @@ module Fitting
14
14
  end
15
15
 
16
16
  def route
17
- "#{@schema['method']} #{@schema['path']}"
17
+ "#{@schema['method']}\t#{@schema['path']}"
18
18
  end
19
19
 
20
20
  def real_method_with_path
21
- "#{@method} #{@path}"
21
+ "#{@method}\t#{@path}"
22
22
  end
23
23
 
24
24
  def schemas_of_possible_responses(status:)
@@ -44,14 +44,14 @@ module Fitting
44
44
 
45
45
  def diff
46
46
  @fully_validates.inject("") do |res, fully_validate|
47
- res + "#{fully_validate}\n"
47
+ res + "#{fully_validate.join("\n")}\n\n"
48
48
  end
49
49
  end
50
50
 
51
51
  def expected
52
- @schemas.inject("") do |res, schema|
53
- res + "#{schema}\n"
54
- end
52
+ @schemas.inject([]) do |res, schema|
53
+ res.push("#{schema}")
54
+ end.join("\n\n")
55
55
  end
56
56
 
57
57
  private
@@ -0,0 +1,15 @@
1
+ module Fitting
2
+ module Storage
3
+ module Skip
4
+ class << self
5
+ def set(skip)
6
+ @skip = skip
7
+ end
8
+
9
+ def get
10
+ @skip ||= false
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Fitting
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitting
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.efimov
@@ -200,6 +200,7 @@ files:
200
200
  - lib/fitting/response.rb
201
201
  - lib/fitting/storage/documentation.rb
202
202
  - lib/fitting/storage/responses.rb
203
+ - lib/fitting/storage/skip.rb
203
204
  - lib/fitting/version.rb
204
205
  homepage: https://github.com/funbox/fitting
205
206
  licenses: