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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd5c81c74bb7ce55eb47ff049359ea161454e320cdca8f44cd24dbfcc24f170e
|
4
|
+
data.tar.gz: 9535573515ab8652257ac1fbf76466e7e014f52460be6d76375625987814340a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8207fe1f0c4339a7e60978fc154a04525b0b0cd87a47e99c9007dc32fc302855b6b3078840681b020d79af6f7f19783266bd7d72efc1d2bc216271e8131682fa
|
7
|
+
data.tar.gz: 13bb82c38b30a054c8f37d3182001248af3e192646507f5737305b12529e01f291382697a42821e67c70360f17ed2df0836a004b57e5a02207b9bb91c2b45eee
|
data/.rubocop.yml
CHANGED
@@ -13,27 +13,18 @@ Style/FrozenStringLiteralComment:
|
|
13
13
|
Metrics/BlockLength:
|
14
14
|
Enabled: false
|
15
15
|
|
16
|
-
Style/CaseEquality:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/NilComparison:
|
20
|
-
Enabled: false
|
21
|
-
|
22
16
|
Naming/MemoizedInstanceVariableName:
|
23
17
|
Enabled: false
|
24
18
|
|
25
|
-
Lint/UnreachableCode:
|
26
|
-
Enabled: false
|
27
|
-
|
28
19
|
Metrics/MethodLength:
|
29
|
-
Max:
|
20
|
+
Max: 60
|
30
21
|
|
31
22
|
# FIXME
|
32
23
|
Metrics/AbcSize:
|
33
24
|
Max: 50
|
34
25
|
|
35
26
|
Metrics/PerceivedComplexity:
|
36
|
-
Max:
|
27
|
+
Max: 30
|
37
28
|
|
38
29
|
Metrics/CyclomaticComplexity:
|
39
30
|
Max: 20
|
@@ -46,3 +37,6 @@ Metrics/ClassLength:
|
|
46
37
|
|
47
38
|
Lint/UselessAssignment:
|
48
39
|
Enabled: false
|
40
|
+
|
41
|
+
Style/ZeroLengthPredicate:
|
42
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
### 3.0.0 - 2021-12-09
|
4
|
+
|
5
|
+
* features
|
6
|
+
* update configuration
|
7
|
+
* support outgoing WebMock request
|
8
|
+
|
9
|
+
### 2.18.3 - 2021-11-12
|
10
|
+
|
11
|
+
* patch
|
12
|
+
* added print table console [#121](https://github.com/funbox/fitting/issues/121)
|
13
|
+
|
14
|
+
### 2.18.2 - 2021-11-09
|
15
|
+
|
16
|
+
* patch
|
17
|
+
* remove legacy [#123](https://github.com/funbox/fitting/issues/123)
|
18
|
+
|
19
|
+
### 2.18.1 - 2021-10-12
|
20
|
+
|
21
|
+
* patch
|
22
|
+
* fix bugs and refactoring
|
23
|
+
|
3
24
|
### 2.18.0 - 2021-09-29
|
4
25
|
|
5
26
|
* patch
|
data/README.md
CHANGED
@@ -48,7 +48,9 @@ Also Swagger
|
|
48
48
|
```yaml
|
49
49
|
prefixes:
|
50
50
|
- name: /api/v1
|
51
|
-
|
51
|
+
type: openapi2
|
52
|
+
schema_paths:
|
53
|
+
- doc.json
|
52
54
|
```
|
53
55
|
|
54
56
|
### OpenAPI 3.0
|
@@ -57,7 +59,9 @@ Also OpenAPI
|
|
57
59
|
```yaml
|
58
60
|
prefixes:
|
59
61
|
- name: /api/v1
|
60
|
-
|
62
|
+
type: openapi3
|
63
|
+
schema_paths:
|
64
|
+
- doc.yaml
|
61
65
|
```
|
62
66
|
|
63
67
|
### API Blueprint
|
@@ -75,7 +79,9 @@ and then
|
|
75
79
|
```yaml
|
76
80
|
prefixes:
|
77
81
|
- name: /api/v1
|
78
|
-
|
82
|
+
type: drafter
|
83
|
+
schema_paths:
|
84
|
+
- doc.yaml
|
79
85
|
```
|
80
86
|
|
81
87
|
### Tomograph
|
@@ -85,7 +91,9 @@ To use additional features of the pre-converted [tomograph](https://github.com/f
|
|
85
91
|
```yaml
|
86
92
|
prefixes:
|
87
93
|
- name: /api/v1
|
88
|
-
|
94
|
+
type: tomogram
|
95
|
+
schema_paths:
|
96
|
+
- doc.json
|
89
97
|
```
|
90
98
|
|
91
99
|
## Run
|
@@ -99,6 +107,11 @@ and then
|
|
99
107
|
bundle e rake fitting:report
|
100
108
|
```
|
101
109
|
|
110
|
+
Run tests by outgoing request first to get run artifacts
|
111
|
+
```bash
|
112
|
+
bundle e rake fitting_out:report
|
113
|
+
```
|
114
|
+
|
102
115
|
Console ouptut
|
103
116
|
|
104
117
|
```text
|
@@ -144,7 +157,9 @@ Setting the prefix name is optional. For example, you can do this:
|
|
144
157
|
|
145
158
|
```yaml
|
146
159
|
prefixes:
|
147
|
-
-
|
160
|
+
- type: openapi2
|
161
|
+
schema_paths:
|
162
|
+
- doc.json
|
148
163
|
```
|
149
164
|
|
150
165
|
## prefix skip
|
@@ -153,11 +168,36 @@ It is not necessary to immediately describe each prefix in detail, you can only
|
|
153
168
|
```yaml
|
154
169
|
prefixes:
|
155
170
|
- name: /api/v1
|
156
|
-
|
171
|
+
type: openapi2
|
172
|
+
schema_paths:
|
173
|
+
- doc.json
|
174
|
+
- name: /api/v3
|
175
|
+
skip: true
|
176
|
+
```
|
177
|
+
|
178
|
+
For work with WebMock outgoing request, you should set up outgoing prefixes
|
179
|
+
```yaml
|
180
|
+
outgoing_prefixes:
|
181
|
+
- name: /api/v1
|
182
|
+
type: openapi2
|
183
|
+
schema_paths:
|
184
|
+
- doc.json
|
157
185
|
- name: /api/v3
|
158
186
|
skip: true
|
159
187
|
```
|
160
188
|
|
189
|
+
You can choose location that must be teste
|
190
|
+
|
191
|
+
```yaml
|
192
|
+
prefixes:
|
193
|
+
- type: openapi2
|
194
|
+
schema_paths:
|
195
|
+
- doc.json
|
196
|
+
only:
|
197
|
+
- POST /api/v1/users
|
198
|
+
- GET /api/v1/user/{id}
|
199
|
+
```
|
200
|
+
|
161
201
|
## Contributing
|
162
202
|
|
163
203
|
Bug reports and pull requests are welcome on GitHub at [github.com/funbox/fitting](https://github.com/funbox/fitting).
|
data/fitting.gemspec
CHANGED
@@ -20,11 +20,13 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '>= 2.6.0'
|
22
22
|
spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
|
23
|
+
spec.add_runtime_dependency 'terminal-table', '~> 3.0', '>= 3.0.2'
|
23
24
|
spec.add_runtime_dependency 'tomograph', '~> 3.1', '>= 3.1.0'
|
25
|
+
|
24
26
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
25
27
|
spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
|
26
28
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
27
29
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
28
|
-
spec.add_development_dependency 'rubocop', '
|
30
|
+
spec.add_development_dependency 'rubocop', '>= 1.22.0'
|
29
31
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
30
32
|
end
|
@@ -1,47 +1,17 @@
|
|
1
|
-
require 'fitting/configuration/yaml'
|
2
|
-
require 'fitting/configuration/legacy'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
1
|
module Fitting
|
6
2
|
class Configuration
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
more_than_one_yaml
|
13
|
-
else
|
14
|
-
legacy
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def one_yaml?
|
19
|
-
File.file?('.fitting.yml')
|
20
|
-
end
|
21
|
-
|
22
|
-
def more_than_one_yaml?
|
23
|
-
!Dir['fitting/*.yml'].empty?
|
24
|
-
end
|
25
|
-
|
26
|
-
def one_yaml
|
27
|
-
yaml = YAML.safe_load(File.read('.fitting.yml'))
|
28
|
-
Fitting::Configuration::Yaml.new(yaml)
|
29
|
-
end
|
30
|
-
|
31
|
-
def more_than_one_yaml
|
32
|
-
files.map do |file|
|
33
|
-
yaml = YAML.safe_load(File.read(file))
|
34
|
-
Fitting::Configuration::Yaml.new(yaml, file[8..-5])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def legacy
|
39
|
-
Fitting::Configuration::Legacy.new
|
40
|
-
end
|
3
|
+
attr_accessor :rspec_json_path,
|
4
|
+
:webmock_json_path,
|
5
|
+
:fitting_report_path,
|
6
|
+
:prefixes,
|
7
|
+
:outgoing_prefixes
|
41
8
|
|
42
|
-
|
43
|
-
|
44
|
-
|
9
|
+
def initialize(config)
|
10
|
+
@rspec_json_path = config['rspec_json_path'] || './fitting_tests'
|
11
|
+
@fitting_report_path = config['fitting_report_path'] || './fitting'
|
12
|
+
@prefixes = config['prefixes'] || []
|
13
|
+
@webmock_json_path = config['webmock_json_path'] || './outgoing_request_tests'
|
14
|
+
@outgoing_prefixes = config['outgoing_prefixes'] || []
|
45
15
|
end
|
46
16
|
end
|
47
17
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module Fitting
|
2
2
|
class Cover
|
3
3
|
class JSONSchema
|
4
|
+
attr_reader :json_schema, :combinations
|
5
|
+
|
4
6
|
def initialize(json_schema)
|
5
7
|
@json_schema = json_schema
|
6
8
|
@combinations = []
|
7
9
|
end
|
8
10
|
|
9
11
|
def combi
|
10
|
-
inception(
|
11
|
-
combination[0] =
|
12
|
+
inception(json_schema, combinations).each do |combination|
|
13
|
+
combination[0] = json_schema.merge(combination[0])
|
12
14
|
combination[1] = ['required', combination[1]]
|
13
15
|
end
|
14
16
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module Fitting
|
2
2
|
class Cover
|
3
3
|
class JSONSchemaEnum
|
4
|
+
attr_reader :json_schema, :combinations
|
5
|
+
|
4
6
|
def initialize(json_schema)
|
5
7
|
@json_schema = json_schema
|
6
8
|
@combinations = []
|
7
9
|
end
|
8
10
|
|
9
11
|
def combi
|
10
|
-
inception(
|
11
|
-
combination[0] =
|
12
|
+
inception(json_schema, combinations).each do |combination|
|
13
|
+
combination[0] = json_schema.merge(combination[0])
|
12
14
|
combination[1] = ['enum', combination[1]]
|
13
15
|
end
|
14
16
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module Fitting
|
2
2
|
class Cover
|
3
3
|
class JSONSchemaOneOf
|
4
|
+
attr_reader :json_schema, :combinations
|
5
|
+
|
4
6
|
def initialize(json_schema)
|
5
7
|
@json_schema = json_schema
|
6
8
|
@combinations = []
|
7
9
|
end
|
8
10
|
|
9
11
|
def combi
|
10
|
-
inception(
|
11
|
-
combination[0] =
|
12
|
+
inception(json_schema, combinations).each do |combination|
|
13
|
+
combination[0] = json_schema.merge(combination[0])
|
12
14
|
combination[1] = ['one_of', combination[1]]
|
13
15
|
end
|
14
16
|
end
|
data/lib/fitting/railtie.rb
CHANGED
@@ -2,9 +2,8 @@ module Fitting
|
|
2
2
|
class Records
|
3
3
|
class Documented
|
4
4
|
class Request
|
5
|
-
def initialize(tomogram_request
|
5
|
+
def initialize(tomogram_request)
|
6
6
|
@tomogram_request = tomogram_request
|
7
|
-
@white_list = white_list
|
8
7
|
end
|
9
8
|
|
10
9
|
def method
|
@@ -24,21 +23,8 @@ module Fitting
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
def white
|
28
|
-
@white ||= white?
|
29
|
-
end
|
30
|
-
|
31
26
|
private
|
32
27
|
|
33
|
-
def white?
|
34
|
-
return true if @white_list == nil
|
35
|
-
return false if @white_list[path.to_s] == nil
|
36
|
-
return true if @white_list[path.to_s] == []
|
37
|
-
return true if @white_list[path.to_s].include?(method)
|
38
|
-
|
39
|
-
false
|
40
|
-
end
|
41
|
-
|
42
28
|
def groups
|
43
29
|
@groups ||= @tomogram_request.responses.group_by do |tomogram_response|
|
44
30
|
tomogram_response['status']
|
@@ -10,7 +10,7 @@ module Fitting
|
|
10
10
|
|
11
11
|
array = []
|
12
12
|
Dir['fitting_tests/*.json'].each do |file|
|
13
|
-
array += JSON.parse(
|
13
|
+
array += JSON.parse(file)
|
14
14
|
end
|
15
15
|
@to_a = array.inject([]) do |res, tested_request|
|
16
16
|
request = Fitting::Records::Spherical::Request.load(tested_request)
|
@@ -6,33 +6,33 @@ module Fitting
|
|
6
6
|
class Records
|
7
7
|
class Tested
|
8
8
|
class Request
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@
|
9
|
+
def initialize(response, example)
|
10
|
+
@example = example
|
11
|
+
@response = response
|
12
12
|
end
|
13
13
|
|
14
14
|
def method
|
15
|
-
@method ||= @
|
15
|
+
@method ||= @response.request.request_method
|
16
16
|
end
|
17
17
|
|
18
18
|
def path
|
19
|
-
@path ||= Tomograph::Path.new(@
|
19
|
+
@path ||= Tomograph::Path.new(@response.request.fullpath)
|
20
20
|
end
|
21
21
|
|
22
22
|
def body
|
23
|
-
@body ||= @
|
23
|
+
@body ||= @response.request.request_parameters
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
@
|
26
|
+
def fitting_response
|
27
|
+
@fitting_response ||= Fitting::Records::Tested::Response.new(@response)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_path
|
31
|
-
@test_path ||= @
|
31
|
+
@test_path ||= @example.location
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_file_path
|
35
|
-
@test_file_path ||=
|
35
|
+
@test_file_path ||= @example.file_path
|
36
36
|
end
|
37
37
|
|
38
38
|
def to_spherical
|
@@ -40,7 +40,7 @@ module Fitting
|
|
40
40
|
method: method,
|
41
41
|
path: path,
|
42
42
|
body: body,
|
43
|
-
response:
|
43
|
+
response: fitting_response.to_spherical,
|
44
44
|
title: test_path,
|
45
45
|
group: test_file_path
|
46
46
|
)
|
@@ -4,16 +4,16 @@ module Fitting
|
|
4
4
|
class Records
|
5
5
|
class Tested
|
6
6
|
class Response
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(response)
|
8
|
+
@response = response
|
9
9
|
end
|
10
10
|
|
11
11
|
def status
|
12
|
-
@status ||= @
|
12
|
+
@status ||= @response.status
|
13
13
|
end
|
14
14
|
|
15
15
|
def body
|
16
|
-
@body ||= @
|
16
|
+
@body ||= @response.body
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_spherical
|
@@ -1,39 +1,59 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
1
3
|
module Fitting
|
2
4
|
module Report
|
3
5
|
class Console
|
4
6
|
def initialize(tests_without_prefixes, prefixes_details)
|
5
7
|
@tests_without_prefixes = tests_without_prefixes
|
6
8
|
@prefixes_details = prefixes_details
|
9
|
+
|
7
10
|
@good = true
|
8
11
|
@tests_without_actions = []
|
9
12
|
@tests_without_responses = []
|
10
13
|
end
|
11
14
|
|
12
15
|
def output
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
tables = []
|
17
|
+
|
18
|
+
@prefixes_details.each do |prefix_details|
|
19
|
+
title = prefix_details[:name]
|
20
|
+
@tests_without_actions += prefix_details[:actions][:tests_without_actions] # непонятно что такое
|
21
|
+
|
22
|
+
next if prefix_details[:actions][:actions_details].count.zero?
|
23
|
+
|
24
|
+
tables << Terminal::Table.new do |t|
|
25
|
+
t.title = title
|
26
|
+
t.headings = %w[method path cover]
|
27
|
+
|
28
|
+
prefix_details[:actions][:actions_details].each do |action|
|
29
|
+
@tests_without_responses += action[:responses][:tests_without_responses]
|
30
|
+
|
31
|
+
path_details = action[:responses][:responses_details].map do |responses_detail|
|
32
|
+
@good = false if responses_detail[:combinations][:cover_percent] != '100%'
|
33
|
+
[responses_detail[:combinations][:cover_percent], responses_detail[:method]]
|
34
|
+
end.join(' ')
|
35
|
+
|
36
|
+
t.add_row [action[:method], action[:path], path_details]
|
23
37
|
end
|
24
|
-
|
38
|
+
|
39
|
+
t.style = { all_separators: true, border: :unicode }
|
25
40
|
end
|
26
41
|
end
|
27
|
-
|
42
|
+
|
43
|
+
tables
|
44
|
+
end
|
45
|
+
|
46
|
+
def output_sum
|
47
|
+
doc_res = ''
|
28
48
|
doc_res += "tests_without_prefixes: #{@tests_without_prefixes.size}\n"
|
29
49
|
doc_res += "tests_without_actions: #{@tests_without_actions.size}\n"
|
30
50
|
doc_res += "tests_without_responses: #{@tests_without_responses.size}\n"
|
31
51
|
end
|
32
52
|
|
33
53
|
def good?
|
34
|
-
return false
|
35
|
-
return false
|
36
|
-
return false
|
54
|
+
return false if @tests_without_prefixes.size != 0
|
55
|
+
return false if @tests_without_actions.size != 0
|
56
|
+
return false if @tests_without_responses.size != 0
|
37
57
|
|
38
58
|
@good
|
39
59
|
end
|
@@ -3,53 +3,32 @@ require 'fitting/report/actions'
|
|
3
3
|
module Fitting
|
4
4
|
module Report
|
5
5
|
class Prefix
|
6
|
-
|
7
|
-
|
6
|
+
KEYS = {
|
7
|
+
'openapi2' => :openapi2_json_path,
|
8
|
+
'openapi3' => :openapi3_yaml_path,
|
9
|
+
'drafter' => :drafter_yaml_path,
|
10
|
+
'crafter' => :crafter_yaml_path,
|
11
|
+
'tomogram' => :tomogram_json_path
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
attr_reader :name, :tests, :actions
|
15
|
+
|
16
|
+
def initialize(schema_paths: nil, type: nil, name: '', skip: false, only: [])
|
8
17
|
@name = name
|
9
|
-
@tomogram_json_path = tomogram_json_path
|
10
18
|
@tests = Fitting::Report::Tests.new([])
|
11
19
|
@skip = skip
|
12
20
|
return if skip
|
13
21
|
|
14
|
-
@actions =
|
15
|
-
Fitting::Report::Actions.new(
|
16
|
-
Tomograph::Tomogram.new(
|
17
|
-
prefix: name,
|
18
|
-
openapi2_json_path: openapi2_json_path
|
19
|
-
)
|
20
|
-
)
|
21
|
-
elsif openapi3_yaml_path
|
22
|
-
Fitting::Report::Actions.new(
|
23
|
-
Tomograph::Tomogram.new(
|
24
|
-
prefix: name,
|
25
|
-
openapi3_yaml_path: openapi3_yaml_path
|
26
|
-
)
|
27
|
-
)
|
28
|
-
elsif drafter_yaml_path
|
29
|
-
Fitting::Report::Actions.new(
|
30
|
-
Tomograph::Tomogram.new(
|
31
|
-
prefix: name,
|
32
|
-
drafter_yaml_path: drafter_yaml_path
|
33
|
-
)
|
34
|
-
)
|
35
|
-
elsif crafter_yaml_path
|
36
|
-
Fitting::Report::Actions.new(
|
37
|
-
Tomograph::Tomogram.new(
|
38
|
-
prefix: name,
|
39
|
-
crafter_yaml_path: crafter_yaml_path
|
40
|
-
)
|
41
|
-
)
|
42
|
-
else
|
43
|
-
Fitting::Report::Actions.new(
|
44
|
-
Tomograph::Tomogram.new(
|
45
|
-
prefix: name,
|
46
|
-
tomogram_json_path: tomogram_json_path
|
47
|
-
)
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
22
|
+
@actions = Fitting::Report::Actions.new([])
|
51
23
|
|
52
|
-
|
24
|
+
schema_paths.each do |path|
|
25
|
+
tomogram = Tomograph::Tomogram.new(prefix: name, KEYS[type] => path)
|
26
|
+
|
27
|
+
tomogram.to_a.filter! { |action| only.include?("#{action.method} #{action.path}") } if only.present?
|
28
|
+
|
29
|
+
@actions.push(Fitting::Report::Actions.new(tomogram))
|
30
|
+
end
|
31
|
+
end
|
53
32
|
|
54
33
|
def skip?
|
55
34
|
@skip
|
@@ -3,18 +3,17 @@ require 'fitting/report/prefix'
|
|
3
3
|
module Fitting
|
4
4
|
module Report
|
5
5
|
class Prefixes
|
6
|
-
def initialize(
|
6
|
+
def initialize(configuration_prefixes)
|
7
7
|
@prefixes = []
|
8
|
-
|
8
|
+
|
9
|
+
configuration_prefixes.map do |prefix|
|
9
10
|
@prefixes.push(
|
10
11
|
Fitting::Report::Prefix.new(
|
12
|
+
schema_paths: prefix['schema_paths'],
|
13
|
+
type: prefix['type'],
|
11
14
|
name: prefix['name'],
|
12
|
-
|
13
|
-
|
14
|
-
drafter_yaml_path: prefix['drafter_yaml_path'],
|
15
|
-
tomogram_json_path: prefix['tomogram_json_path'],
|
16
|
-
crafter_yaml_path: prefix['crafter_yaml_path'],
|
17
|
-
skip: prefix['skip']
|
15
|
+
skip: prefix['skip'],
|
16
|
+
only: prefix['only']
|
18
17
|
)
|
19
18
|
)
|
20
19
|
end
|