merge in env to test methods

This commit is contained in:
Blake Mizerany 2008-03-31 18:03:49 -07:00
parent ed0638480d
commit 1bcd28fa13
2 changed files with 16 additions and 10 deletions

View File

@ -213,6 +213,8 @@ module Sinatra
:buffer_size => 4096
}.freeze
class MissingFile < RuntimeError; end
class FileStreamer
attr_reader :path, :options
@ -919,6 +921,10 @@ def configures(*envs, &b)
end
alias :configure :configures
def set_options(opts)
Sinatra.application.default_options.merge!(opts)
end
def mime(ext, type)
Rack::File::MIME_TYPES[ext.to_s] = type
end

View File

@ -14,34 +14,34 @@ module Sinatra
module Methods
def get_it(path, params = {})
def get_it(path, params = {}, options = {})
agent = params.delete(:agent)
@request = Rack::MockRequest.new(Sinatra.application)
@response = @request.get(path, :input => params.to_params, :agent => agent)
@response = @request.get(path, options.merge(:input => params.to_params, :agent => agent))
end
def head_it(path, params = {})
def head_it(path, params = {}, options = {})
agent = params.delete(:agent)
@request = Rack::MockRequest.new(Sinatra.application)
@response = @request.request('HEAD', path, :input => params.to_params, :agent => agent)
@response = @request.request('HEAD', path, options.merge(:input => params.to_params, :agent => agent))
end
def post_it(path, params = {})
def post_it(path, params = {}, options = {})
agent = params.delete(:agent)
@request = Rack::MockRequest.new(Sinatra.application)
@response = @request.post(path, :input => params.to_params, :agent => agent)
@response = @request.post(path, options.merge(:input => params.to_params, :agent => agent))
end
def put_it(path, params = {})
def put_it(path, params = {}, options = {})
agent = params.delete(:agent)
@request = Rack::MockRequest.new(Sinatra.application)
@response = @request.put(path, :input => params.to_params, :agent => agent)
@response = @request.put(path, options.merge(:input => params.to_params, :agent => agent))
end
def delete_it(path, params = {})
def delete_it(path, params = {}, options = {})
agent = params.delete(:agent)
@request = Rack::MockRequest.new(Sinatra.application)
@response = @request.delete(path, :input => params.to_params, :agent => agent)
@response = @request.delete(path, options.merge(:input => params.to_params, :agent => agent))
end
def follow!