fitting 2.18.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -11
- data/CHANGELOG.md +21 -0
- data/README.md +46 -6
- data/fitting.gemspec +3 -1
- data/lib/fitting/configuration.rb +11 -41
- data/lib/fitting/cover/json_schema.rb +4 -2
- data/lib/fitting/cover/json_schema_enum.rb +4 -2
- data/lib/fitting/cover/json_schema_one_of.rb +4 -2
- data/lib/fitting/railtie.rb +1 -0
- data/lib/fitting/records/documented/request.rb +1 -15
- data/lib/fitting/records/spherical/requests.rb +1 -1
- data/lib/fitting/records/tested/request.rb +11 -11
- data/lib/fitting/records/tested/response.rb +4 -4
- data/lib/fitting/report/actions.rb +4 -0
- data/lib/fitting/report/combinations.rb +1 -1
- data/lib/fitting/report/console.rb +35 -15
- data/lib/fitting/report/prefix.rb +20 -41
- data/lib/fitting/report/prefixes.rb +7 -8
- data/lib/fitting/report/response.rb +0 -3
- data/lib/fitting/report/tests.rb +23 -10
- data/lib/fitting/storage/responses.rb +5 -9
- data/lib/fitting/tests.rb +12 -4
- data/lib/fitting/version.rb +1 -1
- data/lib/fitting.rb +38 -43
- data/lib/tasks/fitting.rake +3 -186
- data/lib/tasks/fitting_outgoing.rake +91 -0
- metadata +28 -45
- data/lib/fitting/configuration/legacy.rb +0 -61
- data/lib/fitting/configuration/yaml.rb +0 -89
- data/lib/fitting/cover/response.rb +0 -37
- data/lib/fitting/documentation.rb +0 -56
- data/lib/fitting/matchers/response_matcher.rb +0 -96
- data/lib/fitting/records/realized_unit.rb +0 -52
- data/lib/fitting/records/test_unit/request.rb +0 -98
- data/lib/fitting/records/unit/combination.rb +0 -27
- data/lib/fitting/records/unit/json_schema.rb +0 -111
- data/lib/fitting/records/unit/request.rb +0 -37
- data/lib/fitting/records/unit/response.rb +0 -32
- data/lib/fitting/request.rb +0 -38
- data/lib/fitting/response/fully_validates.rb +0 -34
- data/lib/fitting/response.rb +0 -88
- data/lib/fitting/statistics/analysis.rb +0 -25
- data/lib/fitting/statistics/cover_error.rb +0 -29
- data/lib/fitting/statistics/cover_error_enum.rb +0 -29
- data/lib/fitting/statistics/cover_error_one_of.rb +0 -29
- data/lib/fitting/statistics/great.rb +0 -13
- data/lib/fitting/statistics/list.rb +0 -55
- data/lib/fitting/statistics/lists.rb +0 -53
- data/lib/fitting/statistics/measurement.rb +0 -92
- data/lib/fitting/statistics/measurement_cover.rb +0 -92
- data/lib/fitting/statistics/measurement_cover_enum.rb +0 -92
- data/lib/fitting/statistics/measurement_cover_one_of.rb +0 -92
- data/lib/fitting/statistics/not_covered_responses.rb +0 -13
- data/lib/fitting/statistics/percent.rb +0 -20
- data/lib/fitting/statistics/requests_stats.rb +0 -40
- data/lib/fitting/statistics/responses_stats.rb +0 -32
- data/lib/fitting/statistics/template.rb +0 -117
- data/lib/fitting/statistics/template_cover_error.rb +0 -50
- data/lib/fitting/statistics/template_cover_error_enum.rb +0 -50
- data/lib/fitting/statistics/template_cover_error_one_of.rb +0 -50
- data/lib/fitting/statistics.rb +0 -25
- data/lib/fitting/storage/white_list.rb +0 -158
- data/lib/fitting/templates/realized_template.rb +0 -49
- data/lib/fitting/view/report.html.haml +0 -16
- data/lib/fitting/view/style.css +0 -47
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- d.efimov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.6.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: terminal-table
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.0.2
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.0.2
|
33
53
|
- !ruby/object:Gem::Dependency
|
34
54
|
name: tomograph
|
35
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,14 +142,14 @@ dependencies:
|
|
122
142
|
name: rubocop
|
123
143
|
requirement: !ruby/object:Gem::Requirement
|
124
144
|
requirements:
|
125
|
-
- - "
|
145
|
+
- - ">="
|
126
146
|
- !ruby/object:Gem::Version
|
127
147
|
version: 1.22.0
|
128
148
|
type: :development
|
129
149
|
prerelease: false
|
130
150
|
version_requirements: !ruby/object:Gem::Requirement
|
131
151
|
requirements:
|
132
|
-
- - "
|
152
|
+
- - ">="
|
133
153
|
- !ruby/object:Gem::Version
|
134
154
|
version: 1.22.0
|
135
155
|
- !ruby/object:Gem::Dependency
|
@@ -173,27 +193,16 @@ files:
|
|
173
193
|
- images/logo.png
|
174
194
|
- lib/fitting.rb
|
175
195
|
- lib/fitting/configuration.rb
|
176
|
-
- lib/fitting/configuration/legacy.rb
|
177
|
-
- lib/fitting/configuration/yaml.rb
|
178
196
|
- lib/fitting/cover/json_schema.rb
|
179
197
|
- lib/fitting/cover/json_schema_enum.rb
|
180
198
|
- lib/fitting/cover/json_schema_one_of.rb
|
181
|
-
- lib/fitting/cover/response.rb
|
182
|
-
- lib/fitting/documentation.rb
|
183
|
-
- lib/fitting/matchers/response_matcher.rb
|
184
199
|
- lib/fitting/railtie.rb
|
185
200
|
- lib/fitting/records/documented/request.rb
|
186
|
-
- lib/fitting/records/realized_unit.rb
|
187
201
|
- lib/fitting/records/spherical/request.rb
|
188
202
|
- lib/fitting/records/spherical/requests.rb
|
189
203
|
- lib/fitting/records/spherical/response.rb
|
190
|
-
- lib/fitting/records/test_unit/request.rb
|
191
204
|
- lib/fitting/records/tested/request.rb
|
192
205
|
- lib/fitting/records/tested/response.rb
|
193
|
-
- lib/fitting/records/unit/combination.rb
|
194
|
-
- lib/fitting/records/unit/json_schema.rb
|
195
|
-
- lib/fitting/records/unit/request.rb
|
196
|
-
- lib/fitting/records/unit/response.rb
|
197
206
|
- lib/fitting/report/action.rb
|
198
207
|
- lib/fitting/report/actions.rb
|
199
208
|
- lib/fitting/report/combination.rb
|
@@ -205,37 +214,11 @@ files:
|
|
205
214
|
- lib/fitting/report/responses.rb
|
206
215
|
- lib/fitting/report/test.rb
|
207
216
|
- lib/fitting/report/tests.rb
|
208
|
-
- lib/fitting/request.rb
|
209
|
-
- lib/fitting/response.rb
|
210
|
-
- lib/fitting/response/fully_validates.rb
|
211
|
-
- lib/fitting/statistics.rb
|
212
|
-
- lib/fitting/statistics/analysis.rb
|
213
|
-
- lib/fitting/statistics/cover_error.rb
|
214
|
-
- lib/fitting/statistics/cover_error_enum.rb
|
215
|
-
- lib/fitting/statistics/cover_error_one_of.rb
|
216
|
-
- lib/fitting/statistics/great.rb
|
217
|
-
- lib/fitting/statistics/list.rb
|
218
|
-
- lib/fitting/statistics/lists.rb
|
219
|
-
- lib/fitting/statistics/measurement.rb
|
220
|
-
- lib/fitting/statistics/measurement_cover.rb
|
221
|
-
- lib/fitting/statistics/measurement_cover_enum.rb
|
222
|
-
- lib/fitting/statistics/measurement_cover_one_of.rb
|
223
|
-
- lib/fitting/statistics/not_covered_responses.rb
|
224
|
-
- lib/fitting/statistics/percent.rb
|
225
|
-
- lib/fitting/statistics/requests_stats.rb
|
226
|
-
- lib/fitting/statistics/responses_stats.rb
|
227
|
-
- lib/fitting/statistics/template.rb
|
228
|
-
- lib/fitting/statistics/template_cover_error.rb
|
229
|
-
- lib/fitting/statistics/template_cover_error_enum.rb
|
230
|
-
- lib/fitting/statistics/template_cover_error_one_of.rb
|
231
217
|
- lib/fitting/storage/responses.rb
|
232
|
-
- lib/fitting/storage/white_list.rb
|
233
|
-
- lib/fitting/templates/realized_template.rb
|
234
218
|
- lib/fitting/tests.rb
|
235
219
|
- lib/fitting/version.rb
|
236
|
-
- lib/fitting/view/report.html.haml
|
237
|
-
- lib/fitting/view/style.css
|
238
220
|
- lib/tasks/fitting.rake
|
221
|
+
- lib/tasks/fitting_outgoing.rake
|
239
222
|
- lib/templates/bomboniere/.gitignore
|
240
223
|
- lib/templates/bomboniere/.tool-versions
|
241
224
|
- lib/templates/bomboniere/README.md
|
@@ -264,7 +247,7 @@ homepage: https://github.com/funbox/fitting
|
|
264
247
|
licenses:
|
265
248
|
- MIT
|
266
249
|
metadata: {}
|
267
|
-
post_install_message:
|
250
|
+
post_install_message:
|
268
251
|
rdoc_options: []
|
269
252
|
require_paths:
|
270
253
|
- lib
|
@@ -280,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
263
|
version: '0'
|
281
264
|
requirements: []
|
282
265
|
rubygems_version: 3.0.1
|
283
|
-
signing_key:
|
266
|
+
signing_key:
|
284
267
|
specification_version: 4
|
285
268
|
summary: Coverage API Blueprint, Swagger and OpenAPI with RSpec
|
286
269
|
test_files: []
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'tomograph'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
class Configuration
|
5
|
-
class Legacy
|
6
|
-
attr_accessor :apib_path,
|
7
|
-
:drafter_yaml_path,
|
8
|
-
:crafter_apib_path,
|
9
|
-
:crafter_yaml_path,
|
10
|
-
:drafter_4_apib_path,
|
11
|
-
:drafter_4_yaml_path,
|
12
|
-
:strict,
|
13
|
-
:prefix,
|
14
|
-
:white_list,
|
15
|
-
:resource_white_list,
|
16
|
-
:ignore_list,
|
17
|
-
:include_resources,
|
18
|
-
:include_actions
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
@strict = false
|
22
|
-
@prefix = ''
|
23
|
-
@ignore_list = []
|
24
|
-
end
|
25
|
-
|
26
|
-
def tomogram
|
27
|
-
@tomogram ||= if @crafter_apib_path || @crafter_yaml_path
|
28
|
-
Tomograph::Tomogram.new(
|
29
|
-
prefix: @prefix,
|
30
|
-
crafter_apib_path: @crafter_apib_path,
|
31
|
-
crafter_yaml_path: @crafter_yaml_path
|
32
|
-
)
|
33
|
-
elsif @drafter_4_apib_path || @drafter_4_yaml_path
|
34
|
-
Tomograph::Tomogram.new(
|
35
|
-
prefix: @prefix,
|
36
|
-
drafter_4_apib_path: @drafter_4_apib_path,
|
37
|
-
drafter_4_yaml_path: @drafter_4_yaml_path
|
38
|
-
)
|
39
|
-
else
|
40
|
-
Tomograph::Tomogram.new(
|
41
|
-
prefix: @prefix,
|
42
|
-
apib_path: @apib_path,
|
43
|
-
drafter_yaml_path: @drafter_yaml_path
|
44
|
-
)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def title
|
49
|
-
'fitting'
|
50
|
-
end
|
51
|
-
|
52
|
-
def stats_path
|
53
|
-
'fitting/stats'
|
54
|
-
end
|
55
|
-
|
56
|
-
def not_covered_path
|
57
|
-
'fitting/not_covered'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'tomograph'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
class Configuration
|
5
|
-
class Yaml
|
6
|
-
attr_reader :title
|
7
|
-
attr_accessor :apib_path,
|
8
|
-
:drafter_yaml_path,
|
9
|
-
:crafter_apib_path,
|
10
|
-
:crafter_yaml_path,
|
11
|
-
:drafter_4_apib_path,
|
12
|
-
:drafter_4_yaml_path,
|
13
|
-
:tomogram_json_path,
|
14
|
-
:strict,
|
15
|
-
:prefix,
|
16
|
-
:white_list,
|
17
|
-
:resource_white_list,
|
18
|
-
:ignore_list,
|
19
|
-
:include_resources,
|
20
|
-
:include_actions
|
21
|
-
|
22
|
-
def initialize(yaml, title = 'fitting')
|
23
|
-
@apib_path = yaml['apib_path']
|
24
|
-
@drafter_yaml_path = yaml['drafter_yaml_path']
|
25
|
-
@crafter_apib_path = yaml['crafter_apib_path']
|
26
|
-
@crafter_yaml_path = yaml['crafter_yaml_path']
|
27
|
-
@drafter_4_apib_path = yaml['drafter_4_apib_path']
|
28
|
-
@drafter_4_yaml_path = yaml['drafter_4_yaml_path']
|
29
|
-
@tomogram_json_path = yaml['tomogram_json_path']
|
30
|
-
@strict = yaml['strict']
|
31
|
-
@prefix = yaml['prefix']
|
32
|
-
@white_list = yaml['white_list']
|
33
|
-
@resource_white_list = yaml['resource_white_list']
|
34
|
-
@ignore_list = yaml['ignore_list']
|
35
|
-
@include_resources = yaml['include_resources']
|
36
|
-
@include_actions = yaml['include_actions']
|
37
|
-
@title = title
|
38
|
-
default
|
39
|
-
end
|
40
|
-
|
41
|
-
def tomogram
|
42
|
-
@tomogram ||= if @crafter_yaml_path || @crafter_apib_path
|
43
|
-
Tomograph::Tomogram.new(
|
44
|
-
prefix: @prefix,
|
45
|
-
crafter_apib_path: @crafter_apib_path,
|
46
|
-
crafter_yaml_path: @crafter_yaml_path
|
47
|
-
)
|
48
|
-
elsif @drafter_4_apib_path || @drafter_4_yaml_path
|
49
|
-
Tomograph::Tomogram.new(
|
50
|
-
prefix: @prefix,
|
51
|
-
drafter_4_apib_path: @drafter_4_apib_path,
|
52
|
-
drafter_4_yaml_path: @drafter_4_yaml_path
|
53
|
-
)
|
54
|
-
else
|
55
|
-
Tomograph::Tomogram.new(
|
56
|
-
prefix: @prefix,
|
57
|
-
apib_path: @apib_path,
|
58
|
-
drafter_yaml_path: @drafter_yaml_path,
|
59
|
-
tomogram_json_path: @tomogram_json_path
|
60
|
-
)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def stats_path
|
65
|
-
if @title == 'fitting'
|
66
|
-
'fitting/stats'
|
67
|
-
else
|
68
|
-
"fitting/#{@title}/stats"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def not_covered_path
|
73
|
-
if @title == 'fitting'
|
74
|
-
'fitting/not_covered'
|
75
|
-
else
|
76
|
-
"fitting/#{@title}/not_covered"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def default
|
83
|
-
@strict ||= false if @strict.nil?
|
84
|
-
@prefix ||= ''
|
85
|
-
@ignore_list ||= []
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'fitting/cover/json_schema'
|
2
|
-
require 'json-schema'
|
3
|
-
|
4
|
-
module Fitting
|
5
|
-
class Cover
|
6
|
-
class Response
|
7
|
-
def initialize(response)
|
8
|
-
@cover_json_schemas = Fitting::Cover::JSONSchema.new(response.json_schema)
|
9
|
-
@json_schemas = @cover_json_schemas.json_schemas + [response.json_schema]
|
10
|
-
@combinations = @cover_json_schemas.combinations
|
11
|
-
@flags = @cover_json_schemas.json_schemas.map do |json_schema|
|
12
|
-
JSON::Validator.validate(json_schema, response.body)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
attr_reader :json_schemas, :combinations, :flags
|
17
|
-
|
18
|
-
def update(response)
|
19
|
-
index = 0
|
20
|
-
@cover_json_schemas.json_schemas.map do |json_schema|
|
21
|
-
flag = JSON::Validator.validate(json_schema, response.body)
|
22
|
-
@flags[index] = @flags[index] || flag
|
23
|
-
index += 1
|
24
|
-
end
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_hash
|
29
|
-
{
|
30
|
-
'json_schemas' => json_schemas,
|
31
|
-
'combinations' => combinations,
|
32
|
-
'flags' => flags
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Fitting
|
2
|
-
class Documentation
|
3
|
-
def initialize(tomogram, white_list)
|
4
|
-
@tomogram = tomogram
|
5
|
-
@white_list = white_list
|
6
|
-
end
|
7
|
-
|
8
|
-
def black
|
9
|
-
if @white_list
|
10
|
-
all.select do |response|
|
11
|
-
black?(response)
|
12
|
-
end
|
13
|
-
else
|
14
|
-
[]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def white
|
19
|
-
if @white_list
|
20
|
-
all.select do |response|
|
21
|
-
white?(response)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
all
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def all
|
29
|
-
@all ||= @tomogram.to_hash.each_with_object([]) do |request, routes|
|
30
|
-
responses(request).map do |status, indexes|
|
31
|
-
indexes.times do |index|
|
32
|
-
route = "#{request['method']}\t#{request['path']} #{status} #{index}"
|
33
|
-
routes.push(route)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end.uniq
|
37
|
-
end
|
38
|
-
|
39
|
-
def responses(request)
|
40
|
-
request['responses'].each_with_object({}) do |response, responses|
|
41
|
-
responses[response['status']] ||= 0
|
42
|
-
responses[response['status']] += 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def black?(response)
|
47
|
-
data = response.split(' ')
|
48
|
-
data[1] && !@white_list[data[1]] || (@white_list[data[1]] != [] && !@white_list[data[1]].include?(data[0]))
|
49
|
-
end
|
50
|
-
|
51
|
-
def white?(response)
|
52
|
-
data = response.split(' ')
|
53
|
-
data[1] && @white_list[data[1]] && (@white_list[data[1]] == [] || @white_list[data[1]].include?(data[0]))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'fitting/response'
|
2
|
-
require 'fitting/configuration'
|
3
|
-
|
4
|
-
module Fitting
|
5
|
-
module Matchers
|
6
|
-
class Response
|
7
|
-
def matches?(response)
|
8
|
-
if Fitting.configuration.is_a?(Array)
|
9
|
-
Fitting.configuration.all? do |config|
|
10
|
-
one_match(response, config)
|
11
|
-
end
|
12
|
-
else
|
13
|
-
one_match(response, Fitting.configuration)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def ===(other)
|
18
|
-
matches?(other)
|
19
|
-
end
|
20
|
-
|
21
|
-
def failure_message
|
22
|
-
unless @response.documented?
|
23
|
-
return "response not documented\n"\
|
24
|
-
"got: #{@response.real_request_with_status}"
|
25
|
-
end
|
26
|
-
|
27
|
-
return nil if @response.fully_validates.valid?
|
28
|
-
|
29
|
-
"response does not conform to json-schema\n"\
|
30
|
-
"schemas: \n#{@response.expected}\n\n"\
|
31
|
-
"got: #{@response.got}\n\n"\
|
32
|
-
"errors: \n#{@response.fully_validates}\n"
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def one_match(response, config)
|
38
|
-
response = Fitting::Response.new(response, config.tomogram)
|
39
|
-
if response.within_prefix?(config.prefix)
|
40
|
-
@response = response
|
41
|
-
return true if @response.ignored?(config.ignore_list)
|
42
|
-
|
43
|
-
@response.fully_validates.valid?
|
44
|
-
else
|
45
|
-
true
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class StrictResponse
|
51
|
-
def matches?(response)
|
52
|
-
if Fitting.configuration.is_a?(Array)
|
53
|
-
one_match(response, Fitting.configuration[0])
|
54
|
-
else
|
55
|
-
one_match(response, Fitting.configuration)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def ===(other)
|
60
|
-
matches?(other)
|
61
|
-
end
|
62
|
-
|
63
|
-
def failure_message
|
64
|
-
unless @response.documented?
|
65
|
-
return "response not documented\n"\
|
66
|
-
"got: #{@response.real_request_with_status}"
|
67
|
-
end
|
68
|
-
|
69
|
-
return nil if @response.strict_fully_validates.valid?
|
70
|
-
|
71
|
-
"response does not conform to json-schema\n"\
|
72
|
-
"schemas: \n#{@response.expected}\n\n"\
|
73
|
-
"got: #{@response.got}\n\n"\
|
74
|
-
"errors: \n#{@response.strict_fully_validates}\n"
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def one_match(response, config)
|
80
|
-
@response = Fitting::Response.new(
|
81
|
-
response,
|
82
|
-
config.tomogram
|
83
|
-
)
|
84
|
-
@response.strict_fully_validates.valid?
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def match_schema
|
89
|
-
Response.new
|
90
|
-
end
|
91
|
-
|
92
|
-
def strictly_match_schema
|
93
|
-
StrictResponse.new
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'fitting/records/test_unit/request'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
class Records
|
5
|
-
class RealizedUnit
|
6
|
-
def initialize(realized_requests, documented_requests)
|
7
|
-
@realized_requests = realized_requests
|
8
|
-
@documented_requests = documented_requests
|
9
|
-
end
|
10
|
-
|
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
|
-
|
17
|
-
test_file_paths.each do |_key, requests|
|
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?)
|
22
|
-
end
|
23
|
-
|
24
|
-
all_good_documented && all_good_response_documented &&
|
25
|
-
all_good_response_json_schemas && all_good_valid_json_schemas
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_file_paths
|
29
|
-
return @test_file_paths if @test_file_paths
|
30
|
-
|
31
|
-
@test_file_paths = {}
|
32
|
-
white_unit.map do |request|
|
33
|
-
@test_file_paths[request.test_file_path] ||= []
|
34
|
-
@test_file_paths[request.test_file_path].push(request)
|
35
|
-
end
|
36
|
-
@test_file_paths
|
37
|
-
end
|
38
|
-
|
39
|
-
def all_documented_requests
|
40
|
-
@all_documented_requests ||= @documented_requests.to_a.inject([]) do |res, tomogram_request|
|
41
|
-
res.push(Fitting::Records::Documented::Request.new(tomogram_request, nil))
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def white_unit
|
46
|
-
@white_unit_requests ||= @realized_requests.to_a.inject([]) do |res, tested_request|
|
47
|
-
res.push(Fitting::Records::TestUnit::Request.new(tested_request, all_documented_requests))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'json-schema'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
class Records
|
5
|
-
class TestUnit
|
6
|
-
class Request
|
7
|
-
def initialize(tested_request, all_documented_requests)
|
8
|
-
@tested_request = tested_request
|
9
|
-
@all_documented_requests = all_documented_requests
|
10
|
-
end
|
11
|
-
|
12
|
-
def method
|
13
|
-
@method ||= @tested_request.method
|
14
|
-
end
|
15
|
-
|
16
|
-
def path
|
17
|
-
@path ||= @tested_request.path
|
18
|
-
end
|
19
|
-
|
20
|
-
def body
|
21
|
-
@body ||= @tested_request.body
|
22
|
-
end
|
23
|
-
|
24
|
-
def response
|
25
|
-
@response ||= @tested_request.response
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_path
|
29
|
-
@test_path ||= @tested_request.title
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_file_path
|
33
|
-
@test_file_path ||= @tested_request.group
|
34
|
-
end
|
35
|
-
|
36
|
-
def documented_requests
|
37
|
-
@documented_requests ||= @all_documented_requests.inject([]) do |res, documented_request|
|
38
|
-
next res unless @tested_request.method == documented_request.method &&
|
39
|
-
documented_request.path.match(@tested_request.path.to_s)
|
40
|
-
|
41
|
-
res.push(documented_request)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def documented?
|
46
|
-
@documented ||= documented_requests.present?
|
47
|
-
end
|
48
|
-
|
49
|
-
def documented_responses
|
50
|
-
@documented_responses ||= documented_requests.inject([]) do |res, documented_request|
|
51
|
-
documented_request.responses.map do |documented_response|
|
52
|
-
next unless documented_response['status'] == response.status.to_s
|
53
|
-
|
54
|
-
res.push(documented_response)
|
55
|
-
end
|
56
|
-
end.flatten.compact
|
57
|
-
end
|
58
|
-
|
59
|
-
def response_documented?
|
60
|
-
@response_documented ||= documented_responses.present?
|
61
|
-
end
|
62
|
-
|
63
|
-
def response_json_schemas
|
64
|
-
@response_json_schemas ||= documented_responses.inject([]) do |res, documented_response|
|
65
|
-
res.push(documented_response['json_schemas'])
|
66
|
-
end.flatten
|
67
|
-
end
|
68
|
-
|
69
|
-
def response_json_schemas?
|
70
|
-
@response_json_schemas_present ||= response_json_schemas.present?
|
71
|
-
end
|
72
|
-
|
73
|
-
def valid_json_schemas
|
74
|
-
@valid_json_schemas ||= response_json_schemas.inject([]) do |res, json_schema|
|
75
|
-
next res unless JSON::Validator.validate(json_schema, response.body)
|
76
|
-
|
77
|
-
res.push(json_schema)
|
78
|
-
end.flatten
|
79
|
-
end
|
80
|
-
|
81
|
-
def invalid_json_schemas
|
82
|
-
@invalid_json_schemas ||= response_json_schemas.inject([]) do |res, json_schema|
|
83
|
-
next res if JSON::Validator.validate(json_schema, response.body)
|
84
|
-
|
85
|
-
res.push(
|
86
|
-
json_schema: json_schema,
|
87
|
-
fully_validate: JSON::Validator.fully_validate(json_schema, response.body)
|
88
|
-
)
|
89
|
-
end.flatten
|
90
|
-
end
|
91
|
-
|
92
|
-
def valid_json_schemas?
|
93
|
-
@valid_json_schemas_present ||= valid_json_schemas.present?
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'json-schema'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
class Records
|
5
|
-
class Unit
|
6
|
-
class Combination
|
7
|
-
attr_reader :description, :json_schema, :bodies
|
8
|
-
|
9
|
-
def initialize(comb, bodies)
|
10
|
-
@description = comb[1]
|
11
|
-
@json_schema = comb[0]
|
12
|
-
@bodies = bodies
|
13
|
-
end
|
14
|
-
|
15
|
-
def valid_bodies
|
16
|
-
@valid_bodies ||= @bodies.inject([]) do |res, tested_body|
|
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)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|