Skip to content

Commit

Permalink
Don't create garbage StringIO instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 25, 2022
1 parent 5e6e944 commit 3b10fd5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/rack/mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ class << self
# Errors
attr_accessor :errors

def initialize(status, headers, body, errors = StringIO.new(""))
def initialize(status, headers, body, errors = nil)
@original_headers = headers
@errors = errors.string if errors.respond_to?(:string)

if errors
@errors = errors.string if errors.respond_to?(:string)
else
@errors = nil
end

super(body, status, headers)

Expand Down

0 comments on commit 3b10fd5

Please sign in to comment.