fitting 2.17.0 → 2.18.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +31 -3
  3. data/CHANGELOG.md +5 -0
  4. data/fitting.gemspec +7 -7
  5. data/lib/fitting/configuration/legacy.rb +6 -5
  6. data/lib/fitting/configuration/yaml.rb +2 -2
  7. data/lib/fitting/cover/json_schema.rb +3 -2
  8. data/lib/fitting/cover/json_schema_enum.rb +1 -1
  9. data/lib/fitting/cover/json_schema_one_of.rb +1 -1
  10. data/lib/fitting/cover/response.rb +1 -5
  11. data/lib/fitting/documentation.rb +0 -2
  12. data/lib/fitting/matchers/response_matcher.rb +2 -1
  13. data/lib/fitting/records/documented/request.rb +1 -0
  14. data/lib/fitting/records/realized_unit.rb +13 -15
  15. data/lib/fitting/records/spherical/request.rb +1 -1
  16. data/lib/fitting/records/spherical/requests.rb +2 -1
  17. data/lib/fitting/records/spherical/response.rb +2 -2
  18. data/lib/fitting/records/test_unit/request.rb +4 -0
  19. data/lib/fitting/records/tested/request.rb +1 -1
  20. data/lib/fitting/records/unit/combination.rb +5 -6
  21. data/lib/fitting/records/unit/json_schema.rb +38 -33
  22. data/lib/fitting/records/unit/request.rb +1 -0
  23. data/lib/fitting/records/unit/response.rb +1 -0
  24. data/lib/fitting/report/action.rb +6 -9
  25. data/lib/fitting/report/actions.rb +7 -5
  26. data/lib/fitting/report/combination.rb +1 -15
  27. data/lib/fitting/report/combinations.rb +5 -6
  28. data/lib/fitting/report/console.rb +4 -3
  29. data/lib/fitting/report/prefix.rb +42 -51
  30. data/lib/fitting/report/prefixes.rb +3 -3
  31. data/lib/fitting/report/response.rb +17 -18
  32. data/lib/fitting/report/responses.rb +9 -8
  33. data/lib/fitting/report/test.rb +9 -11
  34. data/lib/fitting/report/tests.rb +10 -13
  35. data/lib/fitting/request.rb +0 -1
  36. data/lib/fitting/response.rb +4 -3
  37. data/lib/fitting/statistics/cover_error.rb +2 -0
  38. data/lib/fitting/statistics/cover_error_enum.rb +2 -0
  39. data/lib/fitting/statistics/cover_error_one_of.rb +2 -0
  40. data/lib/fitting/statistics/list.rb +5 -4
  41. data/lib/fitting/statistics/not_covered_responses.rb +1 -1
  42. data/lib/fitting/statistics/percent.rb +2 -1
  43. data/lib/fitting/statistics/template.rb +10 -8
  44. data/lib/fitting/storage/white_list.rb +7 -0
  45. data/lib/fitting/templates/realized_template.rb +2 -0
  46. data/lib/fitting/tests.rb +1 -1
  47. data/lib/fitting/version.rb +1 -1
  48. data/lib/fitting.rb +5 -2
  49. data/lib/tasks/fitting.rake +62 -54
  50. metadata +17 -49
@@ -22,29 +22,33 @@ namespace :fitting do
22
22
  end
23
23
 
24
24
  prefixes.to_a.map do |prefix|
25
+ next if prefix.skip?
26
+
25
27
  prefix.actions.to_a.map do |action|
26
28
  action.responses.join(action.tests)
27
- end unless prefix.skip?
29
+ end
28
30
  end
29
31
 
30
32
  prefixes.to_a.map do |prefix|
33
+ next if prefix.skip?
34
+
31
35
  prefix.actions.to_a.map do |action|
32
36
  action.responses.to_a.map do |response|
33
37
  response.combinations.join(response.tests)
34
38
  end
35
- end unless prefix.skip?
39
+ end
36
40
  end
37
41
 
38
42
  report = JSON.pretty_generate(
39
- {
40
- tests_without_prefixes: tests.without_prefixes,
41
- prefixes_details: prefixes.to_a.map { |p| p.details }
42
- }
43
+ {
44
+ tests_without_prefixes: tests.without_prefixes,
45
+ prefixes_details: prefixes.to_a.map(&:details)
46
+ }
43
47
  )
44
48
 
45
49
  destination = 'fitting'
46
50
  FileUtils.mkdir_p(destination)
