-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mattkasa/215391-terraform-read-request-body' into 'master'
Test terraform state API using Unicorn::TeeInput See merge request gitlab-org/gitlab!30334
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
REQUEST_CLASSES = [ | ||
::Grape::Request, | ||
::Rack::Request | ||
].freeze | ||
|
||
def request_body_class | ||
return ::Unicorn::TeeInput if defined?(::Unicorn) | ||
|
||
Class.new(StringIO) do | ||
def string | ||
raise NotImplementedError, '#string is only valid under Puma which uses StringIO, use #read instead' | ||
end | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.before(:each, :unicorn) do | ||
REQUEST_CLASSES.each do |request_class| | ||
allow_any_instance_of(request_class) | ||
.to receive(:body).and_wrap_original do |m, *args| | ||
request_body_class.new(m.call(*args).read) | ||
end | ||
end | ||
end | ||
end |