fakeit 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.gitignore +0 -2
- data/.rubocop.yml +8 -1
- data/Gemfile.lock +40 -40
- data/README.md +1 -1
- data/fakeit.gemspec +5 -5
- data/lib/fakeit/app/app_builder.rb +15 -11
- data/lib/fakeit/app/options.rb +16 -2
- data/lib/fakeit/app/routes/openapi_route.rb +1 -2
- data/lib/fakeit/middleware/recorder.rb +1 -1
- data/lib/fakeit/openapi/example/array_example.rb +1 -1
- data/lib/fakeit/openapi/example/integer_example.rb +2 -2
- data/lib/fakeit/openapi/example/number_example.rb +1 -1
- data/lib/fakeit/openapi/example/string_example.rb +5 -3
- data/lib/fakeit/openapi/loader.rb +1 -1
- data/lib/fakeit/version.rb +1 -1
- metadata +12 -27
- data/lib/fakeit/core_extensions/reference.rb +0 -9
- data/lib/fakeit/openapi/reference_error.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea17f6b5e42fc32d82440e4198d5402d2ba51b02dc36182d50db13d33fea840
|
4
|
+
data.tar.gz: '09f5e2290f08d07a71b539b80cff919a37d0be2a8567b315a280c8c6699e07f7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c139f4c1654a3e4261b31c7cbed720819e3f9aaa74c54042bb297d4e587412811542c7d8fb35d294a66b0bf27bb0ce0328835ed5b47d61a9c02abc45b7708d4a
|
7
|
+
data.tar.gz: cbf4746fbcbfe72714f50af0afcc242f49b6de65056cb7d1edf5058de3a8ed488d9e20314475ae5aefbfc8a4cb132f6d561b52c4a12424700775354d9e15b06b
|
data/.circleci/config.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 3.
|
2
|
+
TargetRubyVersion: 3.1
|
3
3
|
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
4
5
|
|
5
6
|
Style/Documentation:
|
6
7
|
Enabled: false
|
@@ -21,3 +22,9 @@ Security/Open:
|
|
21
22
|
|
22
23
|
Style/HashTransformKeys:
|
23
24
|
Enabled: false
|
25
|
+
|
26
|
+
Metrics/ParameterLists:
|
27
|
+
CountKeywordArgs: false
|
28
|
+
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Max: 20
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fakeit (0.
|
5
|
-
faker (= 2.
|
6
|
-
openapi_parser (= 0.
|
4
|
+
fakeit (0.11.0)
|
5
|
+
faker (= 2.22.0)
|
6
|
+
openapi_parser (= 1.0.0)
|
7
7
|
rack (~> 2.0)
|
8
8
|
rack-cors (~> 1.0)
|
9
9
|
rainbow (~> 3.0)
|
@@ -15,52 +15,53 @@ GEM
|
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
17
|
ast (2.4.2)
|
18
|
-
|
19
|
-
|
20
|
-
diff-lcs (1.4.4)
|
18
|
+
concurrent-ruby (1.1.10)
|
19
|
+
diff-lcs (1.5.0)
|
21
20
|
docile (1.4.0)
|
22
|
-
faker (2.
|
23
|
-
i18n (>= 1.
|
24
|
-
i18n (1.
|
21
|
+
faker (2.22.0)
|
22
|
+
i18n (>= 1.8.11, < 2)
|
23
|
+
i18n (1.12.0)
|
25
24
|
concurrent-ruby (~> 1.0)
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
json (2.6.2)
|
26
|
+
openapi_parser (1.0.0)
|
27
|
+
parallel (1.22.1)
|
28
|
+
parser (3.1.2.1)
|
29
29
|
ast (~> 2.4.1)
|
30
|
-
rack (2.2.
|
30
|
+
rack (2.2.4)
|
31
31
|
rack-cors (1.1.1)
|
32
32
|
rack (>= 2.0.0)
|
33
|
-
rack-test (
|
34
|
-
rack (>= 1.
|
35
|
-
rainbow (3.
|
33
|
+
rack-test (2.0.2)
|
34
|
+
rack (>= 1.3)
|
35
|
+
rainbow (3.1.1)
|
36
36
|
rake (13.0.6)
|
37
37
|
regexp-examples (1.5.1)
|
38
|
-
regexp_parser (2.
|
38
|
+
regexp_parser (2.6.0)
|
39
39
|
rexml (3.2.5)
|
40
|
-
rspec (3.
|
41
|
-
rspec-core (~> 3.
|
42
|
-
rspec-expectations (~> 3.
|
43
|
-
rspec-mocks (~> 3.
|
44
|
-
rspec-core (3.
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-expectations (3.
|
40
|
+
rspec (3.11.0)
|
41
|
+
rspec-core (~> 3.11.0)
|
42
|
+
rspec-expectations (~> 3.11.0)
|
43
|
+
rspec-mocks (~> 3.11.0)
|
44
|
+
rspec-core (3.11.0)
|
45
|
+
rspec-support (~> 3.11.0)
|
46
|
+
rspec-expectations (3.11.1)
|
47
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-mocks (3.
|
48
|
+
rspec-support (~> 3.11.0)
|
49
|
+
rspec-mocks (3.11.1)
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-support (3.
|
53
|
-
rubocop (1.
|
51
|
+
rspec-support (~> 3.11.0)
|
52
|
+
rspec-support (3.11.1)
|
53
|
+
rubocop (1.36.0)
|
54
|
+
json (~> 2.3)
|
54
55
|
parallel (~> 1.10)
|
55
|
-
parser (>= 3.
|
56
|
+
parser (>= 3.1.2.1)
|
56
57
|
rainbow (>= 2.2.2, < 4.0)
|
57
58
|
regexp_parser (>= 1.8, < 3.0)
|
58
|
-
rexml
|
59
|
-
rubocop-ast (>= 1.
|
59
|
+
rexml (>= 3.2.5, < 4.0)
|
60
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
60
61
|
ruby-progressbar (~> 1.7)
|
61
62
|
unicode-display_width (>= 1.4.0, < 3.0)
|
62
|
-
rubocop-ast (1.
|
63
|
-
parser (>= 3.
|
63
|
+
rubocop-ast (1.21.0)
|
64
|
+
parser (>= 3.1.1.0)
|
64
65
|
rubocop-rake (0.6.0)
|
65
66
|
rubocop (~> 1.0)
|
66
67
|
ruby-progressbar (1.11.0)
|
@@ -69,9 +70,9 @@ GEM
|
|
69
70
|
simplecov-html (~> 0.11)
|
70
71
|
simplecov_json_formatter (~> 0.1)
|
71
72
|
simplecov-html (0.12.3)
|
72
|
-
simplecov_json_formatter (0.1.
|
73
|
-
slop (4.9.
|
74
|
-
unicode-display_width (2.
|
73
|
+
simplecov_json_formatter (0.1.4)
|
74
|
+
slop (4.9.3)
|
75
|
+
unicode-display_width (2.3.0)
|
75
76
|
webrick (1.7.0)
|
76
77
|
|
77
78
|
PLATFORMS
|
@@ -79,9 +80,8 @@ PLATFORMS
|
|
79
80
|
|
80
81
|
DEPENDENCIES
|
81
82
|
bundler (~> 2.0)
|
82
|
-
byebug (~> 11.0)
|
83
83
|
fakeit!
|
84
|
-
rack-test (~>
|
84
|
+
rack-test (~> 2.0)
|
85
85
|
rake (~> 13.0)
|
86
86
|
rspec (~> 3.0)
|
87
87
|
rubocop (~> 1.10)
|
@@ -89,4 +89,4 @@ DEPENDENCIES
|
|
89
89
|
simplecov (~> 0.18)
|
90
90
|
|
91
91
|
BUNDLED WITH
|
92
|
-
2.
|
92
|
+
2.3.7
|
data/README.md
CHANGED
data/fakeit.gemspec
CHANGED
@@ -22,23 +22,23 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = 'fakeit'
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.required_ruby_version = '>= 3.
|
25
|
+
spec.required_ruby_version = '>= 3.1.2'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency 'rack-test', '~> 1.1'
|
28
|
+
spec.add_development_dependency 'rack-test', '~> 2.0'
|
30
29
|
spec.add_development_dependency 'rake', '~> 13.0'
|
31
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
31
|
spec.add_development_dependency 'rubocop', '~> 1.10'
|
33
32
|
spec.add_development_dependency 'rubocop-rake', '~> 0.5'
|
34
33
|
spec.add_development_dependency 'simplecov', '~> 0.18'
|
35
34
|
|
36
|
-
spec.add_dependency 'faker', '2.
|
37
|
-
spec.add_dependency 'openapi_parser', '0.
|
35
|
+
spec.add_dependency 'faker', '2.22.0'
|
36
|
+
spec.add_dependency 'openapi_parser', '1.0.0'
|
38
37
|
spec.add_dependency 'rack', '~> 2.0'
|
39
38
|
spec.add_dependency 'rack-cors', '~> 1.0'
|
40
39
|
spec.add_dependency 'rainbow', '~> 3.0'
|
41
40
|
spec.add_dependency 'regexp-examples', '1.5.1'
|
42
41
|
spec.add_dependency 'slop', '~> 4.8'
|
43
42
|
spec.add_dependency 'webrick', '~> 1.7'
|
43
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
44
44
|
end
|
@@ -2,7 +2,6 @@ module Fakeit
|
|
2
2
|
module App
|
3
3
|
class AppBuilder
|
4
4
|
def initialize(spec_file, options)
|
5
|
-
@options = options
|
6
5
|
@config_route = Routes::ConfigRoute.new(options)
|
7
6
|
@openapi_route = Routes::OpenapiRoute.new(spec_file)
|
8
7
|
end
|
@@ -10,25 +9,30 @@ module Fakeit
|
|
10
9
|
def build
|
11
10
|
proc do |env|
|
12
11
|
request = Rack::Request.new(env)
|
12
|
+
base_path = @config_route.options.base_path
|
13
|
+
path_info = request.path_info
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
if path_info == '/__fakeit_config__'
|
16
|
+
config(request)
|
17
|
+
elsif path_info.start_with?(base_path)
|
18
|
+
openapi(request, path_info[(base_path.length - 1)..])
|
19
|
+
elsif "#{path_info}/" == base_path
|
20
|
+
openapi(request, '/')
|
17
21
|
else
|
18
|
-
|
19
|
-
@openapi_route.call(request, @config_route.options)
|
22
|
+
Fakeit::App::Helpers::ResponseBuilder.not_found
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
27
|
private
|
25
28
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
return path unless path.start_with?(@options.base_path)
|
29
|
+
def config(request)
|
30
|
+
@config_route.call(request)
|
31
|
+
end
|
30
32
|
|
31
|
-
|
33
|
+
def openapi(request, path_info)
|
34
|
+
request.path_info = path_info
|
35
|
+
@openapi_route.call(request, @config_route.options)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
data/lib/fakeit/app/options.rb
CHANGED
@@ -3,7 +3,14 @@ module Fakeit
|
|
3
3
|
class Options
|
4
4
|
attr_reader :permissive, :use_example, :base_path
|
5
5
|
|
6
|
-
def initialize(
|
6
|
+
def initialize(
|
7
|
+
permissive: false,
|
8
|
+
use_example: false,
|
9
|
+
static: false,
|
10
|
+
static_types: [],
|
11
|
+
static_properties: [],
|
12
|
+
base_path: nil
|
13
|
+
)
|
7
14
|
@permissive = permissive
|
8
15
|
@use_example = use_example
|
9
16
|
@static = static
|
@@ -11,7 +18,14 @@ module Fakeit
|
|
11
18
|
@static_properties = static_properties
|
12
19
|
# Standardize the base path to include trailing slash
|
13
20
|
# so that `/base` matches `/base/path` but doesn't match `/basement/path`
|
14
|
-
@base_path =
|
21
|
+
@base_path =
|
22
|
+
if base_path.nil?
|
23
|
+
'/'
|
24
|
+
elsif base_path[-1] == '/'
|
25
|
+
base_path
|
26
|
+
else
|
27
|
+
"#{base_path}/"
|
28
|
+
end
|
15
29
|
end
|
16
30
|
|
17
31
|
def use_static?(type: nil, property: nil)
|
@@ -34,8 +34,7 @@ module Fakeit
|
|
34
34
|
request
|
35
35
|
.each_header
|
36
36
|
.select { |k, _| k.start_with? 'HTTP_' }
|
37
|
-
.
|
38
|
-
.to_h
|
37
|
+
.to_h { |k, v| [k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-'), v] }
|
39
38
|
end
|
40
39
|
|
41
40
|
def parse_query(query_string)
|
@@ -15,7 +15,7 @@ module Fakeit
|
|
15
15
|
def log_request(env)
|
16
16
|
env['rack.input']
|
17
17
|
&.tap { |body| Logger.info("Request body: #{body.read}") }
|
18
|
-
&.tap
|
18
|
+
&.tap(&:rewind)
|
19
19
|
end
|
20
20
|
|
21
21
|
def log_response(response) = Logger.info("Response body: #{response[2].first}")
|
@@ -29,7 +29,7 @@ module Fakeit
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def int_rand_begin = min_int / int_multiple + int_rand_begin_adjust
|
32
|
+
def int_rand_begin = (min_int / int_multiple) + int_rand_begin_adjust
|
33
33
|
|
34
34
|
def int_rand_end = max_int / int_multiple
|
35
35
|
|
@@ -49,7 +49,7 @@ module Fakeit
|
|
49
49
|
if maximum
|
50
50
|
exclusiveMaximum ? maximum - 1 : maximum
|
51
51
|
else
|
52
|
-
2**(int_bits - 1) - 1
|
52
|
+
(2**(int_bits - 1)) - 1
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -44,7 +44,8 @@ module Fakeit
|
|
44
44
|
elsif pattern then static_string_pattern
|
45
45
|
elsif format then static_string_format
|
46
46
|
elsif length_constraint then static_string_with_length
|
47
|
-
else
|
47
|
+
else
|
48
|
+
'string'
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -61,7 +62,8 @@ module Fakeit
|
|
61
62
|
elsif pattern then random_string_pattern
|
62
63
|
elsif format then random_string_format
|
63
64
|
elsif length_constraint then string_with_length
|
64
|
-
else
|
65
|
+
else
|
66
|
+
Faker::Book.title
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -81,7 +83,7 @@ module Fakeit
|
|
81
83
|
|
82
84
|
def min_string_length = minLength || 0
|
83
85
|
|
84
|
-
def max_string_length = maxLength || min_string_length + 10
|
86
|
+
def max_string_length = maxLength || (min_string_length + 10)
|
85
87
|
|
86
88
|
def random_string_format = (RANDOM_FORMAT_HANDLERS[format] || method(:unknown_format))[]
|
87
89
|
|
data/lib/fakeit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakeit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Feng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,34 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: byebug
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '11.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '11.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rack-test
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '2.0'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '2.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +114,28 @@ dependencies:
|
|
128
114
|
requirements:
|
129
115
|
- - '='
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.
|
117
|
+
version: 2.22.0
|
132
118
|
type: :runtime
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - '='
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.
|
124
|
+
version: 2.22.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: openapi_parser
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - '='
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
131
|
+
version: 1.0.0
|
146
132
|
type: :runtime
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - '='
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
138
|
+
version: 1.0.0
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: rack
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,7 +250,6 @@ files:
|
|
264
250
|
- lib/fakeit/app/routes/config_route.rb
|
265
251
|
- lib/fakeit/app/routes/openapi_route.rb
|
266
252
|
- lib/fakeit/core_extensions/array_validator.rb
|
267
|
-
- lib/fakeit/core_extensions/reference.rb
|
268
253
|
- lib/fakeit/core_extensions/schema.rb
|
269
254
|
- lib/fakeit/logger.rb
|
270
255
|
- lib/fakeit/middleware/recorder.rb
|
@@ -276,7 +261,6 @@ files:
|
|
276
261
|
- lib/fakeit/openapi/example/string_example.rb
|
277
262
|
- lib/fakeit/openapi/loader.rb
|
278
263
|
- lib/fakeit/openapi/operation.rb
|
279
|
-
- lib/fakeit/openapi/reference_error.rb
|
280
264
|
- lib/fakeit/openapi/schema.rb
|
281
265
|
- lib/fakeit/openapi/specification.rb
|
282
266
|
- lib/fakeit/validation/validation_error.rb
|
@@ -285,7 +269,8 @@ files:
|
|
285
269
|
homepage: https://github.com/JustinFeng/fakeit
|
286
270
|
licenses:
|
287
271
|
- MIT
|
288
|
-
metadata:
|
272
|
+
metadata:
|
273
|
+
rubygems_mfa_required: 'true'
|
289
274
|
post_install_message:
|
290
275
|
rdoc_options: []
|
291
276
|
require_paths:
|
@@ -294,14 +279,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
279
|
requirements:
|
295
280
|
- - ">="
|
296
281
|
- !ruby/object:Gem::Version
|
297
|
-
version: 3.
|
282
|
+
version: 3.1.2
|
298
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
284
|
requirements:
|
300
285
|
- - ">="
|
301
286
|
- !ruby/object:Gem::Version
|
302
287
|
version: '0'
|
303
288
|
requirements: []
|
304
|
-
rubygems_version: 3.
|
289
|
+
rubygems_version: 3.3.7
|
305
290
|
signing_key:
|
306
291
|
specification_version: 4
|
307
292
|
summary: Create mock server from Openapi specification
|