1 class Rack::MockRequest
3 alias :env_for_without_env :env_for
4 def env_for(uri = "", opts = {})
5 env = { 'HTTP_USER_AGENT' => opts.delete(:agent) }
6 env_for_without_env(uri, opts).merge(env)
17 def get_it(path, params = {})
18 agent = params.delete(:agent)
19 @request = Rack::MockRequest.new(Sinatra.application)
20 @response = @request.get(path, :input => params.to_params, :agent => agent)
23 def post_it(path, params = {})
24 agent = params.delete(:agent)
25 @request = Rack::MockRequest.new(Sinatra.application)
26 @response = @request.post(path, :input => params.to_params, :agent => agent)
29 def put_it(path, params = {})
30 agent = params.delete(:agent)
31 @request = Rack::MockRequest.new(Sinatra.application)
32 @response = @request.put(path, :input => params.to_params, :agent => agent)
35 def delete_it(path, params = {})
36 agent = params.delete(:agent)
37 @request = Rack::MockRequest.new(Sinatra.application)
38 @response = @request.delete(path, :input => params.to_params, :agent => agent)
42 get_it(@response.location)
45 def method_missing(name, *args)
46 @response.send(name, *args)