fitting 2.8.0 → 2.11.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/.gitignore +1 -0
- data/CHANGELOG.md +33 -0
- data/README.md +21 -5
- data/fitting.gemspec +1 -2
- data/lib/fitting.rb +2 -0
- data/lib/fitting/configuration/legacy.rb +22 -5
- data/lib/fitting/configuration/yaml.rb +28 -6
- data/lib/fitting/records/spherical/requests.rb +4 -1
- data/lib/fitting/statistics/cover_error.rb +2 -2
- data/lib/fitting/statistics/cover_error_enum.rb +2 -2
- data/lib/fitting/tests.rb +3 -1
- data/lib/fitting/version.rb +1 -1
- metadata +6 -21
- data/lib/fitting/cover.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fe2c40a89499b32b2a4989a88cb8d294c420191
|
4
|
+
data.tar.gz: cd0deaa0b1fb6003bc6c58054def0843fa22e656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e2e177b230a274a1e53d2eb525f6f59f89ffcdcc9ae4392183f0021ae727f3a4d48499dd870bf853ea49a21d7eeec00c9196f1659506348d14dae07287688e3
|
7
|
+
data.tar.gz: a4ae0ec1d99a3f6b9d9e9fd10bcdeaf592be1335ada092481dece76250da9caa5f4f3cf084d290f792bb16fa897fe361a0967c4c739f918fcedb53a4e8d3bac9
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
### 2.11.0 - 2019-09-09
|
4
|
+
|
5
|
+
* features
|
6
|
+
* crafter_apib_path
|
7
|
+
* drafter_4_apib_path
|
8
|
+
* drafter_4_yaml_path
|
9
|
+
|
10
|
+
* fixes
|
11
|
+
* crafter_yaml_path
|
12
|
+
|
13
|
+
### 2.10.0 - 2019-09-05
|
14
|
+
|
15
|
+
* features
|
16
|
+
* add crafter_yaml_path
|
17
|
+
|
18
|
+
### 2.9.1 - 2019-07-15
|
19
|
+
|
20
|
+
* fixes
|
21
|
+
* Improve gemspec
|
22
|
+
* Delete experimental code with haml
|
23
|
+
|
24
|
+
### 2.9.0 - 2019-07-15
|
25
|
+
|
26
|
+
* features
|
27
|
+
* Delete old spec json
|
28
|
+
* fixes
|
29
|
+
* Improve gemspec
|
30
|
+
|
31
|
+
### 2.8.1 - 2018-12-18
|
32
|
+
|
33
|
+
* features
|
34
|
+
* Add support for [parallel_tests](https://github.com/grosser/parallel_tests)
|
35
|
+
|
3
36
|
### 2.8.0 - 2018-10-13
|
4
37
|
|
5
38
|
* features
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ require 'fitting'
|
|
42
42
|
Fitting.save_test_data
|
43
43
|
```
|
44
44
|
|
45
|
-
The
|
45
|
+
The files will be created in ./fitting_tests/ path
|
46
46
|
|
47
47
|
Example:
|
48
48
|
|
@@ -141,9 +141,9 @@ API responses with validation errors or untested: 9 (36.00% of 25).
|
|
141
141
|
For details `rake fitting:documentation_responses_error[s]`
|
142
142
|
|
143
143
|
```
|
144
|
-
request
|
144
|
+
request method: GET
|
145
145
|
request path: /api/v1/book
|
146
|
-
response
|
146
|
+
response status: 200
|
147
147
|
source json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
|
148
148
|
combination: ["required", "pages"]
|
149
149
|
new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...}
|
@@ -167,11 +167,27 @@ If your project uses several prefixes, for each one you need to create a separat
|
|
167
167
|
|
168
168
|
### apib_path
|
169
169
|
|
170
|
-
Path to API Blueprint documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
170
|
+
Path to API Blueprint v3 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
171
171
|
|
172
172
|
### drafter_yaml_path
|
173
173
|
|
174
|
-
Path to API Blueprint documentation pre-parsed with `drafter` and saved to a YAML file.
|
174
|
+
Path to API Blueprint v3 documentation pre-parsed with `drafter` and saved to a YAML file.
|
175
|
+
|
176
|
+
### drafter_4_apib_path
|
177
|
+
|
178
|
+
Path to API Blueprint v4 documentation. There must be an installed [drafter](https://github.com/apiaryio/drafter) to parse it.
|
179
|
+
|
180
|
+
### drafter_4_yaml_path
|
181
|
+
|
182
|
+
Path to API Blueprint v4 documentation pre-parsed with `drafter` and saved to a YAML file.
|
183
|
+
|
184
|
+
### crafter_apib_path
|
185
|
+
|
186
|
+
Path to API Blueprint v4 documentation.
|
187
|
+
|
188
|
+
### crafter_yaml_path
|
189
|
+
|
190
|
+
Path to API Blueprint v4 documentation pre-parsed with `crafter` and saved to a YAML file.
|
175
191
|
|
176
192
|
### tomogram_json_path
|
177
193
|
|
data/fitting.gemspec
CHANGED
@@ -18,9 +18,8 @@ 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.add_runtime_dependency 'haml'
|
22
21
|
spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
|
23
|
-
spec.add_runtime_dependency 'multi_json'
|
22
|
+
spec.add_runtime_dependency 'multi_json', '~> 1.11'
|
24
23
|
spec.add_runtime_dependency 'tomograph', '~> 2.0', '>= 2.2.0'
|
25
24
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
25
|
spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.1'
|
data/lib/fitting.rb
CHANGED
@@ -32,6 +32,8 @@ module Fitting
|
|
32
32
|
def save_test_data
|
33
33
|
responses = Fitting::Storage::Responses.new
|
34
34
|
|
35
|
+
FileUtils.rm_r Dir.glob("fitting_tests/*"), :force => true
|
36
|
+
|
35
37
|
RSpec.configure do |config|
|
36
38
|
config.after(:each, type: :controller) do
|
37
39
|
responses.add(response, inspect)
|
@@ -5,6 +5,10 @@ module Fitting
|
|
5
5
|
class Legacy
|
6
6
|
attr_accessor :apib_path,
|
7
7
|
:drafter_yaml_path,
|
8
|
+
:crafter_apib_path,
|
9
|
+
:crafter_yaml_path,
|
10
|
+
:drafter_4_apib_path,
|
11
|
+
:drafter_4_yaml_path,
|
8
12
|
:strict,
|
9
13
|
:prefix,
|
10
14
|
:white_list,
|
@@ -20,11 +24,24 @@ module Fitting
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def tomogram
|
23
|
-
@tomogram ||=
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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 Tomograph::Tomogram.new(
|
40
|
+
prefix: @prefix,
|
41
|
+
apib_path: @apib_path,
|
42
|
+
drafter_yaml_path: @drafter_yaml_path
|
43
|
+
)
|
44
|
+
end
|
28
45
|
end
|
29
46
|
|
30
47
|
def title
|
@@ -6,6 +6,10 @@ module Fitting
|
|
6
6
|
attr_reader :title
|
7
7
|
attr_accessor :apib_path,
|
8
8
|
:drafter_yaml_path,
|
9
|
+
:crafter_apib_path,
|
10
|
+
:crafter_yaml_path,
|
11
|
+
:drafter_4_apib_path,
|
12
|
+
:drafter_4_yaml_path,
|
9
13
|
:tomogram_json_path,
|
10
14
|
:strict,
|
11
15
|
:prefix,
|
@@ -18,6 +22,10 @@ module Fitting
|
|
18
22
|
def initialize(yaml, title = 'fitting')
|
19
23
|
@apib_path = yaml['apib_path']
|
20
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']
|
21
29
|
@tomogram_json_path = yaml['tomogram_json_path']
|
22
30
|
@strict = yaml['strict']
|
23
31
|
@prefix = yaml['prefix']
|
@@ -31,12 +39,26 @@ module Fitting
|
|
31
39
|
end
|
32
40
|
|
33
41
|
def tomogram
|
34
|
-
@tomogram ||=
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
40
62
|
end
|
41
63
|
|
42
64
|
def stats_path
|
@@ -8,7 +8,10 @@ module Fitting
|
|
8
8
|
def to_a
|
9
9
|
return @to_a if @to_a
|
10
10
|
|
11
|
-
array =
|
11
|
+
array = []
|
12
|
+
Dir['fitting_tests/*.json'].each do |file|
|
13
|
+
array += JSON.load(File.read(file))
|
14
|
+
end
|
12
15
|
@to_a = array.inject([]) do |res, tested_request|
|
13
16
|
res.push(Fitting::Records::Spherical::Request.load(tested_request))
|
14
17
|
end
|
@@ -13,8 +13,8 @@ module Fitting
|
|
13
13
|
response.json_schemas.map do |json_schema|
|
14
14
|
json_schema.combinations.map do |combination|
|
15
15
|
next unless combination.valid_bodies == []
|
16
|
-
res += "request
|
17
|
-
"response
|
16
|
+
res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
|
17
|
+
"response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
|
18
18
|
"combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
|
19
19
|
end
|
20
20
|
end
|
@@ -13,8 +13,8 @@ module Fitting
|
|
13
13
|
response.json_schemas.map do |json_schema|
|
14
14
|
json_schema.combinations_with_enum.map do |combination|
|
15
15
|
next unless combination.valid_bodies == []
|
16
|
-
res += "request
|
17
|
-
"response
|
16
|
+
res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
|
17
|
+
"response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
|
18
18
|
"combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
|
19
19
|
end
|
20
20
|
end
|
data/lib/fitting/tests.rb
CHANGED
@@ -7,12 +7,14 @@ module Fitting
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def save
|
10
|
+
make_dir('fitting_tests')
|
10
11
|
array = @tested_requests.inject([]) do |res, request|
|
11
12
|
next res unless request.path.to_s.start_with?(Fitting.configuration.prefix)
|
12
13
|
res.push(request.to_spherical.to_hash)
|
13
14
|
end
|
14
15
|
json = JSON.dump(array)
|
15
|
-
|
16
|
+
|
17
|
+
File.open("fitting_tests/test#{ENV["TEST_ENV_NUMBER"]}.json", 'w') { |file| file.write(json) }
|
16
18
|
end
|
17
19
|
|
18
20
|
def make_dir(dir_name)
|
data/lib/fitting/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.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:
|
11
|
+
date: 2019-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: haml
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: json-schema
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,16 +34,16 @@ dependencies:
|
|
48
34
|
name: multi_json
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
50
36
|
requirements:
|
51
|
-
- - "
|
37
|
+
- - "~>"
|
52
38
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
39
|
+
version: '1.11'
|
54
40
|
type: :runtime
|
55
41
|
prerelease: false
|
56
42
|
version_requirements: !ruby/object:Gem::Requirement
|
57
43
|
requirements:
|
58
|
-
- - "
|
44
|
+
- - "~>"
|
59
45
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
46
|
+
version: '1.11'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: tomograph
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,7 +196,6 @@ files:
|
|
210
196
|
- lib/fitting/configuration.rb
|
211
197
|
- lib/fitting/configuration/legacy.rb
|
212
198
|
- lib/fitting/configuration/yaml.rb
|
213
|
-
- lib/fitting/cover.rb
|
214
199
|
- lib/fitting/cover/json_schema.rb
|
215
200
|
- lib/fitting/cover/json_schema_enum.rb
|
216
201
|
- lib/fitting/cover/response.rb
|
data/lib/fitting/cover.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'fitting/cover/response'
|
2
|
-
require 'haml'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module Fitting
|
6
|
-
class Cover
|
7
|
-
def initialize(all_responses, coverage)
|
8
|
-
@all_responses = all_responses
|
9
|
-
@coverage = coverage
|
10
|
-
@list = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_hash
|
14
|
-
return @list unless @list == {}
|
15
|
-
@all_responses.each_with_object({}) do |response, res|
|
16
|
-
next res unless response.documented?
|
17
|
-
if res.key?(response.route)
|
18
|
-
res[response.route].update(response)
|
19
|
-
else
|
20
|
-
res[response.route] = Fitting::Cover::Response.new(response)
|
21
|
-
end
|
22
|
-
end.map do |key, value|
|
23
|
-
@list[key] = value.to_hash
|
24
|
-
end
|
25
|
-
@list
|
26
|
-
end
|
27
|
-
|
28
|
-
def template
|
29
|
-
return @template if @template
|
30
|
-
@template = {}
|
31
|
-
to_hash.each do |key, value|
|
32
|
-
@template[key] = value
|
33
|
-
@template[key]['cover'] = 100.0
|
34
|
-
if value['flags'] == []
|
35
|
-
@template[key]['type'] = 'passed'
|
36
|
-
else
|
37
|
-
flag_true = value['flags'].find_all { |flag| flag == true }
|
38
|
-
flag_false = value['flags'].find_all { |flag| flag == false }
|
39
|
-
if flag_false.empty?
|
40
|
-
@template[key]['type'] = 'passed'
|
41
|
-
else
|
42
|
-
@template[key]['cover'] = if flag_true.empty?
|
43
|
-
0.0
|
44
|
-
else
|
45
|
-
flag_false.size / flag_true.size
|
46
|
-
end
|
47
|
-
@template[key]['type'] = 'failed'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
@template[key]['json_schema'] = JSON.pretty_generate(value['json_schemas'].last)
|
51
|
-
end
|
52
|
-
@template
|
53
|
-
end
|
54
|
-
|
55
|
-
def save
|
56
|
-
to_hash
|
57
|
-
contents = File.read(File.expand_path('../view/report.html.haml', __FILE__))
|
58
|
-
html = "<style>\n#{File.read(File.expand_path('../view/style.css', __FILE__))}\n</style>\n"
|
59
|
-
html += Haml::Engine.new(contents).render(
|
60
|
-
Object.new,
|
61
|
-
:@to_hash => template
|
62
|
-
)
|
63
|
-
html
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|