fitting 2.13.0 → 2.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cb768409f791b3b1af04fdcee07ae65bb5156ee
4
- data.tar.gz: 2ff46f1b9f5412cc3d79c9d3908243584d896bee
3
+ metadata.gz: 483a7f1462b7204b2dbeb31d372ad2526783c775
4
+ data.tar.gz: eef485bd208b70fbe0fd10e350e3bda9e82ac084
5
5
  SHA512:
6
- metadata.gz: 70f5a4114b36c30a665cc3792b73000c557b78c8d1fd925a10d66b5aac3df16f953aa40b72be5093dca176915059697867807f8e8923ced92151f990da7aaceb
7
- data.tar.gz: aaecda82b7dcc6307a7dc168c162f2654568cae2ea0327653127e7b688bec23969b0f51eb7090aec58e8ba46e18d144f3734da8813d405e0a0220217d2678c08
6
+ metadata.gz: 16b2442c467a9a507262b721fe4d0528af989ae7ab9a7f8f703d740ca692aedf97c47c7cb8eec180955ade9b151c85948af723ca301dcdb73c56cf9b06e14250
7
+ data.tar.gz: 2e42661f2d0a13f794cb6c808ea5b4d6e3b7fbc8d2ae368c4948a2cfc69a7e8a398333cc8de76a3e70cc6db63bceea03f4df76b14acdc6757dc53107fc883400
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ### 2.13.1 - 2020-04-17
4
+
5
+ * fixes
6
+ * combinations
7
+
3
8
  ### 2.13.0 - 2020-02-26
4
9
 
5
10
  * features
@@ -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', '~> 10.0'
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'
@@ -16,17 +16,19 @@ module Fitting
16
16
  def inception(json_schema, combinations)
17
17
  json_schema.each do |key, value|
18
18
  if key == 'properties' and json_schema['required'] != value.keys
19
- one_of = json_schema.delete('required') || []
20
- json_schema['properties'].each_key do |property|
19
+ schema = json_schema.dup
20
+ one_of = schema.delete('required') || []
21
+ schema['properties'].each_key do |property|
21
22
  next if one_of.include?(property)
22
- combinations.push([json_schema.merge('required' => one_of + [property]), "required.#{property}"])
23
+ combinations.push([schema.merge('required' => one_of + [property]), "required.#{property}"])
23
24
  end
24
25
  elsif value.is_a?(Hash)
25
- inception(value, combinations)
26
- combinations.each do |combination|
27
- combination[0] = { key => combination[0]}
26
+ com = inception(value, [])
27
+ com.each do |combination|
28
+ combination[0] = { key => value.merge(combination[0])}
28
29
  combination[1] = "#{key}.#{combination[1]}"
29
30
  end
31
+ combinations += com
30
32
  end
31
33
  end
32
34
 
@@ -15,17 +15,19 @@ module Fitting
15
15
 
16
16
  def inception(json_schema, combinations)
17
17
  json_schema.each do |key, value|
18
- if key == 'enum'
19
- one_of = json_schema.delete('enum')
18
+ if key == 'enum' && value.size > 1
19
+ schema = json_schema.dup
20
+ one_of = schema.delete('enum')
20
21
  one_of.each_index do |index|
21
- combinations.push([json_schema.merge('enum' => [one_of[index]]), "enum.#{one_of[index]}"])
22
+ combinations.push([schema.merge('enum' => [one_of[index]]), "enum.#{one_of[index]}"])
22
23
  end
23
24
  elsif value.is_a?(Hash)
24
- inception(value, combinations)
25
- combinations.each do |combination|
26
- combination[0] = { key => combination[0]}
25
+ com = inception(value, [])
26
+ com.each do |combination|
27
+ combination[0] = { key => value.merge(combination[0])}
27
28
  combination[1] = "#{key}.#{combination[1]}"
28
29
  end
30
+ combinations += com
29
31
  end
30
32
  end
31
33
 
@@ -16,16 +16,18 @@ module Fitting
16
16
  def inception(json_schema, combinations)
17
17
  json_schema.each do |key, value|
18
18
  if key == 'oneOf'
19
- one_of = json_schema.delete('oneOf')
19
+ schema = json_schema.dup
20
+ one_of = schema.delete('oneOf')
20
21
  one_of.each_index do |index|
21
- combinations.push([json_schema.merge('oneOf' => [one_of[index]]), "oneOf.#{index}"])
22
+ combinations.push([schema.merge('oneOf' => [one_of[index]]), "oneOf.#{index}"])
22
23
  end
