fitting 2.16.0 → 2.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +34 -3
  3. data/CHANGELOG.md +19 -0
  4. data/README.md +37 -4
  5. data/fitting.gemspec +9 -9
  6. data/images/example.png +0 -0
  7. data/images/example2.png +0 -0
  8. data/images/logo.png +0 -0
  9. data/lib/fitting/configuration/legacy.rb +6 -5
  10. data/lib/fitting/configuration/yaml.rb +2 -2
  11. data/lib/fitting/cover/json_schema.rb +3 -2
  12. data/lib/fitting/cover/json_schema_enum.rb +1 -1
  13. data/lib/fitting/cover/json_schema_one_of.rb +1 -1
  14. data/lib/fitting/cover/response.rb +1 -5
  15. data/lib/fitting/documentation.rb +0 -2
  16. data/lib/fitting/matchers/response_matcher.rb +2 -1
  17. data/lib/fitting/records/documented/request.rb +1 -0
  18. data/lib/fitting/records/realized_unit.rb +13 -15
  19. data/lib/fitting/records/spherical/request.rb +1 -1
  20. data/lib/fitting/records/spherical/requests.rb +2 -1
  21. data/lib/fitting/records/spherical/response.rb +2 -2
  22. data/lib/fitting/records/test_unit/request.rb +4 -0
  23. data/lib/fitting/records/tested/request.rb +4 -4
  24. data/lib/fitting/records/unit/combination.rb +5 -6
  25. data/lib/fitting/records/unit/json_schema.rb +38 -33
  26. data/lib/fitting/records/unit/request.rb +1 -0
  27. data/lib/fitting/records/unit/response.rb +1 -0
  28. data/lib/fitting/report/action.rb +6 -9
  29. data/lib/fitting/report/actions.rb +7 -5
  30. data/lib/fitting/report/combination.rb +1 -15
  31. data/lib/fitting/report/combinations.rb +4 -5
  32. data/lib/fitting/report/console.rb +1 -0
  33. data/lib/fitting/report/prefix.rb +42 -51
  34. data/lib/fitting/report/prefixes.rb +6 -4
  35. data/lib/fitting/report/response.rb +17 -18
  36. data/lib/fitting/report/responses.rb +9 -8
  37. data/lib/fitting/report/test.rb +9 -11
  38. data/lib/fitting/report/tests.rb +10 -13
  39. data/lib/fitting/request.rb +0 -1
  40. data/lib/fitting/response.rb +4 -3
  41. data/lib/fitting/statistics/cover_error.rb +2 -0
  42. data/lib/fitting/statistics/cover_error_enum.rb +2 -0
  43. data/lib/fitting/statistics/cover_error_one_of.rb +2 -0
  44. data/lib/fitting/statistics/list.rb +5 -4
  45. data/lib/fitting/statistics/not_covered_responses.rb +1 -1
  46. data/lib/fitting/statistics/percent.rb +2 -1
  47. data/lib/fitting/statistics/template.rb +10 -8
  48. data/lib/fitting/storage/responses.rb +2 -2
  49. data/lib/fitting/storage/white_list.rb +7 -0
  50. data/lib/fitting/templates/realized_template.rb +2 -0
  51. data/lib/fitting/tests.rb +1 -1
  52. data/lib/fitting/version.rb +1 -1
  53. data/lib/fitting.rb +9 -6
  54. data/lib/tasks/fitting.rake +62 -54
  55. data/lib/templates/bomboniere/package-lock.json +82 -67
  56. data/lib/templates/bomboniere/src/components/HelloWorld.vue +3 -0
  57. metadata +30 -55
  58. data/example.png +0 -0
  59. data/example2.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de3ef63b994a6585d5795ebff3c5473d5b150a47b29abab37d8c306a813e4ee
