# File lib/merb-core/test/helpers/request_helper.rb, line 7 7: def request(uri, env = {}) 8: uri = url(uri) if uri.is_a?(Symbol) 9: uri = URI(trim_prefix(uri)) 10: uri.scheme ||= "http" 11: uri.host ||= "example.org" 12: 13: if (env[:method] == "POST" || env["REQUEST_METHOD"] == "POST") 14: params = env.delete(:body_params) if env.key?(:body_params) 15: params = env.delete(:params) if env.key?(:params) && !env.key?(:input) 16: 17: unless env.key?(:input) 18: env[:input] = Merb::Parse.params_to_query_string(params) 19: env["CONTENT_TYPE"] = "application/x-www-form-urlencoded" 20: end 21: end 22: 23: if env[:params] 24: uri.query = [ 25: uri.query, Merb::Parse.params_to_query_string(env.delete(:params)) 26: ].compact.join("&") 27: end 28: 29: ignore_cookies = env.has_key?(:jar) && env[:jar].nil? 30: 31: unless ignore_cookies 32: # Setup a default cookie jar container 33: @__cookie_jar__ ||= Merb::Test::CookieJar.new 34: # Grab the cookie group name 35: jar = env.delete(:jar) || :default 36: # Add the cookies explicitly set by the user 37: @__cookie_jar__.update(jar, uri, env.delete(:cookie)) if env.has_key?(:cookie) 38: # Set the cookie header with the cookies 39: env["HTTP_COOKIE"] = @__cookie_jar__.for(jar, uri) 40: end 41: 42: app = Merb::Config[:app] 43: rack = app.call(::Rack::MockRequest.env_for(uri.to_s, env)) 44: 45: rack = Struct.new(:status, :headers, :body, :url, :original_env). 46: new(rack[0], rack[1], rack[2], uri.to_s, env) 47: 48: @__cookie_jar__.update(jar, uri, rack.headers["Set-Cookie"]) unless ignore_cookies 49: 50: Merb::Dispatcher.work_queue.size.times do 51: Merb::Dispatcher.work_queue.pop.call 52: end 53: 54: rack 55: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.