module Sinatra::Test

def make_request(verb, path, body=nil, options={})

def make_request(verb, path, body=nil, options={})
  @app = Sinatra::Application if @app.nil? && defined?(Sinatra::Application)
  fail "@app not set - cannot make request" if @app.nil?
  @request = Rack::MockRequest.new(@app)
  options = { :lint => true }.merge(options || {})
  case
  when body.respond_to?(:to_hash)
    options.merge! body.delete(:env) if body.key?(:env)
    options[:content_type] ||= 'application/x-www-form-urlencoded'
    options[:input] = param_string(body)
  when body.respond_to?(:to_str)
    options[:input] = body
  when body.nil?
    options[:input] = ''
  else
    raise ArgumentError, "body must be a Hash, String, or nil"
  end
  yield @request if block_given?
  @response = @request.request(verb, path, rack_options(options))
end