4
- data.tar.gz: 0c8b4c52d63c38f4b1d6fb174b991544b185bedde24722b09428adfb0260cf05
3
+ metadata.gz: 5d4c64b93e5cc274fd6ce45447011be34413072ac0cddc20d75799ef9ccb3f8d
4
+ data.tar.gz: be18cc02c5f5a3be1167d17bf46039c8b2f9cc404f0c7849297166bffa45a1d5
5
5
  SHA512:
6
- metadata.gz: df9e196563d7a3430b228d9bc4fdaf13600a4db62ee0c8182506b30a4c890fb39a4bb3dc0ae194df63d6a48489ccaf8817dda54c6e6ab3c509a9fa5ee73421c2
7
- data.tar.gz: a140201ca99818ce637b39d80721a26a0c00a75beb5435778e41aacce5e60e953d6b62c285272295b48446c234c3992dd0b7c87c8670bad91d0601f64a7ded1e
6
+ metadata.gz: 0f3b8b8a48f3927c09325dd9d0057b2cfe9294d495eb3693471f2e7e1a11f37cdc5165e44bbbd5d736bbb504875fa68e81473624c113217d1d2573b5735179e9
7
+ data.tar.gz: 00b71dc28323aefa7dd022a8ea441a337c5316228ffb2ddc0b6f6ad310bcd3fefcad35c174dcbe734fdd8cf1178992125f850d6729225a7627f0be70dbeb4706
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.6
3
3
 
4
- Metrics/LineLength:
5
- Max: 120
4
+ Layout/LineLength:
5
+ Max: 130
6
6
 
7
7
  Style/Documentation:
8
8
  Enabled: false
@@ -18,3 +18,34 @@ Style/CaseEquality:
18
18
 
19
19
  Style/NilComparison:
20
20
  Enabled: false
21
+
22
+ Naming/MemoizedInstanceVariableName:
23
+ Enabled: false
24
+
25
+ Lint/UnreachableCode:
26
+ Enabled: false
27
+
28
+ Metrics/MethodLength:
29
+ Max: 50
30
+
31
+ # FIXME
32
+ Metrics/AbcSize:
33
+ Max: 50
34
+
35
+ Metrics/PerceivedComplexity:
36
+ Max: 20
37
+
38
+ Metrics/CyclomaticComplexity:
39
+ Max: 20
40
+
41
+ Metrics/ParameterLists:
42
+ Max: 7
43
+
44
+ Metrics/ClassLength:
45
+ Max: 150
46
+
47
+ Lint/UselessAssignment:
48
+ Enabled: false
49
+
50
+ Style/ZeroLengthPredicate:
51
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Change log
2
2
 
