fitting 2.18.3 → 3.0.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 +4 -4
- data/.rubocop.yml +2 -11
- data/CHANGELOG.md +6 -0
- data/README.md +46 -6
- data/fitting.gemspec +1 -1
- data/lib/fitting/configuration.rb +12 -6
- 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/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 +2 -186
- data/lib/tasks/fitting_outgoing.rake +91 -0
- metadata +5 -41
- 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 -88
- 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
|
data/CHANGELOG.md
CHANGED
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
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
|
28
28
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
30
|
-
spec.add_development_dependency 'rubocop', '
|
30
|
+
spec.add_development_dependency 'rubocop', '>= 1.22.0'
|
31
31
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
32
32
|
end
|
@@ -1,11 +1,17 @@
|
|
1
|
-
require 'fitting/configuration/yaml'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
1
|
module Fitting
|
5
2
|
class Configuration
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
attr_accessor :rspec_json_path,
|
4
|
+
:webmock_json_path,
|
5
|
+
:fitting_report_path,
|
6
|
+
:prefixes,
|
7
|
+
:outgoing_prefixes
|
8
|
+
|
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'] || []
|
9
15
|
end
|
10
16
|
end
|
11
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
|
@@ -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
|
data/lib/fitting/report/tests.rb
CHANGED
@@ -3,13 +3,26 @@ require 'fitting/report/test'
|
|
3
3
|
module Fitting
|
4
4
|
module Report
|
5
5
|
class Tests
|
6
|
+
attr_reader :tests
|
7
|
+
|
6
8
|
def initialize(tests)
|
7
9
|
@tests = tests
|
8
10
|
end
|
9
11
|
|
10
|
-
def self.new_from_config
|
12
|
+
def self.new_from_config
|
13
|
+
tests = []
|
14
|
+
Dir["#{Fitting.configuration.rspec_json_path}/*.json"].each do |file|
|
15
|
+
JSON.parse(File.read(file)).map do |test|
|
16
|
+
tests.push(Fitting::Report::Test.new(test))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
tests.sort { |a, b| b.path <=> a.path }
|
20
|
+
new(tests)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.new_from_outgoing_config
|
11
24
|
tests = []
|
12
|
-
Dir[
|
25
|
+
Dir["#{Fitting.configuration.webmock_json_path}/*.json"].each do |file|
|
13
26
|
JSON.parse(File.read(file)).map do |test|
|
14
27
|
tests.push(Fitting::Report::Test.new(test))
|
15
28
|
end
|
@@ -19,45 +32,45 @@ module Fitting
|
|
19
32
|
end
|
20
33
|
|
21
34
|
def without_prefixes
|
22
|
-
|
35
|
+
tests.each_with_object([]) do |test, result|
|
23
36
|
result.push(test.path) unless test.there_a_prefix?
|
24
37
|
end
|
25
38
|
end
|
26
39
|
|
27
40
|
def without_actions
|
28
|
-
|
41
|
+
tests.each_with_object([]) do |test, result|
|
29
42
|
result.push("#{test.method} #{test.path}") unless test.there_an_actions?
|
30
43
|
end
|
31
44
|
end
|
32
45
|
|
33
46
|
def without_responses
|
34
|
-
|
47
|
+
tests.each_with_object([]) do |test, result|
|
35
48
|
result.push(test.id) unless test.there_an_responses?
|
36
49
|
end
|
37
50
|
end
|
38
51
|
|
39
52
|
def without_combinations
|
40
|
-
|
53
|
+
tests.each_with_object([]) do |test, result|
|
41
54
|
result.push(test.path) unless test.there_an_combinations?
|
42
55
|
end
|
43
56
|
end
|
44
57
|
|
45
58
|
def push(test)
|
46
|
-
|
59
|
+
tests.push(test)
|
47
60
|
end
|
48
61
|
|
49
62
|
def size
|
50
|
-
|
63
|
+
tests.size
|
51
64
|
end
|
52
65
|
|
53
66
|
def to_a
|
54
|
-
|
67
|
+
tests
|
55
68
|
end
|
56
69
|
|
57
70
|
def to_h
|
58
71
|
return @hash if @hash
|
59
72
|
|
60
|
-
@hash =
|
73
|
+
@hash = tests.inject({}) do |res, test|
|
61
74
|
res.merge!(test.id => test.to_h)
|
62
75
|
end
|
63
76
|
end
|
@@ -1,24 +1,20 @@
|
|
1
|
-
require 'fitting/statistics'
|
2
|
-
require 'fitting/tests'
|
3
1
|
require 'fitting/records/tested/request'
|
4
2
|
|
5
3
|
module Fitting
|
6
4
|
module Storage
|
7
5
|
class Responses
|
6
|
+
attr_reader :tested_requests
|
7
|
+
|
8
8
|
def initialize
|
9
9
|
@tested_requests = []
|
10
10
|
end
|
11
11
|
|
12
|
-
def add(
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def statistics
|
17
|
-
Fitting::Statistics.new(@tested_requests)
|
12
|
+
def add(response, example)
|
13
|
+
tested_requests.push(Fitting::Records::Tested::Request.new(response, example))
|
18
14
|
end
|
19
15
|
|
20
16
|
def tests
|
21
|
-
Fitting::Tests.new(
|
17
|
+
Fitting::Tests.new(tested_requests)
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
data/lib/fitting/tests.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'fitting/statistics/template'
|
2
|
-
|
3
1
|
module Fitting
|
4
2
|
class Tests
|
5
3
|
def initialize(tested_requests)
|
@@ -7,13 +5,23 @@ module Fitting
|
|
7
5
|
end
|
8
6
|
|
9
7
|
def save
|
10
|
-
make_dir(
|
8
|
+
make_dir(Fitting.configuration.rspec_json_path)
|
9
|
+
array = @tested_requests.inject([]) do |res, request|
|
10
|
+
res.push(request.to_spherical.to_hash)
|
11
|
+
end
|
12
|
+
json = JSON.dump(array)
|
13
|
+
|
14
|
+
File.open("#{Fitting.configuration.rspec_json_path}/test#{ENV['TEST_ENV_NUMBER']}.json", 'w') { |file| file.write(json) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def outgoing_save
|
18
|
+
make_dir('./outgoing_request_tests')
|
11
19
|
array = @tested_requests.inject([]) do |res, request|
|
12
20
|
res.push(request.to_spherical.to_hash)
|
13
21
|
end
|
14
22
|
json = JSON.dump(array)
|
15
23
|
|
16
|
-
File.open("
|
24
|
+
File.open("./outgoing_request_tests/test#{ENV['TEST_ENV_NUMBER']}.json", 'w') { |file| file.write(json) }
|
17
25
|
end
|
18
26
|
|
19
27
|
def make_dir(dir_name)
|
data/lib/fitting/version.rb
CHANGED