module Rack::Test::Utils

def build_multipart(params, _first = true, multipart = false)

Build a multipart body for the given params.
def build_multipart(params, _first = true, multipart = false)
  raise ArgumentError, 'value must be a Hash' unless params.is_a?(Hash)
  unless multipart
    query = lambda { |value|
      case value
      when Array
        value.each(&query)
      when Hash
        value.values.each(&query)
      when UploadedFile
        multipart = true
      end
    }
    params.values.each(&query)
    return nil unless multipart
  end
  params = normalize_multipart_params(params, true)
  buffer = String.new
  build_parts(buffer, params)
  buffer
end