3
+ ### 2.18.1 - 2021-10-12
4
+
5
+ * patch
6
+ * fix bugs and refactoring
7
+
8
+ ### 2.18.0 - 2021-09-29
9
+
10
+ * patch
11
+ * remove multi_json [#119](https://github.com/funbox/fitting/issues/119)
12
+
13
+ ### 2.17.0 - 2021-09-20
14
+
15
+ * features
16
+ * display tests_without_responses details on the main page [#115](https://github.com/funbox/fitting/issues/115)
17
+
18
+ ### 2.16.1 - 2021-02-10
19
+ * patch
20
+ * make prefix optional [#98](https://github.com/funbox/fitting/issues/98)
21
+
3
22
  ### 2.16.0 - 2021-02-10
4
23
 
5
24
  * features
data/README.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Fitting
2
- Coverage API Blueprint, Swagger and OpenAPI with rspec tests for easily make high-quality API and documenatiton.
3
- ![exmaple](example.png)
2
+
3
+ <img align="right" width="192" height="192"
4
+ alt="Optimizt avatar: OK sign with Mona Lisa picture between the fingers"
5
+ src="./images/logo.png">
6
+
7
+ There are such ways of describing the API documentation as API Blueprint, Swagger and OpenAPI. And using the tests already writed for your code, you can reuse them to find out the documentation coverage.
8
+ This makes it easy to find out how much the documentation matches the implementation.
9
+
10
+ * Cool if you already have a project with tests and documentation, you can check how good everything is and fix microbags.
11
+
12
+ * If are you going developing API and write documentation for it, this tool will help you document-driven development easily create high-quality write API documentation and API.
13
+
14
+ * Also, if you have an undocumented API, this is an easy way to describe it.
15
+
16
+ ![exmaple](images/example.png)
4
17
 
5
18
  ## Installation
6
19
  Add this line to your application's Gemfile:
@@ -119,11 +132,31 @@ tests_without_responses: 43
119
132
 
120
133
  And task will create HTML (`fitting/index.html`) reports.
121
134
 
122
- ![exmaple](example.png)
135
+ ![exmaple](images/example.png)
123
136
 
124
137
  More information on action coverage
125
138
 
126
- ![exmaple2](example2.png)
139
+ ![exmaple2](images/example2.png)
140
+
141
+ ## prefix name
142
+
143
+ Setting the prefix name is optional. For example, you can do this:
144
+
145
+ ```yaml
146
+ prefixes:
147
+ - openapi2_json_path: doc.json
148
+ ```
149
+
150
+ ## prefix skip
151
+
152
+ It is not necessary to immediately describe each prefix in detail, you can only specify its name and skip it until you are ready to documented it
153
+ ```yaml
154
+ prefixes:
155
+ - name: /api/v1
156
+ openapi2_json_path: doc.json
157
+ - name: /api/v3
158
+ skip: true
159
+ ```
127
160
 
128
161
  ## Contributing
129
162
 
data/fitting.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'fitting/version'
4
4
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['d.efimov']
9
9
  spec.email = ['d.efimov@fun-box.ru']
10
10
 
11
- spec.summary = 'Coverage API Blueprint, Swagger and OpenAPI with rspec tests'
12
- spec.description = 'Coverage API Blueprint, Swagger and OpenAPI with rspec tests for easily make high-quality API and documenatiton.'
11
+ spec.summary = 'Coverage API Blueprint, Swagger and OpenAPI with RSpec'
12
+ spec.description = 'Coverage API Blueprint, Swagger and OpenAPI with RSpec for easily make high-quality API and documenatiton'
13
13
  spec.homepage = 'https://github.com/funbox/fitting'
14
14
  spec.license = 'MIT'
15
15
 
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.required_ruby_version = '>= 2.6.0'
21
22
  spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
22
- spec.add_runtime_dependency 'multi_json', '~> 1.11'
23
23
  spec.add_runtime_dependency 'tomograph', '~> 3.1', '>= 3.1.0'
24
24
  spec.add_development_dependency 'bundler', '~> 2.0'
25
- spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.1'
26
- spec.add_development_dependency 'rake', '>= 12.3.3'
27
- spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
28
- spec.add_development_dependency 'rubocop', '~> 0.49.1', '>= 0.49.1'
29
- spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
25
+ spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
26
+ spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
27
+ spec.add_development_dependency 'rspec', '~> 3.10'
28
+ spec.add_development_dependency 'rubocop', '~> 1.22.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.21'
30
30
  end
Binary file
Binary file
data/images/logo.png ADDED
Binary file
@@ -36,11 +36,12 @@ module Fitting
36
36
  drafter_4_apib_path: @drafter_4_apib_path,
37
37
  drafter_4_yaml_path: @drafter_4_yaml_path
38
38
  )
39
- else Tomograph::Tomogram.new(
40
- prefix: @prefix,
41
- apib_path: @apib_path,
42
- drafter_yaml_path: @drafter_yaml_path
43
- )
39
+ else
40
+ Tomograph::Tomogram.new(
41
+ prefix: @prefix,
42
+ apib_path: @apib_path,
43
+ drafter_yaml_path: @drafter_yaml_path
44
+ )
44
45
  end
45
46
  end
46
47
 
@@ -43,13 +43,13 @@ module Fitting
43
43
  Tomograph::Tomogram.new(
44
44
  prefix: @prefix,
45
45
  crafter_apib_path: @crafter_apib_path,
46
- crafter_yaml_path: @crafter_yaml_path,
46
+ crafter_yaml_path: @crafter_yaml_path
47
47
  )
48
48
  elsif @drafter_4_apib_path || @drafter_4_yaml_path
49
49
  Tomograph::Tomogram.new(
50
50
  prefix: @prefix,
51
51
  drafter_4_apib_path: @drafter_4_apib_path,
52
- drafter_4_yaml_path: @drafter_4_yaml_path,
52
+ drafter_4_yaml_path: @drafter_4_yaml_path
53
53
  )
54
54
  else
55
55
  Tomograph::Tomogram.new(
@@ -15,17 +15,18 @@ module Fitting
15
15
 
16
16
  def inception(json_schema, combinations)
17
17
  json_schema.each do |key, value|
18
- if key == 'properties' and json_schema['required'] != value.keys
18
+ if (key == 'properties') && (json_schema['required'] != value.keys)
19
19
  schema = json_schema.dup
20
20
  one_of = schema.delete('required') || []
21
21
  schema['properties'].each_key do |property|
22
22
  next if one_of.include?(property)
23
+
23
24
  combinations.push([schema.merge('required' => one_of + [property]), "required.#{property}"])
24
25
  end
25
26
  elsif value.is_a?(Hash)
26
27
  com = inception(value, [])
27
28
  com.each do |combination|
28
- combination[0] = { key => value.merge(combination[0])}
29
+ combination[0] = { key => value.merge(combination[0]) }
29
30
  combination[1] = "#{key}.#{combination[1]}"
30
31
  end
31
32
  combinations += com
@@ -24,7 +24,7 @@ module Fitting
24
24
  elsif value.is_a?(Hash)
25
25
  com = inception(value, [])
26
26
  com.each do |combination|
27
- combination[0] = { key => value.merge(combination[0])}
27
+ combination[0] = { key => value.merge(combination[0]) }
28
28
  combination[1] = "#{key}.#{combination[1]}"
29
29
  end
30
30
  combinations += com
@@ -24,7 +24,7 @@ module Fitting
24
24
  elsif value.is_a?(Hash)
25
25
  com = inception(value, [])
26
26
  com.each do |combination|
27
- combination[0] = { key => value.merge(combination[0])}
27
+ combination[0] = { key => value.merge(combination[0]) }
28
28
  combination[1] = "#{key}.#{combination[1]}"
29
29
  end
30
30
  combinations += com
@@ -13,11 +13,7 @@ module Fitting
13
13
  end
14
14
  end
15
15
 
16
- attr_reader :json_schemas
17
-
18
- attr_reader :combinations
19
-
20
- attr_reader :flags
16
+ attr_reader :json_schemas, :combinations, :flags
21
17
 
22
18
  def update(response)
23
19
  index = 0
@@ -1,5 +1,3 @@
1
- require 'multi_json'
2
-
3
1
  module Fitting
4
2
  class Documentation
5
3
  def initialize(tomogram, white_list)
@@ -39,7 +39,8 @@ module Fitting
39
39
  if response.within_prefix?(config.prefix)
40
40
  @response = response
41
41
  return true if @response.ignored?(config.ignore_list)
42
- return @response.fully_validates.valid?
42
+
43
+ @response.fully_validates.valid?
43
44
  else
44
45
  true
45
46
  end
@@ -35,6 +35,7 @@ module Fitting
35
35
  return false if @white_list[path.to_s] == nil
36
36
  return true if @white_list[path.to_s] == []
37
37
  return true if @white_list[path.to_s].include?(method)
38
+
38
39
  false
39
40
  end
40
41
 
@@ -9,27 +9,25 @@ module Fitting
9
9
  end
10
10
 
11
11
  def fully_covered?
12
+ all_good_documented = false
13
+ all_good_response_documented = false
14
+ all_good_response_json_schemas = false
15
+ all_good_valid_json_schemas = false
16
+
12
17
  test_file_paths.each do |_key, requests|
13
- all_good = requests.all?(&:documented?)
14
- return false unless all_good
15
- end
16
- test_file_paths.each do |_key, requests|
17
- all_good = requests.all?(&:response_documented?)
18
- return false unless all_good
19
- end
20
- test_file_paths.each do |_key, requests|
21
- all_good = requests.all?(&:response_json_schemas?)
22
- return false unless all_good
23
- end
24
- test_file_paths.each do |_key, requests|
25
- all_good = requests.all?(&:valid_json_schemas?)
26
- return false unless all_good
18
+ all_good_documented = requests.all?(&:documented?)
19
+ all_good_response_documented = requests.all?(&:response_documented?)
20
+ all_good_response_json_schemas = requests.all?(&:response_json_schemas?)
21
+ all_good_valid_json_schemas = requests.all?(&:valid_json_schemas?)
27
22
  end
28
- true
23
+
24
+ all_good_documented && all_good_response_documented &&
25
+ all_good_response_json_schemas && all_good_valid_json_schemas
29
26
  end
30
27
 
31
28
  def test_file_paths
32
29
  return @test_file_paths if @test_file_paths
30
+
33
31
  @test_file_paths = {}
34
32
  white_unit.map do |request|
35
33
  @test_file_paths[request.test_file_path] ||= []
@@ -27,7 +27,7 @@ module Fitting
27
27
  }
28
28
  end
29
29
 
30
- def to_json
30
+ def to_json(*_args)
31
31
  JSON.dump(to_hash)
32
32
  end
33
33
 
@@ -10,11 +10,12 @@ module Fitting
10
10
 
11
11
  array = []
12
12
  Dir['fitting_tests/*.json'].each do |file|
13
- array += JSON.load(File.read(file))
13
+ array += JSON.parse(File.read(file))
14
14
  end
15
15
  @to_a = array.inject([]) do |res, tested_request|
16
16
  request = Fitting::Records::Spherical::Request.load(tested_request)
17
17
  next res unless request.path.to_s.start_with?(Fitting.configuration.prefix)
18
+
18
19
  res.push(request)
19
20
  end
20
21
  end
@@ -14,7 +14,7 @@ module Fitting
14
14
  def to_hash
15
15
  {
16
16
  status: status,
17
- body: JSON.load(body)
17
+ body: JSON.parse(body)
18
18
  }
19
19
  rescue JSON::ParserError
20
20
  {
@@ -23,7 +23,7 @@ module Fitting
23
23
  }
24
24
  end
25
25
 
26
- def to_json
26
+ def to_json(*_args)
27
27
  JSON.dump(to_hash)
28
28
  end
29
29
 
@@ -37,6 +37,7 @@ module Fitting
37
37
  @documented_requests ||= @all_documented_requests.inject([]) do |res, documented_request|
38
38
  next res unless @tested_request.method == documented_request.method &&
39
39
  documented_request.path.match(@tested_request.path.to_s)
40
+
40
41
  res.push(documented_request)
41
42
  end
42
43
  end
@@ -49,6 +50,7 @@ module Fitting
49
50
  @documented_responses ||= documented_requests.inject([]) do |res, documented_request|
50
51
  documented_request.responses.map do |documented_response|
51
52
  next unless documented_response['status'] == response.status.to_s
53
+
52
54
  res.push(documented_response)
53
55
  end
54
56
  end.flatten.compact
@@ -71,6 +73,7 @@ module Fitting
71
73
  def valid_json_schemas
72
74
  @valid_json_schemas ||= response_json_schemas.inject([]) do |res, json_schema|
73
75
  next res unless JSON::Validator.validate(json_schema, response.body)
76
+
74
77
  res.push(json_schema)
75
78
  end.flatten
76
79
  end
@@ -78,6 +81,7 @@ module Fitting
78
81
  def invalid_json_schemas
79
82
  @invalid_json_schemas ||= response_json_schemas.inject([]) do |res, json_schema|
80
83
  next res if JSON::Validator.validate(json_schema, response.body)
84
+
81
85
  res.push(
82
86
  json_schema: json_schema,
83
87
  fully_validate: JSON::Validator.fully_validate(json_schema, response.body)
@@ -6,9 +6,9 @@ module Fitting
6
6
  class Records
7
7
  class Tested
8
8
  class Request
9
- def initialize(env_response, test_title)
9
+ def initialize(env_response, metadata)
10
10
  @env_response = env_response
11
- @test_title = test_title
11
+ @metadata = metadata
12
12
  end
13
13
 
14
14
  def method
@@ -28,11 +28,11 @@ module Fitting
28
28
  end
29
29
 
30
30
  def test_path
31
- @test_path ||= @test_title[/#{'\(\.'}(.*?)#{'\)'}/m, 1] || @test_title[/#{'\.'}(.*?)#{'\"'}/m, 1]
31
+ @test_path ||= @metadata.fetch(:location)
32
32
  end
33
33
 
34
34
  def test_file_path
35
- @test_file_path ||= test_path.split(':').first
35
+ @test_file_path ||= @metadata.fetch(:file_path)
36
36
  end
37
37
 
38
38
  def to_spherical
@@ -14,12 +14,11 @@ module Fitting
14
14
 
15
15
  def valid_bodies
16
16
  @valid_bodies ||= @bodies.inject([]) do |res, tested_body|
17
- begin
18
- next res unless JSON::Validator.validate(@json_schema, tested_body)
19
- res.push(tested_body)
20
- rescue JSON::Schema::UriError
21
- res.push(tested_body)
22
- end
17
+ next res unless JSON::Validator.validate(@json_schema, tested_body)
18
+
19
+ res.push(tested_body)
20
+ rescue JSON::Schema::UriError
21
+ res.push(tested_body)
23
22
  end
24
23
  end
25
24
  end
@@ -17,50 +17,55 @@ module Fitting
17
17
 
18
18
  def bodies
19
19
  @bodies ||= @tested_bodies.inject([]) do |res, tested_body|
20
- begin
21
- next res unless JSON::Validator.validate(@json_schema, tested_body)
22
- res.push(tested_body)
23
- rescue JSON::Schema::UriError
24
- res.push(tested_body)
25
- end
20
+ next res unless JSON::Validator.validate(@json_schema, tested_body)
21
+
22
+ res.push(tested_body)
23
+ rescue JSON::Schema::UriError
24
+ res.push(tested_body)
26
25
  end
27
26
  end
28
27
 
29
28
  def combinations
30
29
  return @combinations if @combinations
30
+
31
31
  @combinations = []
32
32
  cover_json_schema = Fitting::Cover::JSONSchema.new(@json_schema)
33
33
  cover_json_schema.combi.map do |comb|
34
34
  @combinations.push(Fitting::Records::Unit::Combination.new(
35
- comb,
36
- bodies
37
- ))
35
+ comb,
36
+ bodies
37
+ ))
38
38
  end
39
39
  @combinations
40
40
  end
41
41
 
42
42
  def combinations_with_enum
43
43
  return @combinations_with_enum if @combinations_with_enum
44
+
44
45
  @combinations_with_enum = []
45
- qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi + Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi
46
+ qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi +
47
+ Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi
46
48
  qwe.map do |comb|
47
49
  @combinations_with_enum.push(Fitting::Records::Unit::Combination.new(
48
- comb,
49
- bodies
50
- ))
50
+ comb,
51
+ bodies
52
+ ))
51
53
  end
