0
0
Fork 0

easier environment generation

This still needs some work, but it should definitly be easier to
generate new environments now. Why is that even so much work?
This commit is contained in:
Gibheer 2013-01-11 08:02:46 +01:00
parent d645a2eb49
commit 9e83d9d8b5
1 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,24 @@ class SpecApp
end
end
def environment(uri = '/foo', options = {})
http_options = options
if options.has_key?(:method)
http_options['REQUEST_METHOD'] = options[:method].to_s.capitalize
end
if options.has_key?(:payload)
http_options[:input] = options[:payload].
map {|key, value| "#{key}=#{value}"}.
join('&')
http_options['CONTENT_TYPE'] = 'multipart/form-data'
http_options['REQUEST_METHOD'] = 'POST' unless http_options['REQUEST_METHOD']
end
http_options['zero.params.custom'] = options[:custom] if options.has_key?(:custom)
http_options.inspect
Rack::MockRequest.env_for(uri, http_options)
end
class EnvGenerator
KEY_REQUEST_METHOD = 'REQUEST_METHOD'
KEY_REQUEST_GET = 'GET'