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
@@ -1,158 +0,0 @@
|
|
1
|
-
require 'tomograph'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
module Storage
|
5
|
-
class WhiteList
|
6
|
-
def initialize(prefix, white_list, resource_white_list, include_resources, include_actions, resources)
|
7
|
-
@prefix = prefix
|
8
|
-
@white_list = white_list
|
9
|
-
@resource_white_list = resource_white_list
|
10
|
-
@include_resources = include_resources
|
11
|
-
@include_actions = include_actions
|
12
|
-
@resources = resources
|
13
|
-
@warnings = []
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_a
|
17
|
-
return nil if @white_list == nil && @resource_white_list == nil && @include_resources == nil && @include_actions == nil
|
18
|
-
return @white_list if @white_list
|
19
|
-
return @white_list = transformation if @resource_white_list
|
20
|
-
|
21
|
-
@white_list = {}
|
22
|
-
@white_list.merge!(new_transformation) if @include_resources
|
23
|
-
@white_list.merge!(postnew_transformation) if @include_actions
|
24
|
-
@white_list
|
25
|
-
end
|
26
|
-
|
27
|
-
def without_group
|
28
|
-
return @without_group_list if @without_group_list
|
29
|
-
|
30
|
-
@without_group_list = @resource_white_list.inject([]) do |all_requests, resource|
|
31
|
-
resource_selection(resource, all_requests)
|
32
|
-
end.flatten.uniq
|
33
|
-
puts_warnings
|
34
|
-
@without_group_list
|
35
|
-
end
|
36
|
-
|
37
|
-
def resource_selection(resource, all_requests)
|
38
|
-
if resource[1] == []
|
39
|
-
find_warnings(resource[0])
|
40
|
-
requests(@resources[resource[0]], all_requests)
|
41
|
-
else
|
42
|
-
requests(resource[1], all_requests)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def find_warnings(resource)
|
47
|
-
return nil if @resources[resource]
|
48
|
-
|
49
|
-
@warnings.push(
|
50
|
-
"FITTING WARNING: In the documentation there isn't resource from the resource_white_list #{resource}"
|
51
|
-
)
|
52
|
-
end
|
53
|
-
|
54
|
-
def puts_warnings
|
55
|
-
return nil if @warnings == []
|
56
|
-
|
57
|
-
warnings_string = @warnings.join("\n")
|
58
|
-
puts "\n#{warnings_string}"
|
59
|
-
end
|
60
|
-
|
61
|
-
def requests(resource, all_requests)
|
62
|
-
return all_requests unless resource
|
63
|
-
|
64
|
-
resource.map do |request|
|
65
|
-
all_requests.push(request_hash(request))
|
66
|
-
end
|
67
|
-
all_requests
|
68
|
-
end
|
69
|
-
|
70
|
-
def transformation
|
71
|
-
result = without_group.group_by { |action| action[:path] }
|
72
|
-
result.inject({}) do |res, group|
|
73
|
-
methods = group.last.map { |gr| gr[:method] }
|
74
|
-
res.merge(group.first => methods)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def request_hash(request)
|
79
|
-
array = request.split(' ')
|
80
|
-
{
|
81
|
-
method: array[0],
|
82
|
-
path: Tomograph::Path.new(array[1]).to_s
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
def new_transformation
|
87
|
-
@new_resources = {}
|
88
|
-
@resources.map do |key, value|
|
89
|
-
@new_resources.merge!(Tomograph::Path.new(key).to_s => value)
|
90
|
-
end
|
91
|
-
result = new_without_group.group_by { |action| action[:path] }
|
92
|
-
result.inject({}) do |res, group|
|
93
|
-
methods = group.last.map { |gr| gr[:method] }
|
94
|
-
res.merge(group.first => methods)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def new_without_group
|
99
|
-
return @newwithout_group_list if @newwithout_group_list
|
100
|
-
|
101
|
-
@newwithout_group_list = @include_resources.inject([]) do |all_requests, resource|
|
102
|
-
if resource[0] == '/'
|
103
|
-
new_resource_selection(resource, all_requests)
|
104
|
-
else
|
105
|
-
new_resource_selection("/#{resource}", all_requests)
|
106
|
-
end
|
107
|
-
end.flatten.uniq
|
108
|
-
puts_warnings
|
109
|
-
@newwithout_group_list
|
110
|
-
end
|
111
|
-
|
112
|
-
def new_resource_selection(resource, all_requests)
|
113
|
-
new_find_warnings(resource)
|
114
|
-
new_requests(@new_resources[resource], all_requests)
|
115
|
-
end
|
116
|
-
|
117
|
-
def new_requests(resource, all_requests)
|
118
|
-
return all_requests unless resource
|
119
|
-
|
120
|
-
resource.map do |request|
|
121
|
-
all_requests.push(request_hash(request))
|
122
|
-
end
|
123
|
-
all_requests
|
124
|
-
end
|
125
|
-
|
126
|
-
def new_find_warnings(resource)
|
127
|
-
return nil if @new_resources[resource]
|
128
|
-
|
129
|
-
@warnings.push(
|
130
|
-
"FITTING WARNING: In the documentation there isn't resource from the resource_white_list #{resource}"
|
131
|
-
)
|
132
|
-
end
|
133
|
-
|
134
|
-
def postnew_transformation
|
135
|
-
result = postnew_without_group.group_by { |action| action[:path] }
|
136
|
-
result.inject({}) do |res, group|
|
137
|
-
methods = group.last.map { |gr| gr[:method] }
|
138
|
-
res.merge(group.first => methods)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def postnew_without_group
|
143
|
-
return @postnewwithout_group_list if @postnewwithout_group_list
|
144
|
-
|
145
|
-
@postnewwithout_group_list = @include_actions.inject([]) do |all_requests, resource|
|
146
|
-
method, path = resource.split(' ')
|
147
|
-
if path[0] == '/'
|
148
|
-
new_requests(["#{method} #{@prefix}#{path}"], all_requests)
|
149
|
-
else
|
150
|
-
new_requests(["#{method} #{@prefix}/#{path}"], all_requests)
|
151
|
-
end
|
152
|
-
end.flatten.uniq
|
153
|
-
puts_warnings
|
154
|
-
@postnewwithout_group_list
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Fitting
|
2
|
-
class Templates
|
3
|
-
class RealizedTemplate
|
4
|
-
def initialize(realized_unit)
|
5
|
-
@realized_unit = realized_unit
|
6
|
-
end
|
7
|
-
|
8
|
-
def to_s
|
9
|
-
res = ''
|
10
|
-
res += "1. Find request method and path:\n"
|
11
|
-
@realized_unit.test_file_paths.each do |key, requests|
|
12
|
-
all_good = requests.all?(&:documented?)
|
13
|
-
res += "file: #{key} #{all_good ? '✔' : '✖'}\n"
|
14
|
-
end
|
15
|
-
res += "\n2. Find response status code:\n"
|
16
|
-
@realized_unit.test_file_paths.each do |key, requests|
|
17
|
-
all_good = requests.all?(&:response_documented?)
|
18
|
-
res += "file: #{key} #{all_good ? '✔' : '✖'}\n"
|
19
|
-
end
|
20
|
-
res += "\n3. Find response json-schemas:\n"
|
21
|
-
@realized_unit.test_file_paths.each do |key, requests|
|
22
|
-
all_good = requests.all?(&:response_json_schemas?)
|
23
|
-
res += "file: #{key} #{all_good ? '✔' : '✖'}\n"
|
24
|
-
end
|
25
|
-
res += "\n4. Check valid json-schemas:\n"
|
26
|
-
@realized_unit.test_file_paths.each do |key, requests|
|
27
|
-
all_good = requests.all?(&:valid_json_schemas?)
|
28
|
-
res += "path: #{key} #{all_good ? '✔' : '✖'}\n"
|
29
|
-
next if all_good
|
30
|
-
|
31
|
-
requests.map do |request|
|
32
|
-
next if request.valid_json_schemas?
|
33
|
-
|
34
|
-
res += " full path: #{request.test_path} ✖\n"
|
35
|
-
res += " request.method #{request.method}\n"
|
36
|
-
res += " request.path #{request.path}\n"
|
37
|
-
res += " request.response.status #{request.response.status}\n"
|
38
|
-
res += " request.response.body #{request.response.body}\n\n"
|
39
|
-
request.invalid_json_schemas.map do |schema|
|
40
|
-
res += " json_schemas: #{schema[:json_schema]}\n"
|
41
|
-
res += " fully_validate: #{schema[:fully_validate]}\n\n"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
res
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
!!! 5
|
2
|
-
%html
|
3
|
-
%head
|
4
|
-
%title= Time.now
|
5
|
-
%meta{charset: "utf-8"}
|
6
|
-
%body
|
7
|
-
- @to_hash.each do |key, value|
|
8
|
-
%details
|
9
|
-
%summary{class: "collapse #{value['type']}"}
|
10
|
-
= "#{key} #{value['cover']}"
|
11
|
-
%div{class: 'group'}
|
12
|
-
%div{class: 'section'}
|
13
|
-
%div
|
14
|
-
%b main json-schema
|
15
|
-
%xmp
|
16
|
-
= value['json_schema']
|
data/lib/fitting/view/style.css
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
summary {
|
2
|
-
margin: 10px;
|
3
|
-
}
|
4
|
-
|
5
|
-
summary:hover {
|
6
|
-
background: #e1e1e1;
|
7
|
-
}
|
8
|
-
|
9
|
-
.passed {
|
10
|
-
color: green;
|
11
|
-
}
|
12
|
-
|
13
|
-
.failed {
|
14
|
-
color: red;
|
15
|
-
}
|
16
|
-
|
17
|
-
.pending {
|
18
|
-
color: orange;
|
19
|
-
}
|
20
|
-
|
21
|
-
.collapse {
|
22
|
-
cursor: pointer;
|
23
|
-
display: block;
|
24
|
-
background: white;
|
25
|
-
}
|
26
|
-
|
27
|
-
.collapse + input {
|
28
|
-
display: none; /* hide the checkboxes */
|
29
|
-
}
|
30
|
-
|
31
|
-
.collapse + input + div {
|
32
|
-
display: none;
|
33
|
-
}
|
34
|
-
|
35
|
-
.collapse + input:checked + div {
|
36
|
-
display: block;
|
37
|
-
}
|
38
|
-
|
39
|
-
.section {
|
40
|
-
padding-top: 10px;
|
41
|
-
}
|
42
|
-
|
43
|
-
.group {
|
44
|
-
border: 1px solid black;
|
45
|
-
margin: 5px 0px;
|
46
|
-
padding: 0px 5px;
|
47
|
-
}
|