47
- FileUtils.rm_r Dir.glob("#{destination}/*"), :force => true
51
+ FileUtils.rm_r Dir.glob("#{destination}/*"), force: true
48
52
  File.open('fitting/report.json', 'w') { |file| file.write(report) }
49
53
 
50
54
  gem_path = $LOAD_PATH.find { |i| i.include?('fitting') }
@@ -54,6 +58,8 @@ namespace :fitting do
54
58
  json_schemas = {}
55
59
  combinations = {}
56
60
  prefixes.to_a.map do |prefix|
61
+ next if prefix.skip?
62
+
57
63
  prefix.actions.to_a.map do |action|
58
64
  action.responses.to_a.map do |response|
59
65
  json_schemas.merge!(response.id => response.body)
@@ -61,24 +67,24 @@ namespace :fitting do
61
67
  combinations.merge!(combination.id => combination.json_schema)
62
68
  end
63
69
  end
64
- end unless prefix.skip?
70
+ end
65
71
  end
66
72
  File.open('fitting/json_schemas.json', 'w') { |file| file.write(JSON.pretty_generate(json_schemas)) }
67
73
  File.open('fitting/combinations.json', 'w') { |file| file.write(JSON.pretty_generate(combinations)) }
68
74
  File.open('fitting/tests.json', 'w') { |file| file.write(JSON.pretty_generate(tests.to_h)) }
69
75
 
70
- js_path = Dir["#{destination}/js/*"].find { |f| f[0..14] == 'fitting/js/app.' and f[-3..-1] == '.js' }
76
+ js_path = Dir["#{destination}/js/*"].find { |f| f[0..14] == 'fitting/js/app.' and f[-3..] == '.js' }
71
77
  js_file = File.read(js_path)
72
- new_js_file = js_file.gsub("{stub:\"prefixes report\"}", report)
73
- new_js_file = new_js_file.gsub("{stub:\"for action page\"}", report)
74
- new_js_file = new_js_file.gsub("{stub:\"json-schemas\"}", JSON.pretty_generate(json_schemas))
75
- new_js_file = new_js_file.gsub("{stub:\"combinations\"}", JSON.pretty_generate(combinations))
76
- new_js_file = new_js_file.gsub("{stub:\"tests\"}", JSON.pretty_generate(tests.to_h))
78
+ new_js_file = js_file.gsub('{stub:"prefixes report"}', report)
79
+ new_js_file = new_js_file.gsub('{stub:"for action page"}', report)
80
+ new_js_file = new_js_file.gsub('{stub:"json-schemas"}', JSON.pretty_generate(json_schemas))
81
+ new_js_file = new_js_file.gsub('{stub:"combinations"}', JSON.pretty_generate(combinations))
82
+ new_js_file = new_js_file.gsub('{stub:"tests"}', JSON.pretty_generate(tests.to_h))
77
83
  File.open(js_path, 'w') { |file| file.write(new_js_file) }
78
84
 
79
85
  console = Fitting::Report::Console.new(
80
- tests.without_prefixes,
81
- prefixes.to_a.map { |p| p.details }
86
+ tests.without_prefixes,
87
+ prefixes.to_a.map(&:details)
82
88
  )
83
89
 
84
90
  puts console.output
@@ -88,53 +94,53 @@ namespace :fitting do
88
94
  exit 0
89
95
 
90
96
  actions.map do |action|
91
- action.to_hash["responses"].map do |response|
97
+ action.to_hash['responses'].map do |response|
92
98
  response['combination'] ||= []
93
- combinations = Fitting::Cover::JSONSchema.new(response['body']).combi + Fitting::Cover::JSONSchemaEnum.new(response['body']).combi + Fitting::Cover::JSONSchemaOneOf.new(response['body']).combi
94
- if combinations != []
95
- combinations.map do |combination|
96
- response['combination'].push(
97
- {
98
- 'json_schema' => combination[0],
99
- 'type' => combination[1][0],
100
- 'combination' => combination[1][1],
101
- 'tests' => [],
102
- 'error' => []
103
- }
104
- )
105
- end
99
+ combinations = Fitting::Cover::JSONSchema.new(response['body']).combi +
100
+ Fitting::Cover::JSONSchemaEnum.new(response['body']).combi +
101
+ Fitting::Cover::JSONSchemaOneOf.new(response['body']).combi
102
+ next unless combinations != []
103
+
104
+ combinations.map do |combination|
105
+ response['combination'].push(
106
+ {
107
+ 'json_schema' => combination[0],
108
+ 'type' => combination[1][0],
109
+ 'combination' => combination[1][1],
110
+ 'tests' => [],
111
+ 'error' => []
112
+ }
113
+ )
106
114
  end