23
24
  elsif value.is_a?(Hash)
24
- inception(value, combinations)
25
- combinations.each do |combination|
26
- combination[0] = { key => combination[0]}
25
+ com = inception(value, [])
26
+ com.each do |combination|
27
+ combination[0] = { key => value.merge(combination[0])}
27
28
  combination[1] = "#{key}.#{combination[1]}"
28
29
  end
30
+ combinations += com
29
31
  end
30
32
  end
31
33
 
@@ -1,3 +1,3 @@
1
1
  module Fitting
2
- VERSION = '2.13.0'.freeze
2
+ VERSION = '2.13.1'.freeze
3
3
  end
@@ -5,8 +5,101 @@ require 'fitting/templates/realized_template'
5
5
  require 'fitting/statistics/template_cover_error'
6
6
  require 'fitting/statistics/template_cover_error_enum'
7
7
  require 'fitting/statistics/template_cover_error_one_of'
8
+ require 'fitting/cover/json_schema'
8
9
 
9
10
  namespace :fitting do
11
+ task :report do
12
+ yaml = YAML.safe_load(File.read('.fitting.yml'))
13
+ tomogram = Tomograph::Tomogram.new(
14
+ prefix: yaml['prefix'],
15
+ tomogram_json_path: yaml['tomogram_json_path']
16
+ )
17
+ tests = []
18
+ Dir['fitting_tests/*.json'].each do |file|
19
+ tests += JSON.load(File.read(file))
20
+ end
21
+ actions = tomogram.to_a
22
+ actions.map do |action|
23
+ action = action.to_hash
24
+ action["tests"] = []
25
+ end
26
+
27
+ tests.map do |test|
28
+ actions.map do |action|
29
+ if test['method'] == action.method && action.path.match(test['path'])
30
+ action.to_hash["tests"].push(test)
31
+ tests = tests - [test]
32
+ break
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ actions.map do |action|
39
+ action.to_hash["tests"].map do |test|
40
+ action.to_hash["responses"].map do |response|
41
+ if response['status'].to_s == test['response']['status'].to_s
42
+ if JSON::Validator.fully_validate(response['body'], test['response']['body']) == []
43
+ response['tests'] ||= []
44
+ response['tests'].push(test)
45
+ action.to_hash["tests"] = action.to_hash["tests"] - [test]
46
+ break
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ actions.map do |action|
54
+ action.to_hash["responses"].map do |response|
55
+ response['combination'] ||= []
56
+ combinations = Fitting::Cover::JSONSchema.new(response['body']).combi + Fitting::Cover::JSONSchemaEnum.new(response['body']).combi + Fitting::Cover::JSONSchemaOneOf.new(response['body']).combi
57
+ if combinations != []
58
+ combinations.map do |combination|
59
+ response['combination'].push(
60
+ {
61
+ 'json_schema' => combination[0],
62
+ 'type' => combination[1][0],
63
+ 'combination' => combination[1][1],
64
+ 'tests' => [],
65
+ 'error' => []
66
+ }
67
+ )
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ actions.map do |action|
74
+ action.to_hash["responses"].map do |response|
75
+ response['tests'] ||= []
76
+ response['tests'].map do |test|
77
+ if response['combination'][0]
78
+ response['combination'].map do |combination|
79
+ begin
80
+ res = JSON::Validator.fully_validate(combination['json_schema'], test['response']['body'])
81
+ if res == []
82
+ combination['tests'].push(test)
83
+ response['tests'] = response['tests'] - [test]
84
+ next
85
+ else
86
+ combination['error'].push({test: test, error: res})
87
+ end
88
+ rescue JSON::Schema::SchemaError => error
89
+ combination['error'].push({test: test, error: error})
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ actions_test = {actions: actions, tests: tests}
98
+
99
+ makedirs('fitting')
100
+ File.open('fitting/report.json', 'w') { |file| file.write(MultiJson.dump(actions_test)) }
101
+ end
102
+
10
103
  # deprecated
11
104
  desc 'Fitting documentation'
12
105
  task :documentation do
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: 2.13.0
4
+ version: 2.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.efimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -102,16 +102,16 @@ dependencies:
102
102
  name: rake
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - "~>"
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
- version: '10.0'
107
+ version: 12.3.3
108
108
  type: :development
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - "~>"
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: '10.0'
114
+ version: 12.3.3
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: rspec
117
117
  requirement: !ruby/object:Gem::Requirement