fakeit 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ea17f6b5e42fc32d82440e4198d5402d2ba51b02dc36182d50db13d33fea840
4
- data.tar.gz: '09f5e2290f08d07a71b539b80cff919a37d0be2a8567b315a280c8c6699e07f7'
3
+ metadata.gz: 387b057ba9e0387d7b3cf46715b966049d3adcc19bbd95fe22778c92cedf19f8
4
+ data.tar.gz: 16ba2939faacc64769123f2819b19bf25444fcbfcbe7f9a492809b6b473169e4
5
5
  SHA512:
6
- metadata.gz: c139f4c1654a3e4261b31c7cbed720819e3f9aaa74c54042bb297d4e587412811542c7d8fb35d294a66b0bf27bb0ce0328835ed5b47d61a9c02abc45b7708d4a
7
- data.tar.gz: cbf4746fbcbfe72714f50af0afcc242f49b6de65056cb7d1edf5058de3a8ed488d9e20314475ae5aefbfc8a4cb132f6d561b52c4a12424700775354d9e15b06b
6
+ metadata.gz: 94d467b095d75eb421fa4b0b864a304061257b6abd974b732536b65efabd529d0a46279a49587528856cf9711556864ccd9fbe88af9b2be22c3052d07dffd869
7
+ data.tar.gz: 7b957a4784e93ff5aa77adb3ca44ade65e36c183cc6a513ddd9d9b943ea671220d011573200f5e1b27475f15783f31ec14f327710574ffaa1b9092a77331086f
data/.rubocop.yml CHANGED
@@ -1,21 +1,39 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.1
2
+ TargetRubyVersion: 3.4
3
3
  NewCops: enable
4
4
  SuggestExtensions: false
5
5
 
6
+ Style/Alias:
7
+ EnforcedStyle: prefer_alias_method
8
+
6
9
  Style/Documentation:
7
10
  Enabled: false
8
11
 
9
12
  Style/FrozenStringLiteralComment:
10
13
  Enabled: false
11
14
 
15
+ Style/RescueStandardError:
16
+ EnforcedStyle: implicit
17
+
18
+ Style/SafeNavigationChainLength:
19
+ Enabled: false
20
+
21
+ Style/StringLiterals:
22
+ Enabled: false
23
+
24
+ Style/TernaryParentheses:
25
+ Enabled: false
26
+
12
27
  Layout/LineLength:
13
28
  Max: 120
14
29
 
30
+ Layout/SpaceInsideHashLiteralBraces:
31
+ EnforcedStyle: no_space
32
+
15
33
  Metrics/BlockLength:
16
34
  Exclude:
17
- - 'spec/**/*.rb'
18
- - 'fakeit.gemspec'
35
+ - "spec/**/*.rb"
36
+ - "fakeit.gemspec"
19
37
 
20
38
  Security/Open:
21
39
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.12.0](https://github.com/JustinFeng/fakeit/tree/v0.12.0) (2025-05-13)
4
+
5
+ [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.11.0...v0.12.0)
6
+
7
+ ## [v0.11.0](https://github.com/JustinFeng/fakeit/tree/v0.11.0) (2022-10-09)
8
+
9
+ [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.10.0...v0.11.0)
10
+
11
+ ## [v0.10.0](https://github.com/JustinFeng/fakeit/tree/v0.10.0) (2021-11-21)
12
+
13
+ [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.9.2...v0.10.0)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - Allows specification of a base path for the mock API [\#26](https://github.com/JustinFeng/fakeit/pull/26) ([jphastings](https://github.com/jphastings))
18
+
3
19
  ## [v0.9.2](https://github.com/JustinFeng/fakeit/tree/v0.9.2) (2021-08-14)
4
20
 
5
21
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.9.1...v0.9.2)
@@ -16,7 +32,7 @@
16
32
 
17
33
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.9.0...v0.9.1)
18
34
 
19
- **Fixed bugs:**
35
+ **Closed issues:**
20
36
 
21
37
  - Query parameter array [\#23](https://github.com/JustinFeng/fakeit/issues/23)
22
38
 
@@ -24,9 +40,9 @@
24
40
 
25
41
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.8.1...v0.9.0)
26
42
 
27
- **Implemented enhancements:**
43
+ **Closed issues:**
28
44
 