107
115
  end
108
116
  end
109
117
 
110
118
  actions.map do |action|
111
- action.to_hash["responses"].map do |response|
119
+ action.to_hash['responses'].map do |response|
112
120
  response['tests'] ||= []
113
121
  response['tests'].map do |test|
114
- if response['combination'][0]
115
- response['combination'].map do |combination|
116
- begin
117
- res = JSON::Validator.fully_validate(combination['json_schema'], test['response']['body'])
118
- if res == []
119
- combination['tests'].push(test)
120
- response['tests'] = response['tests'] - [test]
121
- next
122
- else
123
- combination['error'].push({test: test, error: res})
124
- end
125
- rescue JSON::Schema::SchemaError => error
126
- combination['error'].push({test: test, error: error})
127
- end
122
+ next unless response['combination'][0]
123
+
124
+ response['combination'].map do |combination|
125
+ res = JSON::Validator.fully_validate(combination['json_schema'], test['response']['body'])
126
+ if res == []
127
+ combination['tests'].push(test)
128
+ response['tests'] = response['tests'] - [test]
129
+ next
130
+ else
131
+ combination['error'].push({ test: test, error: res })
128
132
  end
133
+ rescue JSON::Schema::SchemaError => e
134
+ combination['error'].push({ test: test, error: e })
129
135
  end
130
136
  end
131
137
  end
132
138
  end
133
139
 
134
- actions_test = {actions: actions, tests: tests}
140
+ actions_test = { actions: actions, tests: tests }
135
141
 
136
142
  makedirs('fitting')
137
- File.open('fitting/old_report.json', 'w') { |file| file.write(MultiJson.dump(actions_test)) }
143
+ File.open('fitting/old_report.json', 'w') { |file| file.write(JSON.dump(actions_test)) }
138
144
  end
139
145
 
140
146
  # deprecated
@@ -154,7 +160,8 @@ namespace :fitting do
154
160
 
155
161
  desc 'Fitting documentation responses cover'
156
162
  task :documentation_responses, [:size] => :environment do |_, args|
