fitting 2.18.3 → 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 +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
data/lib/fitting.rb
CHANGED
@@ -1,73 +1,68 @@
|
|
1
1
|
require 'fitting/version'
|
2
2
|
require 'fitting/configuration'
|
3
|
-
|
4
|
-
require 'fitting/documentation'
|
3
|
+
|
5
4
|
require 'fitting/storage/responses'
|
5
|
+
require 'fitting/tests'
|
6
|
+
require 'fitting/cover/json_schema_enum'
|
7
|
+
require 'fitting/cover/json_schema_one_of'
|
8
|
+
require 'fitting/records/documented/request'
|
6
9
|
require 'fitting/railtie' if defined?(Rails)
|
7
10
|
|
8
11
|
module Fitting
|
9
12
|
class << self
|
10
|
-
def configure
|
11
|
-
yield configuration
|
12
|
-
end
|
13
|
-
|
14
13
|
def configuration
|
15
|
-
|
14
|
+
yaml = YAML.safe_load(File.read('.fitting.yml'))
|
15
|
+
@configuration ||= Configuration.new(yaml)
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.after(:each, type: :controller) do
|
23
|
-
responses.add(response, inspect)
|
24
|
-
end
|
25
|
-
|
26
|
-
config.after(:suite) do
|
27
|
-
responses.statistics.save
|
28
|
-
end
|
29
|
-
end
|
18
|
+
def configure
|
19
|
+
yield(configuration)
|
30
20
|
end
|
31
21
|
|
32
|
-
|
33
|
-
|
22
|
+
def clear_tests_directory
|
23
|
+
FileUtils.rm_r Dir.glob(configuration.rspec_json_path), force: true
|
24
|
+
FileUtils.rm_r Dir.glob(configuration.webmock_json_path), force: true
|
25
|
+
end
|
34
26
|
|
35
27
|
def save_test_data
|
36
|
-
|
28
|
+
clear_tests_directory
|
37
29
|
|
38
|
-
|
30
|
+
outgoing_responses = Fitting::Storage::Responses.new
|
31
|
+
responses = Fitting::Storage::Responses.new
|
39
32
|
|
40
33
|
RSpec.configure do |config|
|
34
|
+
if defined?(WebMock)
|
35
|
+
config.before(:each) do |example|
|
36
|
+
WebMock.after_request do |request_signature, response|
|
37
|
+
env = Rack::MockRequest.env_for(request_signature.uri, { method: request_signature.method })
|
38
|
+
# Парсим в тот формат с которым работает fitting
|
39
|
+
mock_request = ActionDispatch::Request.new(env)
|
40
|
+
mock_response = ActionDispatch::Response.create(response.status.first || 200, response.headers || {},
|
41
|
+
response.body || {})
|
42
|
+
mock_response.instance_variable_set(:@request, mock_request)
|
43
|
+
|
44
|
+
outgoing_responses.add(mock_response, example)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
41
49
|
config.after(:each, type: :request) do |example|
|
42
|
-
responses.add(response, example
|
50
|
+
responses.add(response, example)
|
43
51
|
end
|
44
52
|
|
45
53
|
config.after(:each, type: :controller) do |example|
|
46
|
-
responses.add(response, example
|
54
|
+
responses.add(response, example)
|
55
|
+
end
|
56
|
+
|
57
|
+
config.after(:each) do
|
58
|
+
WebMock::CallbackRegistry.reset
|
47
59
|
end
|
48
60
|
|
49
61
|
config.after(:suite) do
|
50
62
|
responses.tests.save
|
63
|
+
outgoing_responses.tests.outgoing_save
|
51
64
|
end
|
52
65
|
end
|
53
66
|
end
|
54
67
|
end
|
55
|
-
|
56
|
-
def self.loaded_tasks=(val)
|
57
|
-
@loaded_tasks = val
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.loaded_tasks
|
61
|
-
@loaded_tasks
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.load_tasks
|
65
|
-
return if loaded_tasks
|
66
|
-
|
67
|
-
self.loaded_tasks = true
|
68
|
-
|
69
|
-
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each do |rake|
|
70
|
-
load rake
|
71
|
-
end
|
72
|
-
end
|
73
68
|
end
|
data/lib/tasks/fitting.rake
CHANGED
@@ -1,10 +1,4 @@
|
|
1
1
|
require 'fitting/records/spherical/requests'
|
2
|
-
require 'fitting/configuration'
|
3
|
-
require 'fitting/records/realized_unit'
|
4
|
-
require 'fitting/templates/realized_template'
|
5
|
-
require 'fitting/statistics/template_cover_error'
|
6
|
-
require 'fitting/statistics/template_cover_error_enum'
|
7
|
-
require 'fitting/statistics/template_cover_error_one_of'
|
8
2
|
require 'fitting/cover/json_schema'
|
9
3
|
require 'fitting/report/prefixes'
|
10
4
|
require 'fitting/report/tests'
|
@@ -12,8 +6,8 @@ require 'fitting/report/console'
|
|
12
6
|
|
13
7
|
namespace :fitting do
|
14
8
|
task :report do
|
15
|
-
tests = Fitting::Report::Tests.new_from_config
|
16
|
-
prefixes = Fitting::Report::Prefixes.new(
|
9
|
+
tests = Fitting::Report::Tests.new_from_config
|
10
|
+
prefixes = Fitting::Report::Prefixes.new(Fitting.configuration.prefixes)
|
17
11
|
|
18
12
|
prefixes.join(tests)
|
19
13
|
|
@@ -93,183 +87,5 @@ namespace :fitting do
|
|
93
87
|
exit 1 unless console.good?
|
94
88
|
|
95
89
|
exit 0
|
96
|
-
|
97
|
-
actions.map do |action|
|
98
|
-
action.to_hash['responses'].map do |response|
|
99
|
-
response['combination'] ||= []
|
100
|
-
combinations = Fitting::Cover::JSONSchema.new(response['body']).combi +
|
101
|
-
Fitting::Cover::JSONSchemaEnum.new(response['body']).combi +
|
102
|
-
Fitting::Cover::JSONSchemaOneOf.new(response['body']).combi
|
103
|
-
next unless combinations != []
|
104
|
-
|
105
|
-
combinations.map do |combination|
|
106
|
-
response['combination'].push(
|
107
|
-
{
|
108
|
-
'json_schema' => combination[0],
|
109
|
-
'type' => combination[1][0],
|
110
|
-
'combination' => combination[1][1],
|
111
|
-
'tests' => [],
|
112
|
-
'error' => []
|
113
|
-
}
|
114
|
-
)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
actions.map do |action|
|
120
|
-
action.to_hash['responses'].map do |response|
|
121
|
-
response['tests'] ||= []
|
122
|
-
response['tests'].map do |test|
|
123
|
-
next unless response['combination'][0]
|
124
|
-
|
125
|
-
response['combination'].map do |combination|
|
126
|
-
res = JSON::Validator.fully_validate(combination['json_schema'], test['response']['body'])
|
127
|
-
if res == []
|
128
|
-
combination['tests'].push(test)
|
129
|
-
response['tests'] = response['tests'] - [test]
|
130
|
-
next
|
131
|
-
else
|
132
|
-
combination['error'].push({ test: test, error: res })
|
133
|
-
end
|
134
|
-
rescue JSON::Schema::SchemaError => e
|
135
|
-
combination['error'].push({ test: test, error: e })
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
actions_test = { actions: actions, tests: tests }
|
142
|
-
|
143
|
-
makedirs('fitting')
|
144
|
-
File.open('fitting/old_report.json', 'w') { |file| file.write(JSON.dump(actions_test)) }
|
145
|
-
end
|
146
|
-
|
147
|
-
# deprecated
|
148
|
-
desc 'Fitting documentation'
|
149
|
-
task :documentation do
|
150
|
-
documented_unit = Fitting::Statistics::Template.new(
|
151
|
-
Fitting::Records::Spherical::Requests.new,
|
152
|
-
Fitting.configuration
|
153
|
-
)
|
154
|
-
puts documented_unit.stats
|
155
|
-
|
156
|
-
unless documented_unit.not_covered == "\n"
|
157
|
-
puts 'Not all responses from the whitelist are covered!'
|
158
|
-
exit 1
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
desc 'Fitting documentation responses cover'
|
163
|
-
task :documentation_responses, [:size] => :environment do |_, args|
|
164
|
-
case args.size
|
165
|
-
when 'xs'
|
166
|
-
documented_unit = Fitting::Statistics::Template.new(
|
167
|
-
Fitting::Records::Spherical::Requests.new,
|
168
|
-
Fitting.configuration
|
169
|
-
)
|
170
|
-
puts documented_unit.stats
|
171
|
-
|
172
|
-
unless documented_unit.not_covered == "\n"
|
173
|
-
puts 'Not all responses from the whitelist are covered!'
|
174
|
-
exit 1
|
175
|
-
end
|
176
|
-
when 's'
|
177
|
-
documented_unit = Fitting::Statistics::Template.new(
|
178
|
-
Fitting::Records::Spherical::Requests.new,
|
179
|
-
Fitting.configuration,
|
180
|
-
'cover'
|
181
|
-
)
|
182
|
-
puts documented_unit.stats
|
183
|
-
|
184
|
-
unless documented_unit.not_covered == "\n"
|
185
|
-
puts 'Not all responses from the whitelist are covered!'
|
186
|
-
exit 1
|
187
|
-
end
|
188
|
-
when 'm'
|
189
|
-
documented_unit = Fitting::Statistics::Template.new(
|
190
|
-
Fitting::Records::Spherical::Requests.new,
|
191
|
-
Fitting.configuration,
|
192
|
-
'cover_enum'
|
193
|
-
)
|
194
|
-
puts documented_unit.stats
|
195
|
-
|
196
|
-
unless documented_unit.not_covered == "\n"
|
197
|
-
puts 'Not all responses from the whitelist are covered!'
|
198
|
-
exit 1
|
199
|
-
end
|
200
|
-
when 'l'
|
201
|
-
documented_unit = Fitting::Statistics::Template.new(
|
202
|
-
Fitting::Records::Spherical::Requests.new,
|
203
|
-
Fitting.configuration,
|
204
|
-
'cover_one_of'
|
205
|
-
)
|
206
|
-
puts documented_unit.stats
|
207
|
-
|
208
|
-
unless documented_unit.not_covered == "\n"
|
209
|
-
puts 'Not all responses from the whitelist are covered!'
|
210
|
-
exit 1
|
211
|
-
end
|
212
|
-
else
|
213
|
-
puts 'need key xs, s, m or l'
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
desc 'Fitting documentation responses cover error'
|
218
|
-
task :documentation_responses_error, [:size] => :environment do |_, args|
|
219
|
-
case args.size
|
220
|
-
when 's'
|
221
|
-
documented_unit = Fitting::Statistics::TemplateCoverError.new(
|
222
|
-
Fitting::Records::Spherical::Requests.new,
|
223
|
-
Fitting.configuration
|
224
|
-
)
|
225
|
-
puts documented_unit.stats
|
226
|
-
when 'm'
|
227
|
-
documented_unit = Fitting::Statistics::TemplateCoverErrorEnum.new(
|
228
|
-
Fitting::Records::Spherical::Requests.new,
|
229
|
-
Fitting.configuration
|
230
|
-
)
|
231
|
-
puts documented_unit.stats
|
232
|
-
when 'l'
|
233
|
-
documented_unit = Fitting::Statistics::TemplateCoverErrorOneOf.new(
|
234
|
-
Fitting::Records::Spherical::Requests.new,
|
235
|
-
Fitting.configuration
|
236
|
-
)
|
237
|
-
puts documented_unit.stats
|
238
|
-
else
|
239
|
-
puts 'need key s, m or l'
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
# deprecated
|
244
|
-
desc 'Fitting tests'
|
245
|
-
task :tests do
|
246
|
-
realized_unit = Fitting::Records::RealizedUnit.new(
|
247
|
-
Fitting::Records::Spherical::Requests.new,
|
248
|
-
Fitting.configuration.tomogram
|
249
|
-
)
|
250
|
-
puts Fitting::Templates::RealizedTemplate.new(realized_unit).to_s
|
251
|
-
|
252
|
-
unless realized_unit.fully_covered?
|
253
|
-
puts 'Not all responses from the whitelist are covered!'
|
254
|
-
exit 1
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
desc 'Fitting tests'
|
259
|
-
task :tests_responses, [:size] => :environment do |_, args|
|
260
|
-
if args.size == 'xs'
|
261
|
-
realized_unit = Fitting::Records::RealizedUnit.new(
|
262
|
-
Fitting::Records::Spherical::Requests.new,
|
263
|
-
Fitting.configuration.tomogram
|
264
|
-
)
|
265
|
-
puts Fitting::Templates::RealizedTemplate.new(realized_unit).to_s
|
266
|
-
|
267
|
-
unless realized_unit.fully_covered?
|
268
|
-
puts 'Not all responses from the whitelist are covered!'
|
269
|
-
exit 1
|
270
|
-
end
|
271
|
-
else
|
272
|
-
puts 'need key xs'
|
273
|
-
end
|
274
90
|
end
|
275
91
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'fitting/records/spherical/requests'
|
2
|
+
require 'fitting/cover/json_schema'
|
3
|
+
require 'fitting/report/prefixes'
|
4
|
+
require 'fitting/report/tests'
|
5
|
+
require 'fitting/report/console'
|
6
|
+
|
7
|
+
namespace :fitting_out do
|
8
|
+
task :report do
|
9
|
+
tests = Fitting::Report::Tests.new_from_outgoing_config
|
10
|
+
prefixes = Fitting::Report::Prefixes.new(Fitting.configuration.prefixes)
|
11
|
+
|
12
|
+
prefixes.join(tests)
|
13
|
+
|
14
|
+
prefixes.to_a.map do |prefix|
|
15
|
+
prefix.actions.join(prefix.tests) unless prefix.skip?
|
16
|
+
end
|
17
|
+
|
18
|
+
prefixes.to_a.map do |prefix|
|
19
|
+
next if prefix.skip?
|
20
|
+
|
21
|
+
prefix.actions.to_a.map do |action|
|
22
|
+
action.responses.join(action.tests)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
prefixes.to_a.map do |prefix|
|
27
|
+
next if prefix.skip?
|
28
|
+
|
29
|
+
prefix.actions.to_a.map do |action|
|
30
|
+
action.responses.to_a.map do |response|
|
31
|
+
response.combinations.join(response.tests)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
report = JSON.pretty_generate(
|
37
|
+
{
|
38
|
+
tests_without_prefixes: tests.without_prefixes,
|
39
|
+
prefixes_details: prefixes.to_a.map(&:details)
|
40
|
+
}
|
41
|
+
)
|
42
|
+
|
43
|
+
destination = 'fitting'
|
44
|
+
FileUtils.mkdir_p(destination)
|
45
|
+
FileUtils.rm_r Dir.glob("#{destination}/*"), force: true
|
46
|
+
File.open('fitting/report.json', 'w') { |file| file.write(report) }
|
47
|
+
|
48
|
+
gem_path = $LOAD_PATH.find { |i| i.include?('fitting') }
|
49
|
+
source_path = "#{gem_path}/templates/bomboniere/dist"
|
50
|
+
FileUtils.copy_entry source_path, destination
|
51
|
+
|
52
|
+
json_schemas = {}
|
53
|
+
combinations = {}
|
54
|
+
prefixes.to_a.map do |prefix|
|
55
|
+
next if prefix.skip?
|
56
|
+
|
57
|
+
prefix.actions.to_a.map do |action|
|
58
|
+
action.responses.to_a.map do |response|
|
59
|
+
json_schemas[response.id] = response.body
|
60
|
+
response.combinations.to_a.map do |combination|
|
61
|
+
combinations.merge!(combination.id => combination.json_schema)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
File.open('fitting/json_schemas.json', 'w') { |file| file.write(JSON.pretty_generate(json_schemas)) }
|
67
|
+
File.open('fitting/combinations.json', 'w') { |file| file.write(JSON.pretty_generate(combinations)) }
|
68
|
+
File.open('fitting/tests.json', 'w') { |file| file.write(JSON.pretty_generate(tests.to_h)) }
|
69
|
+
|
70
|
+
js_path = Dir["#{destination}/js/*"].find { |f| f[0..14] == 'fitting/js/app.' and f[-3..] == '.js' }
|
71
|
+
js_file = File.read(js_path)
|
72
|
+
new_js_file = js_file.gsub('{stub:"prefixes report"}', report)
|
73
|
+
new_js_file = new_js_file.gsub('{stub:"for action page"}', report)
|
74
|
+
new_js_file = new_js_file.gsub('{stub:"json-schemas"}', JSON.pretty_generate(json_schemas))
|
75
|
+
new_js_file = new_js_file.gsub('{stub:"combinations"}', JSON.pretty_generate(combinations))
|
76
|
+
new_js_file = new_js_file.gsub('{stub:"tests"}', JSON.pretty_generate(tests.to_h))
|
77
|
+
File.open(js_path, 'w') { |file| file.write(new_js_file) }
|
78
|
+
|
79
|
+
console = Fitting::Report::Console.new(
|
80
|
+
tests.without_prefixes,
|
81
|
+
prefixes.to_a.map(&:details)
|
82
|
+
)
|
83
|
+
|
84
|
+
puts console.output
|
85
|
+
puts console.output_sum
|
86
|
+
|
87
|
+
exit 1 unless console.good?
|
88
|
+
|
89
|
+
exit 0
|
90
|
+
end
|
91
|
+
end
|
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:
|
4
|
+
version: 3.0.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: 2021-
|
11
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
name: rubocop
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- - "
|
145
|
+
- - ">="
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: 1.22.0
|
148
148
|
type: :development
|
149
149
|
prerelease: false
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- - "
|
152
|
+
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: 1.22.0
|
155
155
|
- !ruby/object:Gem::Dependency
|
@@ -193,26 +193,16 @@ files:
|
|
193
193
|
- images/logo.png
|
194
194
|
- lib/fitting.rb
|
195
195
|
- lib/fitting/configuration.rb
|
196
|
-
- lib/fitting/configuration/yaml.rb
|
197
196
|
- lib/fitting/cover/json_schema.rb
|
198
197
|
- lib/fitting/cover/json_schema_enum.rb
|
199
198
|
- lib/fitting/cover/json_schema_one_of.rb
|
200
|
-
- lib/fitting/cover/response.rb
|
201
|
-
- lib/fitting/documentation.rb
|
202
|
-
- lib/fitting/matchers/response_matcher.rb
|
203
199
|
- lib/fitting/railtie.rb
|
204
200
|
- lib/fitting/records/documented/request.rb
|
205
|
-
- lib/fitting/records/realized_unit.rb
|
206
201
|
- lib/fitting/records/spherical/request.rb
|
207
202
|
- lib/fitting/records/spherical/requests.rb
|
208
203
|
- lib/fitting/records/spherical/response.rb
|
209
|
-
- lib/fitting/records/test_unit/request.rb
|
210
204
|
- lib/fitting/records/tested/request.rb
|
211
205
|
- lib/fitting/records/tested/response.rb
|
212
|
-
- lib/fitting/records/unit/combination.rb
|
213
|
-
- lib/fitting/records/unit/json_schema.rb
|
214
|
-
- lib/fitting/records/unit/request.rb
|
215
|
-
- lib/fitting/records/unit/response.rb
|
216
206
|
- lib/fitting/report/action.rb
|
217
207
|
- lib/fitting/report/actions.rb
|
218
208
|
- lib/fitting/report/combination.rb
|
@@ -224,37 +214,11 @@ files:
|
|
224
214
|
- lib/fitting/report/responses.rb
|
225
215
|
- lib/fitting/report/test.rb
|
226
216
|
- lib/fitting/report/tests.rb
|
227
|
-
- lib/fitting/request.rb
|
228
|
-
- lib/fitting/response.rb
|
229
|
-
- lib/fitting/response/fully_validates.rb
|
230
|
-
- lib/fitting/statistics.rb
|
231
|
-
- lib/fitting/statistics/analysis.rb
|
232
|
-
- lib/fitting/statistics/cover_error.rb
|
233
|
-
- lib/fitting/statistics/cover_error_enum.rb
|
234
|
-
- lib/fitting/statistics/cover_error_one_of.rb
|
235
|
-
- lib/fitting/statistics/great.rb
|
236
|
-
- lib/fitting/statistics/list.rb
|
237
|
-
- lib/fitting/statistics/lists.rb
|
238
|
-
- lib/fitting/statistics/measurement.rb
|
239
|
-
- lib/fitting/statistics/measurement_cover.rb
|
240
|
-
- lib/fitting/statistics/measurement_cover_enum.rb
|
241
|
-
- lib/fitting/statistics/measurement_cover_one_of.rb
|
242
|
-
- lib/fitting/statistics/not_covered_responses.rb
|
243
|
-
- lib/fitting/statistics/percent.rb
|
244
|
-
- lib/fitting/statistics/requests_stats.rb
|
245
|
-
- lib/fitting/statistics/responses_stats.rb
|
246
|
-
- lib/fitting/statistics/template.rb
|
247
|
-
- lib/fitting/statistics/template_cover_error.rb
|
248
|
-
- lib/fitting/statistics/template_cover_error_enum.rb
|
249
|
-
- lib/fitting/statistics/template_cover_error_one_of.rb
|
250
217
|
- lib/fitting/storage/responses.rb
|
251
|
-
- lib/fitting/storage/white_list.rb
|
252
|
-
- lib/fitting/templates/realized_template.rb
|
253
218
|
- lib/fitting/tests.rb
|
254
219
|
- lib/fitting/version.rb
|
255
|
-
- lib/fitting/view/report.html.haml
|
256
|
-
- lib/fitting/view/style.css
|
257
220
|
- lib/tasks/fitting.rake
|
221
|
+
- lib/tasks/fitting_outgoing.rake
|
258
222
|
- lib/templates/bomboniere/.gitignore
|
259
223
|
- lib/templates/bomboniere/.tool-versions
|
260
224
|
- lib/templates/bomboniere/README.md
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'tomograph'
|
2
|
-
|
3
|
-
module Fitting
|
4
|
-
class Configuration
|
5
|
-
class Yaml
|
6
|
-
attr_reader :title
|
7
|
-
attr_accessor :apib_path,
|
8
|
-
:drafter_yaml_path,
|
9
|
-
:crafter_apib_path,
|
10
|
-
:crafter_yaml_path,
|
11
|
-
:drafter_4_apib_path,
|
12
|
-
:drafter_4_yaml_path,
|
13
|
-
:tomogram_json_path,
|
14
|
-
:strict,
|
15
|
-
:prefix,
|
16
|
-
:white_list,
|
17
|
-
:resource_white_list,
|
18
|
-
:ignore_list,
|
19
|
-
:include_resources,
|
20
|
-
:include_actions
|
21
|
-
|
22
|
-
def initialize(yaml, title = 'fitting')
|
23
|
-
@apib_path = yaml['apib_path']
|
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']
|
29
|
-
@tomogram_json_path = yaml['tomogram_json_path']
|
30
|
-
@strict = yaml['strict']
|
31
|
-
@prefix = yaml['prefix']
|
32
|
-
@white_list = yaml['white_list']
|
33
|
-
@resource_white_list = yaml['resource_white_list']
|
34
|
-
@ignore_list = yaml['ignore_list']
|
35
|
-
@include_resources = yaml['include_resources']
|
36
|
-
@include_actions = yaml['include_actions']
|
37
|
-
@title = title
|
38
|
-
default
|
39
|
-
end
|
40
|
-
|
41
|
-
def tomogram
|
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
|
62
|
-
end
|
63
|
-
|
64
|
-
def stats_path
|
65
|
-
if @title == 'fitting'
|
66
|
-
'fitting/stats'
|
67
|
-
else
|
68
|
-
"fitting/#{@title}/stats"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def not_covered_path
|
73
|
-
if @title == 'fitting'
|
74
|
-
'fitting/not_covered'
|
75
|
-
else
|
76
|
-
"fitting/#{@title}/not_covered"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def default
|
83
|
-
@strict ||= false if strict.nil?
|
84
|
-
@prefix ||= ''
|
85
|
-
@ignore_list ||= []
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'fitting/cover/json_schema'
|
2
|
-
require 'json-schema'
|
3
|
-
|
4
|
-
module Fitting
|
5
|
-
class Cover
|
6
|
-
class Response
|
7
|
-
def initialize(response)
|
8
|
-
@cover_json_schemas = Fitting::Cover::JSONSchema.new(response.json_schema)
|
9
|
-
@json_schemas = @cover_json_schemas.json_schemas + [response.json_schema]
|
10
|
-
@combinations = @cover_json_schemas.combinations
|
11
|
-
@flags = @cover_json_schemas.json_schemas.map do |json_schema|
|
12
|
-
JSON::Validator.validate(json_schema, response.body)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
attr_reader :json_schemas, :combinations, :flags
|
17
|
-
|
18
|
-
def update(response)
|
19
|
-
index = 0
|
20
|
-
@cover_json_schemas.json_schemas.map do |json_schema|
|
21
|
-
flag = JSON::Validator.validate(json_schema, response.body)
|
22
|
-
@flags[index] = @flags[index] || flag
|
23
|
-
index += 1
|
24
|
-
end
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_hash
|
29
|
-
{
|
30
|
-
'json_schemas' => json_schemas,
|
31
|
-
'combinations' => combinations,
|
32
|
-
'flags' => flags
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Fitting
|
2
|
-
class Documentation
|
3
|
-
def initialize(tomogram, white_list)
|
4
|
-
@tomogram = tomogram
|
5
|
-
@white_list = white_list
|
6
|
-
end
|
7
|
-
|
8
|
-
def black
|
9
|
-
if @white_list
|
10
|
-
all.select do |response|
|
11
|
-
black?(response)
|
12
|
-
end
|
13
|
-
else
|
14
|
-
[]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def white
|
19
|
-
if @white_list
|
20
|
-
all.select do |response|
|
21
|
-
white?(response)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
all
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def all
|
29
|
-
@all ||= @tomogram.to_hash.each_with_object([]) do |request, routes|
|
30
|
-
responses(request).map do |status, indexes|
|
31
|
-
indexes.times do |index|
|
32
|
-
route = "#{request['method']}\t#{request['path']} #{status} #{index}"
|
33
|
-
routes.push(route)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end.uniq
|
37
|
-
end
|
38
|
-
|
39
|
-
def responses(request)
|
40
|
-
request['responses'].each_with_object({}) do |response, responses|
|
41
|
-
responses[response['status']] ||= 0
|
42
|
-
responses[response['status']] += 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def black?(response)
|
47
|
-
data = response.split(' ')
|
48
|
-
data[1] && !@white_list[data[1]] || (@white_list[data[1]] != [] && !@white_list[data[1]].include?(data[0]))
|
49
|
-
end
|
50
|
-
|
51
|
-
def white?(response)
|
52
|
-
data = response.split(' ')
|
53
|
-
data[1] && @white_list[data[1]] && (@white_list[data[1]] == [] || @white_list[data[1]].include?(data[0]))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|