29
- - Experimental feature to support plain text and binary response, e.g. application/pdf
45
+ - camelCase instead of PascalCase [\#22](https://github.com/JustinFeng/fakeit/issues/22)
30
46
 
31
47
  ## [v0.8.1](https://github.com/JustinFeng/fakeit/tree/v0.8.1) (2021-03-01)
32
48
 
@@ -40,10 +56,6 @@
40
56
 
41
57
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.7.1...v0.8.0)
42
58
 
43
- **Implemented enhancements:**
44
-
45
- - Upgraded to ruby 3.0.0
46
-
47
59
  ## [v0.7.1](https://github.com/JustinFeng/fakeit/tree/v0.7.1) (2021-02-07)
48
60
 
49
61
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.7.0...v0.7.1)
@@ -58,17 +70,12 @@
58
70
 
59
71
  **Implemented enhancements:**
60
72
 
61
- - Supported change mock server behaviour on the fly
62
- - Allowed to redirect console log to a file
73
+ - Enhancement: Allow for POSTed data to be persisted while running [\#19](https://github.com/JustinFeng/fakeit/issues/19)
63
74
 
64
75
  ## [v0.6.3](https://github.com/JustinFeng/fakeit/tree/v0.6.3) (2020-09-11)
65
76
 
66
77
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.6.2...v0.6.3)
67
78
 
68
- **Implemented enhancements:**
69
-
70
- - Enhanced regex example generation
71
-
72
79
  ## [v0.6.2](https://github.com/JustinFeng/fakeit/tree/v0.6.2) (2020-07-12)
73
80
 
74
81
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.6.1...v0.6.2)
@@ -81,10 +88,6 @@
81
88
 
82
89
  [Full Changelog](https://github.com/JustinFeng/fakeit/compare/v0.5.3...v0.6.0)
83
90
 
84
- **Implemented enhancements:**
85
-
86
- - Added support for multipart/form-data validation
87
-
88
91
  **Fixed bugs:**
89
92
 
90
93
  - Multipart request contain special character will respond 500 [\#16](https://github.com/JustinFeng/fakeit/issues/16)
data/Gemfile CHANGED
@@ -1,4 +1,15 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in fakeit.gemspec
4
4
  gemspec
5
+ group :development do
6
+ gem "bundler", "~> 2.6"
7
+ gem "debug", "~> 1.10"
8
+ gem "racc", "~> 1.8"
9
+ gem "rack-test", "~> 2.2"
10
+ gem "rake", "~> 13.2"
11
+ gem "rspec", "~> 3.13"
12
+ gem "rubocop", "~> 1.75"
13
+ gem "rubocop-rake", "~> 0.7"
14
+ gem "simplecov", "~> 0.22"
15
+ end
data/Gemfile.lock CHANGED
@@ -1,92 +1,134 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fakeit (0.11.0)
5
- faker (= 2.22.0)
6
- openapi_parser (= 1.0.0)
7
- rack (~> 2.0)
8
- rack-cors (~> 1.0)
9
- rainbow (~> 3.0)
10
- regexp-examples (= 1.5.1)
11
- slop (~> 4.8)
12
- webrick (~> 1.7)
4
+ fakeit (0.12.0)
5
+ base64 (~> 0.2.0)
6
+ faker (= 3.5.1)
7
+ logger (= 1.7)
8
+ openapi_parser (= 2.2.6)
9
+ ostruct (~> 0.6)
10
+ rack (~> 3.1)
11
+ rack-cors (~> 2.0)
12
+ rackup (~> 2.2)
13
+ rainbow (~> 3.1)
14
+ regexp-examples (= 1.6.0)
15
+ slop (~> 4.10)
16
+ webrick (~> 1.9)
13
17
 
14
18
  GEM
15
19
  remote: https://rubygems.org/
16
20
  specs:
17
21
  ast (2.4.2)
22
+ base64 (0.2.0)
18
23
  concurrent-ruby (1.1.10)
24
+ date (3.4.1)
25
+ debug (1.10.0)
26
+ irb (~> 1.10)
27
+ reline (>= 0.3.8)
19
28
  diff-lcs (1.5.0)
20
29
  docile (1.4.0)
21
- faker (2.22.0)
30
+ faker (3.5.1)
22
31
  i18n (>= 1.8.11, < 2)
23
32
  i18n (1.12.0)
24
33
  concurrent-ruby (~> 1.0)
34
+ io-console (0.5.11)
35
+ irb (1.15.2)
36
+ pp (>= 0.6.0)
37
+ rdoc (>= 4.0.0)
38
+ reline (>= 0.4.2)
25
39
  json (2.6.2)
26
- openapi_parser (1.0.0)
40
+ language_server-protocol (3.17.0.5)
41
+ lint_roller (1.1.0)
42
+ logger (1.7.0)
43
+ openapi_parser (2.2.6)
44
+ ostruct (0.6.1)
27
45
  parallel (1.22.1)
28
- parser (3.1.2.1)
46
+ parser (3.3.8.0)
29
47
  ast (~> 2.4.1)
30
- rack (2.2.4)
31
- rack-cors (1.1.1)
48
+ racc
49
+ pp (0.6.2)
50
+ prettyprint
51
+ prettyprint (0.2.0)
52
+ prism (1.4.0)
53
+ psych (5.2.6)
54
+ date
55
+ stringio
56
+ racc (1.8.1)
57
+ rack (3.1.14)
58
+ rack-cors (2.0.2)
32
59
  rack (>= 2.0.0)
33
- rack-test (2.0.2)
60
+ rack-test (2.2.0)
34
61
  rack (>= 1.3)
62
+ rackup (2.2.1)
63
+ rack (>= 3)
35
64
  rainbow (3.1.1)
36
- rake (13.0.6)
37
- regexp-examples (1.5.1)
38
- regexp_parser (2.6.0)
39
- rexml (3.2.5)
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)
65
+ rake (13.2.1)
66
+ rdoc (6.13.1)
67
+ psych (>= 4.0.0)
68
+ regexp-examples (1.6.0)
69
+ regexp_property_values (~> 1.5)
70
+ regexp_parser (2.10.0)
71
+ regexp_property_values (1.5.2)
72
+ reline (0.6.1)
73
+ io-console (~> 0.5)
74
+ rspec (3.13.0)
75
+ rspec-core (~> 3.13.0)
76
+ rspec-expectations (~> 3.13.0)
77
+ rspec-mocks (~> 3.13.0)
78
+ rspec-core (3.13.3)
79
+ rspec-support (~> 3.13.0)
80
+ rspec-expectations (3.13.4)
47
81
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.11.0)
49
- rspec-mocks (3.11.1)
82
+ rspec-support (~> 3.13.0)
83
+ rspec-mocks (3.13.4)
50
84
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.11.0)
52
- rspec-support (3.11.1)
53
- rubocop (1.36.0)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-support (3.13.3)
87
+ rubocop (1.75.5)
54
88
  json (~> 2.3)