52
54
  @combinations_with_enum
53
55
  end
54
56
 
55
57
  def combinations_with_one_of
56
58
  return @combinations_with_one_of if @combinations_with_one_of
59
+
57
60
  @combinations_with_one_of = []
58
- qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi + Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi + Fitting::Cover::JSONSchemaOneOf.new(@json_schema).combi
61
+ qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi +
62
+ Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi +
63
+ Fitting::Cover::JSONSchemaOneOf.new(@json_schema).combi
59
64
  qwe.map do |comb|
60
65
  @combinations_with_one_of.push(Fitting::Records::Unit::Combination.new(
61
- comb,
62
- bodies
63
- ))
66
+ comb,
67
+ bodies
68
+ ))
64
69
  end
65
70
  @combinations_with_one_of
66
71
  end
@@ -79,26 +84,26 @@ module Fitting
79
84
 
80
85
  def cover_enum
81
86
  @cover_enum ||= if bodies == []
82
- 0
83
- else
84
- count = 0
85
- combinations_with_enum.map do |combination|
86
- count += 1 unless combination.valid_bodies == []
87
- end
88
- (count + 1) * 100 / (combinations_with_enum.size + 1)
89
- end
87
+ 0
88
+ else
89
+ count = 0
90
+ combinations_with_enum.map do |combination|
91
+ count += 1 unless combination.valid_bodies == []
92
+ end
93
+ (count + 1) * 100 / (combinations_with_enum.size + 1)
94
+ end
90
95
  end