157
- if args.size == 'xs'
163
+ case args.size
164
+ when 'xs'
158
165
  documented_unit = Fitting::Statistics::Template.new(
159
166
  Fitting::Records::Spherical::Requests.new,
160
167
  Fitting.configuration
@@ -165,7 +172,7 @@ namespace :fitting do
165
172
  puts 'Not all responses from the whitelist are covered!'
166
173
  exit 1
167
174
  end
168
- elsif args.size == 's'
175
+ when 's'
169
176
  documented_unit = Fitting::Statistics::Template.new(
170
177
  Fitting::Records::Spherical::Requests.new,
171
178
  Fitting.configuration,
@@ -177,7 +184,7 @@ namespace :fitting do
177
184
  puts 'Not all responses from the whitelist are covered!'
178
185
  exit 1
179
186
  end
180
- elsif args.size == 'm'
187
+ when 'm'
181
188
  documented_unit = Fitting::Statistics::Template.new(
182
189
  Fitting::Records::Spherical::Requests.new,
183
190
  Fitting.configuration,
@@ -189,7 +196,7 @@ namespace :fitting do
189
196
  puts 'Not all responses from the whitelist are covered!'
190
197
  exit 1
191
198
  end
192
- elsif args.size == 'l'
199
+ when 'l'
193
200
  documented_unit = Fitting::Statistics::Template.new(
194
201
  Fitting::Records::Spherical::Requests.new,
195
202
  Fitting.configuration,
@@ -208,19 +215,20 @@ namespace :fitting do
208
215
 
209
216
  desc 'Fitting documentation responses cover error'
210
217
  task :documentation_responses_error, [:size] => :environment do |_, args|
211
- if args.size == 's'
218
+ case args.size
219
+ when 's'
212
220
  documented_unit = Fitting::Statistics::TemplateCoverError.new(
213
221
  Fitting::Records::Spherical::Requests.new,
214
222
  Fitting.configuration
215
223
  )
216
224
  puts documented_unit.stats
217
- elsif args.size == 'm'
225
+ when 'm'
218
226
  documented_unit = Fitting::Statistics::TemplateCoverErrorEnum.new(
219
227
  Fitting::Records::Spherical::Requests.new,
220
228
  Fitting.configuration
221
229
  )
222
230
  puts documented_unit.stats
223
- elsif args.size == 'l'
231
+ when 'l'
224
232
  documented_unit = Fitting::Statistics::TemplateCoverErrorOneOf.new(
225
233
  Fitting::Records::Spherical::Requests.new,
226
234
  Fitting.configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitting
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.17.0
4
+ version: 2.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.efimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -30,20 +30,6 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.6.2
33
- - !ruby/object:Gem::Dependency
34
- name: multi_json
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.11'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.11'
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: tomograph
49
35
  requirement: !ruby/object:Gem::Requirement
@@ -84,100 +70,82 @@ dependencies:
84
70
  requirements:
85
71
  - - "~>"
86
72
  - !ruby/object:Gem::Version
87
- version: '8.2'
73
+ version: '11.1'
88
74
  - - ">="
89
75
  - !ruby/object:Gem::Version
90
- version: 8.2.1
76
+ version: 11.1.3
91
77
  type: :development
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - "~>"
96
82
  - !ruby/object:Gem::Version
97
- version: '8.2'
83
+ version: '11.1'
98
84
  - - ">="
99
85
  - !ruby/object:Gem::Version
100
- version: 8.2.1
86
+ version: 11.1.3
101
87
  - !ruby/object:Gem::Dependency
102
88
  name: rake
103
89
  requirement: !ruby/object:Gem::Requirement
104
90
  requirements:
105
91
  - - "~>"
106
92
  - !ruby/object:Gem::Version
107
- version: '12.3'
93
+ version: '13.0'
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: 12.3.3
96
+ version: 13.0.6
111
97
  type: :development
112
98
  prerelease: false
113
99
  version_requirements: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '12.3'
103
+ version: '13.0'
118
104
  - - ">="
119
105
  - !ruby/object:Gem::Version
120
- version: 12.3.3
106
+ version: 13.0.6
121
107
  - !ruby/object:Gem::Dependency
122
108
  name: rspec
123
109
  requirement: !ruby/object:Gem::Requirement
124
110
  requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- version: 3.4.0
128
111
  - - "~>"
129
112
  - !ruby/object:Gem::Version
130
- version: '3.4'
113
+ version: '3.10'
131
114
  type: :development
132
115
  prerelease: false
133
116
  version_requirements: !ruby/object:Gem::Requirement
134
117
  requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: 3.4.0
138
118
  - - "~>"
139
119
  - !ruby/object:Gem::Version
140
- version: '3.4'
120
+ version: '3.10'
141
121
  - !ruby/object:Gem::Dependency
142
122
  name: rubocop
143
123
  requirement: !ruby/object:Gem::Requirement
144
124
  requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: 0.49.1
148
125
  - - "~>"
149
126
  - !ruby/object:Gem::Version
150
- version: 0.49.1
127
+ version: 1.22.0
151
128
  type: :development
152
129
  prerelease: false
153
130
  version_requirements: !ruby/object:Gem::Requirement
154
131
  requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: 0.49.1
158
132
  - - "~>"
159
133
  - !ruby/object:Gem::Version
160
- version: 0.49.1
134
+ version: 1.22.0
161
135
  - !ruby/object:Gem::Dependency
162
136
  name: simplecov
163
137
  requirement: !ruby/object:Gem::Requirement
164
138
  requirements:
165
139
  - - "~>"
166
140
  - !ruby/object:Gem::Version
167
- version: '0.11'
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- version: 0.11.2
141
+ version: '0.21'
171
142
  type: :development
172
143
  prerelease: false
173
144
  version_requirements: !ruby/object:Gem::Requirement
174
145
  requirements:
175
146
  - - "~>"
176
147
  - !ruby/object:Gem::Version
177
- version: '0.11'
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: 0.11.2
148
+ version: '0.21'
181
149
  description: Coverage API Blueprint, Swagger and OpenAPI with RSpec for easily make
182
150
  high-quality API and documenatiton
183
151
  email:
@@ -304,7 +272,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
304
272
  requirements:
305
273
  - - ">="
306
274
  - !ruby/object:Gem::Version
307
- version: '0'
275
+ version: 2.6.0
308
276
  required_rubygems_version: !ruby/object:Gem::Requirement
309
277
  requirements:
310
278
  - - ">="