fitting 2.12.0 → 2.14.1
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 +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +48 -0
- data/README.md +134 -79
- data/fitting.gemspec +1 -1
- data/lib/fitting.rb +5 -0
- data/lib/fitting/cover/json_schema.rb +21 -80
- data/lib/fitting/cover/json_schema_enum.rb +20 -70
- data/lib/fitting/cover/json_schema_one_of.rb +22 -14
- data/lib/fitting/records/spherical/requests.rb +3 -1
- data/lib/fitting/report/action.rb +53 -0
- data/lib/fitting/report/actions.rb +55 -0
- data/lib/fitting/report/combination.rb +37 -0
- data/lib/fitting/report/combinations.rb +47 -0
- data/lib/fitting/report/console.rb +41 -0
- data/lib/fitting/report/prefix.rb +53 -0
- data/lib/fitting/report/prefixes.rb +44 -0
- data/lib/fitting/report/response.rb +71 -0
- data/lib/fitting/report/responses.rb +48 -0
- data/lib/fitting/report/test.rb +61 -0
- data/lib/fitting/report/tests.rb +62 -0
- data/lib/fitting/tests.rb +0 -1
- data/lib/fitting/version.rb +1 -1
- data/lib/tasks/fitting.rake +128 -0
- data/lib/templates/bomboniere/.gitignore +21 -0
- data/lib/templates/bomboniere/.tool-versions +1 -0
- data/lib/templates/bomboniere/README.md +19 -0
- data/lib/templates/bomboniere/dist/css/app.62e086ac.css +1 -0
- data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +1 -0
- data/lib/templates/bomboniere/dist/favicon.ico +0 -0
- data/lib/templates/bomboniere/dist/index.html +1 -0
- data/lib/templates/bomboniere/dist/js/app.4356d509.js +2 -0
- data/lib/templates/bomboniere/dist/js/app.4356d509.js.map +1 -0
- data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js +13 -0
- data/lib/templates/bomboniere/dist/js/chunk-vendors.90aeb613.js.map +1 -0
- data/lib/templates/bomboniere/package-lock.json +9271 -0
- data/lib/templates/bomboniere/package.json +26 -0
- data/lib/templates/bomboniere/public/favicon.ico +0 -0
- data/lib/templates/bomboniere/public/index.html +17 -0
- data/lib/templates/bomboniere/src/App.vue +102 -0
- data/lib/templates/bomboniere/src/assets/logo.png +0 -0
- data/lib/templates/bomboniere/src/components/HelloWorld.vue +188 -0
- data/lib/templates/bomboniere/src/main.js +10 -0
- data/lib/templates/bomboniere/src/router/index.js +31 -0
- data/lib/templates/bomboniere/src/views/About.vue +5 -0
- data/lib/templates/bomboniere/src/views/Action.vue +154 -0
- data/lib/templates/bomboniere/src/views/Home.vue +17 -0
- data/lib/templates/bomboniere/vue.config.js +3 -0
- metadata +43 -8
data/fitting.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'tomograph', '~> 2.0', '>= 2.2.0'
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
25
25
|
spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.1'
|
26
|
-
spec.add_development_dependency 'rake', '
|
26
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
28
28
|
spec.add_development_dependency 'rubocop', '~> 0.49.1', '>= 0.49.1'
|
29
29
|
spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
|
data/lib/fitting.rb
CHANGED
@@ -16,6 +16,7 @@ module Fitting
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def statistics
|
19
|
+
puts 'DEPRECATED: deprecated method statistics, use new method save_test_data'
|
19
20
|
responses = Fitting::Storage::Responses.new
|
20
21
|
|
21
22
|
RSpec.configure do |config|
|
@@ -35,6 +36,10 @@ module Fitting
|
|
35
36
|
FileUtils.rm_r Dir.glob("fitting_tests/*"), :force => true
|
36
37
|
|
37
38
|
RSpec.configure do |config|
|
39
|
+
config.after(:each, type: :request) do
|
40
|
+
responses.add(response, inspect)
|
41
|
+
end
|
42
|
+
|
38
43
|
config.after(:each, type: :controller) do
|
39
44
|
responses.add(response, inspect)
|
40
45
|
end
|
@@ -3,95 +3,36 @@ module Fitting
|
|
3
3
|
class JSONSchema
|
4
4
|
def initialize(json_schema)
|
5
5
|
@json_schema = json_schema
|
6
|
+
@combinations = []
|
6
7
|
end
|
7
8
|
|
8
9
|
def combi
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
return @combinations unless @json_schema['properties']
|
13
|
-
@combinations = new_super_each(@json_schema['properties'], { 'properties' => nil }, @json_schema, @combinations, 'properties')
|
14
|
-
|
15
|
-
@combinations
|
16
|
-
end
|
17
|
-
|
18
|
-
def new_super_each(json_schema, old_keys_hash, lol_schema, combinations, old_key)
|
19
|
-
json_schema.each do |key, value|
|
20
|
-
next unless value.is_a?(Hash)
|
21
|
-
|
22
|
-
new_keys_hash = clone_hash(old_keys_hash)
|
23
|
-
add_super_key(new_keys_hash, key)
|
24
|
-
|
25
|
-
combinations = new_super_each(value, new_keys_hash, lol_schema, combinations, [old_key, key].compact.join('.'))
|
26
|
-
|
27
|
-
qwe = new_required(value)
|
28
|
-
qwe.map do |asd|
|
29
|
-
new_json_shema = clone_hash(lol_schema)
|
30
|
-
super_merge(new_keys_hash, asd[0], new_json_shema)
|
31
|
-
combinations.push([new_json_shema, [asd[1][0], [old_key, key, asd[1][1]].compact.join('.')]])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
combinations
|
35
|
-
end
|
36
|
-
|
37
|
-
def add_super_key(vbn, new_key)
|
38
|
-
vbn.each do |key, value|
|
39
|
-
if value
|
40
|
-
add_super_key(value, new_key)
|
41
|
-
else
|
42
|
-
vbn[key] = { new_key => nil }
|
43
|
-
end
|
10
|
+
inception(@json_schema, @combinations).each do |combination|
|
11
|
+
combination[0] = @json_schema.merge(combination[0])
|
12
|
+
combination[1] = ['required', combination[1]]
|
44
13
|
end
|
45
14
|
end
|
46
15
|
|
47
|
-
def
|
48
|
-
|
49
|
-
if value
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
elsif value
|
64
|
-
new_json_schema.merge!(key => value.clone)
|
65
|
-
else
|
66
|
-
new_json_schema.merge!(key => nil)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
new_json_schema
|
70
|
-
end
|
71
|
-
|
72
|
-
def new_required(json_schema)
|
73
|
-
res = []
|
74
|
-
new_keys(json_schema).map do |new_key|
|
75
|
-
new_json_shema = json_schema.dup
|
76
|
-
if new_json_shema['required']
|
77
|
-
new_json_shema['required'] += [new_key]
|
78
|
-
else
|
79
|
-
new_json_shema['required'] = [new_key]
|
16
|
+
def inception(json_schema, combinations)
|
17
|
+
json_schema.each do |key, value|
|
18
|
+
if key == 'properties' and json_schema['required'] != value.keys
|
19
|
+
schema = json_schema.dup
|
20
|
+
one_of = schema.delete('required') || []
|
21
|
+
schema['properties'].each_key do |property|
|
22
|
+
next if one_of.include?(property)
|
23
|
+
combinations.push([schema.merge('required' => one_of + [property]), "required.#{property}"])
|
24
|
+
end
|
25
|
+
elsif value.is_a?(Hash)
|
26
|
+
com = inception(value, [])
|
27
|
+
com.each do |combination|
|
28
|
+
combination[0] = { key => value.merge(combination[0])}
|
29
|
+
combination[1] = "#{key}.#{combination[1]}"
|
30
|
+
end
|
31
|
+
combinations += com
|
80
32
|
end
|
81
|
-
res.push([new_json_shema, ['required', new_key]])
|
82
33
|
end
|
83
|
-
res
|
84
|
-
end
|
85
34
|
|
86
|
-
|
87
|
-
return [] unless json_schema && json_schema['properties']
|
88
|
-
all = json_schema['properties'].keys.map(&:to_s)
|
89
|
-
old = json_schema['required']
|
90
|
-
if old
|
91
|
-
all - old
|
92
|
-
else
|
93
|
-
all
|
94
|
-
end
|
35
|
+
combinations
|
95
36
|
end
|
96
37
|
end
|
97
38
|
end
|
@@ -3,85 +3,35 @@ module Fitting
|
|
3
3
|
class JSONSchemaEnum
|
4
4
|
def initialize(json_schema)
|
5
5
|
@json_schema = json_schema
|
6
|
-
end
|
7
|
-
|
8
|
-
def combi
|
9
|
-
return @combinations if @combinations
|
10
6
|
@combinations = []
|
11
|
-
|
12
|
-
return @combinations unless @json_schema['properties']
|
13
|
-
@combinations = new_super_each(@json_schema['properties'], { 'properties' => nil }, @json_schema, @combinations, 'properties')
|
14
|
-
|
15
|
-
@combinations
|
16
|
-
end
|
17
|
-
|
18
|
-
def new_super_each(json_schema, old_keys_hash, lol_schema, combinations, old_key)
|
19
|
-
json_schema.each do |key, value|
|
20
|
-
next unless value.is_a?(Hash)
|
21
|
-
|
22
|
-
new_keys_hash = clone_hash(old_keys_hash)
|
23
|
-
add_super_key(new_keys_hash, key)
|
24
|
-
|
25
|
-
combinations = new_super_each(value, new_keys_hash, lol_schema, combinations, [old_key, key].compact.join('.'))
|
26
|
-
|
27
|
-
qwe = new_enum(value)
|
28
|
-
qwe.map do |asd|
|
29
|
-
new_json_shema = clone_hash(lol_schema)
|
30
|
-
super_merge(new_keys_hash, asd[0], new_json_shema)
|
31
|
-
combinations.push([new_json_shema, [asd[1][0], [old_key, key, asd[1][1]].compact.join('.')]])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
combinations
|
35
7
|
end
|
36
8
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
else
|
42
|
-
vbn[key] = { new_key => nil }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def super_merge(vbn, asd, old_json_schema)
|
48
|
-
vbn.each do |key, value|
|
49
|
-
if value
|
50
|
-
super_merge(value, asd, old_json_schema[key])
|
51
|
-
else
|
52
|
-
old_json_schema[key].merge!(asd)
|
53
|
-
end
|
9
|
+
def combi
|
10
|
+
inception(@json_schema, @combinations).each do |combination|
|
11
|
+
combination[0] = @json_schema.merge(combination[0])
|
12
|
+
combination[1] = ['enum', combination[1]]
|
54
13
|
end
|
55
|
-
old_json_schema
|
56
14
|
end
|
57
15
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
16
|
+
def inception(json_schema, combinations)
|
17
|
+
json_schema.each do |key, value|
|
18
|
+
if key == 'enum' && value.size > 1
|
19
|
+
schema = json_schema.dup
|
20
|
+
one_of = schema.delete('enum')
|
21
|
+
one_of.each_index do |index|
|
22
|
+
combinations.push([schema.merge('enum' => [one_of[index]]), "enum.#{one_of[index]}"])
|
23
|
+
end
|
24
|
+
elsif value.is_a?(Hash)
|
25
|
+
com = inception(value, [])
|
26
|
+
com.each do |combination|
|
27
|
+
combination[0] = { key => value.merge(combination[0])}
|
28
|
+
combination[1] = "#{key}.#{combination[1]}"
|
29
|
+
end
|
30
|
+
combinations += com
|
67
31
|
end
|
68
32
|
end
|
69
|
-
new_json_schema
|
70
|
-
end
|
71
|
-
|
72
|
-
def new_enum(json_schema)
|
73
|
-
res = []
|
74
|
-
new_keys(json_schema).map do |new_key|
|
75
|
-
new_json_shema = json_schema.dup
|
76
|
-
new_json_shema['enum'] = [new_key]
|
77
|
-
res.push([new_json_shema, ['enum', new_key]])
|
78
|
-
end
|
79
|
-
res
|
80
|
-
end
|
81
33
|
|
82
|
-
|
83
|
-
return [] unless json_schema['enum']
|
84
|
-
json_schema['enum']
|
34
|
+
combinations
|
85
35
|
end
|
86
36
|
end
|
87
37
|
end
|
@@ -3,27 +3,35 @@ module Fitting
|
|
3
3
|
class JSONSchemaOneOf
|
4
4
|
def initialize(json_schema)
|
5
5
|
@json_schema = json_schema
|
6
|
+
@combinations = []
|
6
7
|
end
|
7
8
|
|
8
9
|
def combi
|
9
|
-
@combinations
|
10
|
-
|
11
|
-
|
10
|
+
inception(@json_schema, @combinations).each do |combination|
|
11
|
+
combination[0] = @json_schema.merge(combination[0])
|
12
|
+
combination[1] = ['one_of', combination[1]]
|
13
|
+
end
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def inception(json_schema, combinations)
|
17
|
+
json_schema.each do |key, value|
|
18
|
+
if key == 'oneOf'
|
19
|
+
schema = json_schema.dup
|
20
|
+
one_of = schema.delete('oneOf')
|
21
|
+
one_of.each_index do |index|
|
22
|
+
combinations.push([schema.merge('oneOf' => [one_of[index]]), "oneOf.#{index}"])
|
23
|
+
end
|
24
|
+
elsif value.is_a?(Hash)
|
25
|
+
com = inception(value, [])
|
26
|
+
com.each do |combination|
|
27
|
+
combination[0] = { key => value.merge(combination[0])}
|
28
|
+
combination[1] = "#{key}.#{combination[1]}"
|
29
|
+
end
|
30
|
+
combinations += com
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
26
|
-
|
34
|
+
combinations
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
@@ -13,7 +13,9 @@ module Fitting
|
|
13
13
|
array += JSON.load(File.read(file))
|
14
14
|
end
|
15
15
|
@to_a = array.inject([]) do |res, tested_request|
|
16
|
-
|
16
|
+
request = Fitting::Records::Spherical::Request.load(tested_request)
|
17
|
+
next res unless request.path.to_s.start_with?(Fitting.configuration.prefix)
|
18
|
+
res.push(request)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'fitting/report/responses'
|
2
|
+
|
3
|
+
module Fitting
|
4
|
+
module Report
|
5
|
+
class Action
|
6
|
+
def initialize(action)
|
7
|
+
@action = action
|
8
|
+
@tests = Fitting::Report::Tests.new([])
|
9
|
+
@responses = Fitting::Report::Responses.new(@action.responses)
|
10
|
+
end
|
11
|
+
|
12
|
+
def method
|
13
|
+
@action.method
|
14
|
+
end
|
15
|
+
|
16
|
+
def path
|
17
|
+
@action.path.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def responses
|
21
|
+
@responses
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_test(test)
|
25
|
+
@tests.push(test)
|
26
|
+
end
|
27
|
+
|
28
|
+
def path_match(find_path)
|
29
|
+
regexp =~ find_path
|
30
|
+
end
|
31
|
+
|
32
|
+
def regexp
|
33
|
+
return @regexp if @regexp
|
34
|
+
|
35
|
+
str = Regexp.escape(path)
|
36
|
+
str = str.gsub(/\\{\w+\\}/, '[^&=\/]+')
|
37
|
+
str = "\\A#{str}\\z"
|
38
|
+
@regexp = Regexp.new(str)
|
39
|
+
end
|
40
|
+
|
41
|
+
def tests
|
42
|
+
@tests
|
43
|
+
end
|
44
|
+
|
45
|
+
def details
|
46
|
+
{
|
47
|
+
tests_without_responses: @tests.without_responses,
|
48
|
+
responses_details: @responses.to_a.map { |r| {method: r.status, tests_size: r.tests.size, json_schema: r.id, combinations: r.details} }
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'fitting/report/action'
|
2
|
+
|
3
|
+
module Fitting
|
4
|
+
module Report
|
5
|
+
class Actions
|
6
|
+
def initialize(prefix, tomogram_json_path)
|
7
|
+
actions = Tomograph::Tomogram.new(
|
8
|
+
prefix: prefix,
|
9
|
+
tomogram_json_path: tomogram_json_path
|
10
|
+
)
|
11
|
+
@actions = []
|
12
|
+
actions.to_a.map do |action|
|
13
|
+
@actions.push(Fitting::Report::Action.new(action))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_a
|
18
|
+
@actions
|
19
|
+
end
|
20
|
+
|
21
|
+
def join(tests)
|
22
|
+
tests.to_a.map do |test|
|
23
|
+
if is_there_a_suitable_action?(test)
|
24
|
+
cram_into_the_appropriate_action(test)
|
25
|
+
test.mark_action
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_there_a_suitable_action?(test)
|
31
|
+
@actions.map do |action|
|
32
|
+
return true if test.method == action.method && action.path_match(test.path)
|
33
|
+
end
|
34
|
+
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
38
|
+
def cram_into_the_appropriate_action(test)
|
39
|
+
@actions.map do |action|
|
40
|
+
if test.method == action.method && action.path_match(test.path)
|
41
|
+
action.add_test(test)
|
42
|
+
return
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def details(prefix)
|
48
|
+
{
|
49
|
+
tests_without_actions: prefix.tests.without_actions,
|
50
|
+
actions_details: @actions.map { |a| {method: a.method, path: a.path, tests_size: a.tests.size, responses: a.details} }
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fitting
|
2
|
+
module Report
|
3
|
+
class Combination
|
4
|
+
def initialize(json_schema:, type:, combination:)
|
5
|
+
@json_schema = json_schema
|
6
|
+
@type = type
|
7
|
+
@combination = combination
|
8
|
+
@tests = Fitting::Report::Tests.new([])
|
9
|
+
@id = SecureRandom.hex
|
10
|
+
end
|
11
|
+
|
12
|
+
def json_schema
|
13
|
+
@json_schema
|
14
|
+
end
|
15
|
+
|
16
|
+
def id
|
17
|
+
@id
|
18
|
+
end
|
19
|
+
|
20
|
+
def type
|
21
|
+
@type
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
@combination
|
26
|
+
end
|
27
|
+
|
28
|
+
def tests
|
29
|
+
@tests
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_test(test)
|
33
|
+
@tests.push(test)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|