91
96
 
92
97
  def cover_one_of
93
98
  @cover_one_of ||= if bodies == []
94
- 0
95
- else
96
- count = 0
97
- combinations_with_one_of.map do |combination|
98
- count += 1 unless combination.valid_bodies == []
99
- end
100
- (count + 1) * 100 / (combinations_with_one_of.size + 1)
101
- end
99
+ 0
100
+ else
101
+ count = 0
102
+ combinations_with_one_of.map do |combination|
103
+ count += 1 unless combination.valid_bodies == []
104
+ end
105
+ (count + 1) * 100 / (combinations_with_one_of.size + 1)
106
+ end
102
107
  end
103
108
  end
104
109
  end
@@ -27,6 +27,7 @@ module Fitting
27
27
  @tested_responses ||= @tested_requests.to_a.inject([]) do |res, tested_request|
28
28
  next res unless @documented_request.method == tested_request.method &&
29
29
  @documented_request.path.match(tested_request.path.to_s)
30
+
30
31
  res.push(tested_request.response)
31
32
  end
32
33
  end
@@ -22,6 +22,7 @@ module Fitting
22
22
  def tested_bodies
23
23
  @tested_bodies ||= @tested_responses.inject([]) do |res, tested_response|
24
24
  next res unless status == tested_response.status.to_s
25
+
25
26
  res.push(tested_response.body)
26
27
  end
27
28
  end
@@ -17,9 +17,7 @@ module Fitting
17
17
  @action.path.to_s
18
18
  end
19
19
 
20
- def responses
21
- @responses
22
- end
20
+ attr_reader :responses, :tests
23
21
 
24
22
  def add_test(test)
25
23
  @tests.push(test)
@@ -38,14 +36,13 @@ module Fitting
38
36
  @regexp = Regexp.new(str)
39
37
  end
40
38
 
41
- def tests
42
- @tests
43
- end
44
-
45
39
  def details
46
40
  {
47
- tests_without_responses: @tests.without_responses,
48
- responses_details: @responses.to_a.map { |r| {method: r.status, tests_size: r.tests.size, json_schema: r.id, combinations: r.details} }
41
+ tests_without_responses: @tests.without_responses,
42
+ responses_details: @responses.to_a.map do |r|
43
+ { method: r.status, tests_size: r.tests.size, json_schema: r.id,
44
+ combinations: r.details }
45
+ end
49
46
  }
50
47
  end
51
48
  end