89
+ language_server-protocol (~> 3.17.0.2)
90
+ lint_roller (~> 1.1.0)
55
91
  parallel (~> 1.10)
56
- parser (>= 3.1.2.1)
92
+ parser (>= 3.3.0.2)
57
93
  rainbow (>= 2.2.2, < 4.0)
58
- regexp_parser (>= 1.8, < 3.0)
59
- rexml (>= 3.2.5, < 4.0)
60
- rubocop-ast (>= 1.20.1, < 2.0)
94
+ regexp_parser (>= 2.9.3, < 3.0)
95
+ rubocop-ast (>= 1.44.0, < 2.0)
61
96
  ruby-progressbar (~> 1.7)
62
- unicode-display_width (>= 1.4.0, < 3.0)
63
- rubocop-ast (1.21.0)
64
- parser (>= 3.1.1.0)
65
- rubocop-rake (0.6.0)
66
- rubocop (~> 1.0)
97
+ unicode-display_width (>= 2.4.0, < 4.0)
98
+ rubocop-ast (1.44.1)
99
+ parser (>= 3.3.7.2)
100
+ prism (~> 1.4)
101
+ rubocop-rake (0.7.1)
102
+ lint_roller (~> 1.1)
103
+ rubocop (>= 1.72.1)
67
104
  ruby-progressbar (1.11.0)
68
- simplecov (0.21.2)
105
+ simplecov (0.22.0)
69
106
  docile (~> 1.1)
70
107
  simplecov-html (~> 0.11)
71
108
  simplecov_json_formatter (~> 0.1)
72
109
  simplecov-html (0.12.3)
73
110
  simplecov_json_formatter (0.1.4)
74
- slop (4.9.3)
75
- unicode-display_width (2.3.0)
76
- webrick (1.7.0)
111
+ slop (4.10.1)
112
+ stringio (3.1.7)
113
+ unicode-display_width (3.1.4)
114
+ unicode-emoji (~> 4.0, >= 4.0.4)
115
+ unicode-emoji (4.0.4)
116
+ webrick (1.9.1)
77
117
 
78
118
  PLATFORMS
79
119
  ruby
80
120
 
