fitting 3.0.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -0
- data/README.md +272 -109
- data/fitting.gemspec +2 -2
- data/images/b1.png +0 -0
- data/images/b2.png +0 -0
- data/images/w1.png +0 -0
- data/images/w2.png +0 -0
- data/lib/fitting/action.rb +105 -0
- data/lib/fitting/cover/json_schema.rb +2 -2
- data/lib/fitting/cover/json_schema_one_of.rb +4 -2
- data/lib/fitting/debug.rb +47 -0
- data/lib/fitting/doc/action.rb +141 -0
- data/lib/fitting/doc/code.rb +53 -0
- data/lib/fitting/doc/combination_enum.rb +110 -0
- data/lib/fitting/doc/combination_one_of.rb +61 -0
- data/lib/fitting/doc/combination_optional.rb +54 -0
- data/lib/fitting/doc/combination_step.rb +48 -0
- data/lib/fitting/doc/content_type.rb +152 -0
- data/lib/fitting/doc/json_schema.rb +116 -0
- data/lib/fitting/doc/step.rb +102 -0
- data/lib/fitting/doc.rb +107 -0
- data/lib/fitting/host.rb +37 -0
- data/lib/fitting/log.rb +102 -0
- data/lib/fitting/nocov.rb +64 -0
- data/lib/fitting/prefix.rb +62 -0
- data/lib/fitting/railtie.rb +0 -1
- data/lib/fitting/records/spherical/request.rb +7 -4
- data/lib/fitting/records/spherical/response.rb +22 -16
- data/lib/fitting/records/tested/request.rb +6 -1
- data/lib/fitting/records/tested/response.rb +6 -1
- data/lib/fitting/rep/html.rb +32 -0
- data/lib/fitting/rep.rb +24 -0
- data/lib/fitting/report/action.rb +9 -15
- data/lib/fitting/report/actions.rb +22 -33
- data/lib/fitting/report/combination.rb +10 -6
- data/lib/fitting/report/combinations.rb +9 -29
- data/lib/fitting/report/prefix.rb +7 -24
- data/lib/fitting/report/prefixes.rb +11 -25
- data/lib/fitting/report/response.rb +12 -22
- data/lib/fitting/report/responses.rb +23 -27
- data/lib/fitting/report/tests.rb +4 -8
- data/lib/fitting/skip/action.rb +44 -0
- data/lib/fitting/skip/api.rb +29 -0
- data/lib/fitting/skip.rb +21 -0
- data/lib/fitting/version.rb +1 -1
- data/lib/fitting.rb +12 -28
- data/lib/tasks/fitting.rake +23 -84
- data/lib/templates/htmlcss/bootstrap-nightshade.min.css +12 -0
- data/lib/templates/htmlcss/bootstrap.min.js +7 -0
- data/lib/templates/htmlcss/darkmode.min.js +6 -0
- data/lib/templates/htmlcss/fitting.html +196 -0
- data/lib/templates/htmlcss/jquery-3.6.0.min.js +2 -0
- metadata +40 -39
- data/lib/fitting/configuration.rb +0 -17
- data/lib/fitting/records/spherical/requests.rb +0 -25
- data/lib/fitting/storage/responses.rb +0 -21
- data/lib/fitting/tests.rb +0 -31
- data/lib/tasks/fitting_outgoing.rake +0 -91
- data/lib/templates/bomboniere/.gitignore +0 -21
- data/lib/templates/bomboniere/.tool-versions +0 -1
- data/lib/templates/bomboniere/README.md +0 -19
- data/lib/templates/bomboniere/dist/css/app.aa2bcd8a.css +0 -1
- data/lib/templates/bomboniere/dist/css/chunk-vendors.ec5f6c3f.css +0 -1
- data/lib/templates/bomboniere/dist/favicon.ico +0 -0
- data/lib/templates/bomboniere/dist/index.html +0 -1
- data/lib/templates/bomboniere/dist/js/app.e5f1a5ec.js +0 -2
- data/lib/templates/bomboniere/dist/js/app.e5f1a5ec.js.map +0 -1
- data/lib/templates/bomboniere/dist/js/chunk-vendors.0f99b670.js +0 -13
- data/lib/templates/bomboniere/dist/js/chunk-vendors.0f99b670.js.map +0 -1
- data/lib/templates/bomboniere/package-lock.json +0 -9292
- data/lib/templates/bomboniere/package.json +0 -27
- data/lib/templates/bomboniere/public/favicon.ico +0 -0
- data/lib/templates/bomboniere/public/index.html +0 -17
- data/lib/templates/bomboniere/src/App.vue +0 -102
- data/lib/templates/bomboniere/src/assets/logo.png +0 -0
- data/lib/templates/bomboniere/src/components/HelloWorld.vue +0 -204
- data/lib/templates/bomboniere/src/main.js +0 -10
- data/lib/templates/bomboniere/src/router/index.js +0 -31
- data/lib/templates/bomboniere/src/views/About.vue +0 -5
- data/lib/templates/bomboniere/src/views/Action.vue +0 -173
- data/lib/templates/bomboniere/src/views/Home.vue +0 -17
- data/lib/templates/bomboniere/vue.config.js +0 -3
data/lib/fitting.rb
CHANGED
@@ -1,35 +1,16 @@
|
|
1
1
|
require 'json-schema'
|
2
2
|
require 'fitting/version'
|
3
|
-
require 'fitting/configuration'
|
4
|
-
require 'fitting/storage/responses'
|
5
|
-
require 'fitting/tests'
|
6
3
|
require 'fitting/cover/json_schema_enum'
|
7
4
|
require 'fitting/cover/json_schema_one_of'
|
8
5
|
require 'fitting/records/documented/request'
|
9
6
|
require 'fitting/railtie' if defined?(Rails)
|
7
|
+
require 'fitting/records/tested/request'
|
10
8
|
|
11
9
|
module Fitting
|
12
10
|
class << self
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def configure
|
19
|
-
yield(configuration)
|
20
|
-
end
|
21
|
-
|
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
|
26
|
-
|
27
|
-
def save_test_data
|
28
|
-
clear_tests_directory
|
29
|
-
|
30
|
-
outgoing_responses = Fitting::Storage::Responses.new
|
31
|
-
responses = Fitting::Storage::Responses.new
|
32
|
-
|
11
|
+
def logger
|
12
|
+
# :nocov:
|
13
|
+
responses = ""
|
33
14
|
RSpec.configure do |config|
|
34
15
|
if defined?(WebMock)
|
35
16
|
config.before(:each) do |example|
|
@@ -41,17 +22,20 @@ module Fitting
|
|
41
22
|
response.body || {})
|
42
23
|
mock_response.instance_variable_set(:@request, mock_request)
|
43
24
|
|
44
|
-
|
25
|
+
request = Fitting::Records::Tested::Request.new(mock_response, example)
|
26
|
+
responses += "FITTING outgoing request #{request.to_spherical.to_json}\n"
|
45
27
|
end
|
46
28
|
end
|
47
29
|
end
|
48
30
|
|
49
31
|
config.after(:each, type: :request) do |example|
|
50
|
-
|
32
|
+
request = Fitting::Records::Tested::Request.new(response, example)
|
33
|
+
responses += "FITTING incoming request #{request.to_spherical.to_json}\n"
|
51
34
|
end
|
52
35
|
|
53
36
|
config.after(:each, type: :controller) do |example|
|
54
|
-
|
37
|
+
request = Fitting::Records::Tested::Request.new(response, example)
|
38
|
+
responses += "FITTING incoming request #{request.to_spherical.to_json}\n"
|
55
39
|
end
|
56
40
|
|
57
41
|
config.after(:each) do
|
@@ -59,10 +43,10 @@ module Fitting
|
|
59
43
|
end
|
60
44
|
|
61
45
|
config.after(:suite) do
|
62
|
-
|
63
|
-
outgoing_responses.tests.outgoing_save
|
46
|
+
File.open("log/fitting#{ENV['TEST_ENV_NUMBER']}.log", 'w') { |file| file.write(responses) }
|
64
47
|
end
|
65
48
|
end
|
49
|
+
# :nocov:
|
66
50
|
end
|
67
51
|
end
|
68
52
|
end
|
data/lib/tasks/fitting.rake
CHANGED
@@ -1,91 +1,30 @@
|
|
1
|
-
require 'fitting/
|
2
|
-
require 'fitting/
|
3
|
-
require 'fitting/
|
4
|
-
require 'fitting/
|
5
|
-
require 'fitting/
|
1
|
+
require 'fitting/log'
|
2
|
+
require 'fitting/doc'
|
3
|
+
require 'fitting/skip'
|
4
|
+
require 'fitting/nocov'
|
5
|
+
require 'fitting/rep'
|
6
|
+
require 'fitting/debug'
|
6
7
|
|
7
8
|
namespace :fitting do
|
8
|
-
task :
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
task :validate do
|
10
|
+
logs = Fitting::Log.all
|
11
|
+
docs = Fitting::Doc.all
|
12
|
+
skips = Fitting::Skip.all
|
13
|
+
|
14
|
+
logs.each do |log|
|
15
|
+
Fitting::Doc.cover!(docs, log)
|
16
|
+
log.access!
|
17
|
+
rescue Fitting::Doc::NotFound => e
|
18
|
+
next log.pending! if Fitting::Skip.find(skips, log)
|
19
|
+
log.failure!(e)
|
16
20
|
end
|
21
|
+
Fitting::Log.report(logs)
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
prefix.actions.to_a.map do |action|
|
22
|
-
action.responses.join(action.tests)
|
23
|
-
end
|
23
|
+
Fitting::NoCov.all(YAML.safe_load(File.read('.fitting.yml'))).each do |nocov|
|
24
|
+
nocov.find(docs).nocover!
|
24
25
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
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.merge!(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
|
26
|
+
Fitting::Rep.new(docs).save!
|
27
|
+
Fitting::Debug.save!(docs, YAML.safe_load(File.read('.fitting.yml')))
|
28
|
+
Fitting::Doc.report(docs)
|
90
29
|
end
|
91
30
|
end
|