mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
merge in env to test methods
This commit is contained in:
parent
ed0638480d
commit
1bcd28fa13
2 changed files with 16 additions and 10 deletions
|
@ -213,6 +213,8 @@ module Sinatra
|
||||||
:buffer_size => 4096
|
:buffer_size => 4096
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
class MissingFile < RuntimeError; end
|
||||||
|
|
||||||
class FileStreamer
|
class FileStreamer
|
||||||
|
|
||||||
attr_reader :path, :options
|
attr_reader :path, :options
|
||||||
|
@ -919,6 +921,10 @@ def configures(*envs, &b)
|
||||||
end
|
end
|
||||||
alias :configure :configures
|
alias :configure :configures
|
||||||
|
|
||||||
|
def set_options(opts)
|
||||||
|
Sinatra.application.default_options.merge!(opts)
|
||||||
|
end
|
||||||
|
|
||||||
def mime(ext, type)
|
def mime(ext, type)
|
||||||
Rack::File::MIME_TYPES[ext.to_s] = type
|
Rack::File::MIME_TYPES[ext.to_s] = type
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,34 +14,34 @@ module Sinatra
|
||||||
|
|
||||||
module Methods
|
module Methods
|
||||||
|
|
||||||
def get_it(path, params = {})
|
def get_it(path, params = {}, options = {})
|
||||||
agent = params.delete(:agent)
|
agent = params.delete(:agent)
|
||||||
@request = Rack::MockRequest.new(Sinatra.application)
|
@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
|
end
|
||||||
|
|
||||||
def head_it(path, params = {})
|
def head_it(path, params = {}, options = {})
|
||||||
agent = params.delete(:agent)
|
agent = params.delete(:agent)
|
||||||
@request = Rack::MockRequest.new(Sinatra.application)
|
@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
|
end
|
||||||
|
|
||||||
def post_it(path, params = {})
|
def post_it(path, params = {}, options = {})
|
||||||
agent = params.delete(:agent)
|
agent = params.delete(:agent)
|
||||||
@request = Rack::MockRequest.new(Sinatra.application)
|
@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
|
end
|
||||||
|
|
||||||
def put_it(path, params = {})
|
def put_it(path, params = {}, options = {})
|
||||||
agent = params.delete(:agent)
|
agent = params.delete(:agent)
|
||||||
@request = Rack::MockRequest.new(Sinatra.application)
|
@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
|
end
|
||||||
|
|
||||||
def delete_it(path, params = {})
|
def delete_it(path, params = {}, options = {})
|
||||||
agent = params.delete(:agent)
|
agent = params.delete(:agent)
|
||||||
@request = Rack::MockRequest.new(Sinatra.application)
|
@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
|
end
|
||||||
|
|
||||||
def follow!
|
def follow!
|
||||||
|
|
Loading…
Reference in a new issue