81
121
  DEPENDENCIES
82
- bundler (~> 2.0)
122
+ bundler (~> 2.6)
123
+ debug (~> 1.10)
83
124
  fakeit!
84
- rack-test (~> 2.0)
85
- rake (~> 13.0)
86
- rspec (~> 3.0)
87
- rubocop (~> 1.10)
88
- rubocop-rake (~> 0.5)
89
- simplecov (~> 0.18)
125
+ racc (~> 1.8)
126
+ rack-test (~> 2.2)
127
+ rake (~> 13.2)
128
+ rspec (~> 3.13)
129
+ rubocop (~> 1.75)
130
+ rubocop-rake (~> 0.7)
131
+ simplecov (~> 0.22)
90
132
 
91
133
  BUNDLED WITH
92
- 2.3.7
134
+ 2.6.8
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Fakeit
2
2
 
3
+ [Fukuoka Ruby Award - Special Award](https://www.digitalfukuoka.jp/event_reports/21?locale=ja)
4
+
3
5
  [![CircleCI](https://img.shields.io/circleci/build/github/JustinFeng/fakeit.svg)](https://circleci.com/gh/JustinFeng/fakeit)
4
6
  [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/JustinFeng/fakeit.svg)](https://codeclimate.com/github/JustinFeng/fakeit)
5
7
  [![Gem](https://img.shields.io/gem/v/fakeit.svg)](https://rubygems.org/gems/fakeit)
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rubocop/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
4
4
 
5
5
  task default: %i[spec rubocop]
6
6
 
data/bin/fakeit CHANGED
@@ -36,7 +36,7 @@ rescue Slop::Error => e
36
36
  exit
37
37
  end
38
38
 
39
- server = Rack::Handler::WEBrick
39
+ server = Rackup::Handler::WEBrick
40
40
 
41
41
  trap(:INT) do
42
42
  if server.respond_to?(:shutdown)
@@ -65,6 +65,7 @@ app.use Rack::Cors do
65
65
  resource '*', headers: :any, methods: :any
66
66
  end
67
67
  end
68
+ app.use(Rack::RewindableInput::Middleware)
68
69
  app.use(Fakeit::Middleware::Recorder) unless opts.quiet?
69
70
 
70
71
  server.run(app, Port: opts[:port], Host: '0.0.0.0')
data/fakeit.gemspec CHANGED
@@ -1,44 +1,40 @@
1
- lib = File.expand_path('lib', __dir__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'fakeit/version'
3
+ require "fakeit/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'fakeit'
7
- spec.version = Fakeit::VERSION
8
- spec.authors = ['Justin Feng']
9
- spec.email = ['realfengjia@foxmail.com']
6
+ spec.name = "fakeit"
7
+ spec.version = Fakeit::VERSION
8
+ spec.authors = ["Justin Feng"]
9
+ spec.email = ["realfengjia@foxmail.com"]
10
10
 
11
- spec.summary = 'Create mock server from Openapi specification'
12
- spec.description = 'Create mock server from Openapi specification'
13
- spec.homepage = 'https://github.com/JustinFeng/fakeit'
14
- spec.license = 'MIT'
11
+ spec.summary = "Create mock server from Openapi specification"
12
+ spec.description = "Create mock server from Openapi specification"
13
+ spec.homepage = "https://github.com/JustinFeng/fakeit"
14
+ spec.license = "MIT"
15
15
 
16
16
  # Specify which files should be added to the gem when it is released.
17
17
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
19
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
20
  end
21
- spec.bindir = 'bin'
22
- spec.executables = 'fakeit'
23
- spec.require_paths = ['lib']
21
+ spec.bindir = "bin"
22
+ spec.executables = "fakeit"
23
+ spec.require_paths = ["lib"]
24
24
 
25
- spec.required_ruby_version = '>= 3.1.2'
25
+ spec.required_ruby_version = ">= 3.4"
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 2.0'
28
- spec.add_development_dependency 'rack-test', '~> 2.0'
29
- spec.add_development_dependency 'rake', '~> 13.0'
30
- spec.add_development_dependency 'rspec', '~> 3.0'
31
- spec.add_development_dependency 'rubocop', '~> 1.10'
32
- spec.add_development_dependency 'rubocop-rake', '~> 0.5'
33
- spec.add_development_dependency 'simplecov', '~> 0.18'
34
-
35
- spec.add_dependency 'faker', '2.22.0'
36
- spec.add_dependency 'openapi_parser', '1.0.0'
37
- spec.add_dependency 'rack', '~> 2.0'
38
- spec.add_dependency 'rack-cors', '~> 1.0'
39
- spec.add_dependency 'rainbow', '~> 3.0'
40
- spec.add_dependency 'regexp-examples', '1.5.1'
41
- spec.add_dependency 'slop', '~> 4.8'
42
- spec.add_dependency 'webrick', '~> 1.7'
43
- spec.metadata['rubygems_mfa_required'] = 'true'
27
+ spec.add_dependency "base64", "~> 0.2.0"
28
+ spec.add_dependency "faker", "3.5.1"
29
+ spec.add_dependency "logger", "1.7"
30
+ spec.add_dependency "openapi_parser", "2.2.6"
31
+ spec.add_dependency "ostruct", "~> 0.6"
32
+ spec.add_dependency "rack", "~> 3.1"
33
+ spec.add_dependency "rack-cors", "~> 2.0"
34
+ spec.add_dependency "rackup", "~> 2.2"
35
+ spec.add_dependency "rainbow", "~> 3.1"
36
+ spec.add_dependency "regexp-examples", "1.6.0"
37
+ spec.add_dependency "slop", "~> 4.10"
38
+ spec.add_dependency "webrick", "~> 1.9"
39
+ spec.metadata["rubygems_mfa_required"] = "true"
44
40
  end
@@ -12,12 +12,12 @@ module Fakeit
12
12
  base_path = @config_route.options.base_path
13
13
  path_info = request.path_info
14
14
 
15
- if path_info == '/__fakeit_config__'
15
+ if path_info == "/__fakeit_config__"
16
16
  config(request)
17
17
  elsif path_info.start_with?(base_path)
18
18
  openapi(request, path_info[(base_path.length - 1)..])
19
19
  elsif "#{path_info}/" == base_path
20
- openapi(request, '/')
20
+ openapi(request, "/")
21
21
  else
22
22
  Fakeit::App::Helpers::ResponseBuilder.not_found
23
23
  end
@@ -6,11 +6,11 @@ module Fakeit
6
6
  def parse(request)
7
7
  case request.media_type
8
8
  when %r{^application/.*json}
9
- { media_type: request.media_type, data: parse_json(request.body.read) }
10
- when 'multipart/form-data'
11
- { media_type: request.media_type, data: parse_form_data(request.params) }
9
+ {media_type: request.media_type, data: parse_json(request.body.read)}
10
+ when "multipart/form-data"
11
+ {media_type: request.media_type, data: parse_form_data(request.params)}
12
12
  else
13
- { media_type: request.media_type, data: request.body.read }
13
+ {media_type: request.media_type, data: request.body&.read}
14
14
  end
15
15
  end
16
16
 
@@ -18,12 +18,12 @@ module Fakeit
18
18
 
19
19
  def parse_json(body)
20
20
  body.empty? ? {} : JSON.parse(body)
21
- rescue StandardError
22
- raise Fakeit::Validation::ValidationError, 'Invalid json payload'
21
+ rescue
22
+ raise Fakeit::Validation::ValidationError, "Invalid json payload"
23
23
  end
24
24
 
25
25
  def parse_form_data(params)
26
- params.transform_values { |v| v.instance_of?(Hash) && v[:tempfile] ? v[:tempfile].read : v }
26
+ params.transform_values { |v| (v.instance_of?(Hash) && v[:tempfile]) ? v[:tempfile].read : v }
27
27
  end
28
28
  end
29
29
  end
@@ -3,15 +3,15 @@ module Fakeit
3
3
  module Helpers
4
4
  class ResponseBuilder
5
5
  class << self
6
- def error(code, err) = [code, { 'Content-Type' => 'application/json' }, [{ message: err.message }.to_json]]
6
+ def error(code, err) = [code, {"Content-Type" => "application/json"}, [{message: err.message}.to_json]]
7
7
 
8
- def not_found = [404, {}, ['Not Found']]
8
+ def not_found = [404, {}, ["Not Found"]]
9
9
 
10
- def method_not_allowed = [405, {}, ['Method Not Allowed']]
10
+ def method_not_allowed = [405, {}, ["Method Not Allowed"]]
11
11
 
12
- def unsupported_media_type = [415, {}, ['Unsupported Media Type']]
12
+ def unsupported_media_type = [415, {}, ["Unsupported Media Type"]]
13
13
 
14
- def ok(body) = [200, { 'Content-Type' => 'application/json' }, [body.to_json]]
14
+ def ok(body) = [200, {"Content-Type" => "application/json"}, [body.to_json]]
15
15
  end
16
16
  end
17
17
  end
@@ -20,8 +20,8 @@ module Fakeit
20
20
  # so that `/base` matches `/base/path` but doesn't match `/basement/path`
21
21
  @base_path =
22
22
  if base_path.nil?
23
- '/'
24
- elsif base_path[-1] == '/'
23
+ "/"
24
+ elsif base_path[-1] == "/"
25
25
  base_path
26
26
  else
27
27
  "#{base_path}/"
@@ -8,11 +8,11 @@ module Fakeit
8
8
 
9
9
  def call(request)
10
10
  case [request.request_method, request.media_type]
11
- in ['GET', _]
11
+ in ["GET", _]
12
12
  Fakeit::App::Helpers::ResponseBuilder.ok(@options.to_hash)
13
- in ['PUT', 'application/json']
13
+ in ["PUT", "application/json"]
14
14
  update(request)
15
- in ['PUT', _]
15
+ in ["PUT", _]
16
16
  Fakeit::App::Helpers::ResponseBuilder.unsupported_media_type
17
17
  else
18
18
  Fakeit::App::Helpers::ResponseBuilder.method_not_allowed
@@ -7,7 +7,7 @@ module Fakeit
7
7
  def call(request, options)
8
8
  @specification
9
9
  .operation(request.request_method.downcase.to_sym, request.path_info, options)
10
- .then { _1 ? handle(_1, request, options) : Fakeit::App::Helpers::ResponseBuilder.not_found }
10
+ .then { it ? handle(it, request, options) : Fakeit::App::Helpers::ResponseBuilder.not_found }
11
11
  end
12
12
 
13
13
  private
@@ -33,8 +33,8 @@ module Fakeit
33
33
  def headers(request)
34
34
  request
35
35
  .each_header
36
- .select { |k, _| k.start_with? 'HTTP_' }
37
- .to_h { |k, v| [k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-'), v] }
36
+ .select { |k, _| k.start_with? "HTTP_" }
37
+ .to_h { |k, v| [k.sub(/^HTTP_/, "").split("_").map(&:capitalize).join("-"), v] }
38
38
  end
39
39
 
40
40
  def parse_query(query_string)
@@ -42,7 +42,7 @@ module Fakeit
42
42
  cgi_query = CGI.parse(query_string)
43
43
 
44
44
  rack_query.merge(cgi_query.slice(*rack_query.keys)) do |_, oldval, newval|
45
- newval.is_a?(Array) && newval.size > 1 ? newval : oldval
45
+ (newval.is_a?(Array) && newval.size > 1) ? newval : oldval
46
46
  end
47
47
  end
48
48
  end
@@ -1,7 +1,7 @@
1
1
  module OpenAPIParser
2
2
  class SchemaValidator
3
3
  class ArrayValidator
4
- alias old_impl coerce_and_validate
4
+ alias_method :old_impl, :coerce_and_validate
5
5
 
6
6
  def coerce_and_validate(value, schema, **keyword_args)
7
7
  coerced_value = schema.parent.is_a?(OpenAPIParser::Schemas::Parameter) ? [*value] : value
@@ -1,11 +1,11 @@
1
- require 'fakeit/openapi/schema'
1
+ require "fakeit/openapi/schema"
2
2
 
3
3
  module OpenAPIParser
4
4
  module Schemas
5
5
  class Schema
6
6
  include Fakeit::Openapi::Schema
7
7
 
8
- alias old_type type
8
+ alias_method :old_type, :type
9
9
 
10
10
  def type = old_type || inferred_type
11
11
 
@@ -13,9 +13,9 @@ module OpenAPIParser
13
13
 
14
14
  def inferred_type
15
15
  if properties
16
- 'object'
16
+ "object"
17
17
  elsif items
18
- 'array'
18
+ "array"
19
19
  end
20
20
  end
21
21
  end
@@ -6,14 +6,14 @@ module Fakeit
6
6
  def call(env)
7
7
  env
8
8
  .tap(&method(:log_request))
9
- .then { @app.call(_1) }
9
+ .then { @app.call(it) }
10
10
  .tap(&method(:log_response))
11
11
  end
12
12
 
13
13
  private
14
14
 
15
15
  def log_request(env)
16
- env['rack.input']
16
+ env["rack.input"]
17
17
  &.tap { |body| Logger.info("Request body: #{body.read}") }
18
18
  &.tap(&:rewind)
19
19
  end