Use Rack's build_query; remove Sinatra::Test#env_for (unused)

This commit is contained in:
Ryan Tomayko 2009-01-18 14:25:08 -08:00
parent 926f10b0e0
commit e9a784299b
2 changed files with 9 additions and 12 deletions

View File

@ -16,14 +16,14 @@ module Sinatra
when 2 # input, env
input, env = args
if input.kind_of?(Hash) # params, env
[env, param_string(input)]
[env, build_query(input)]
else
[env, input]
end
when 1 # params
if (data = args.first).kind_of?(Hash)
env = (data.delete(:env) || {})
[env, param_string(data)]
[env, build_query(data)]
else
[{}, data]
end
@ -82,15 +82,6 @@ module Sinatra
end
end
def env_for(opts={})
opts = rack_opts(opts)
Rack::MockRequest.env_for(opts)
end
def param_string(hash)
hash.map { |pair| pair.map{|v|escape(v)}.join('=') }.join('&')
end
if defined? Sinatra::Compat
# Deprecated. Use: "get" instead of "get_it".
%w(get head post put delete).each do |verb|
@ -101,6 +92,12 @@ module Sinatra
end
RUBY
end
# Deprecated. Use: build_query instead.
def param_string(hash)
sinatra_warn "The param_string method is deprecated; use build_query instead."
build_query(hash)
end
end
end

View File

@ -171,7 +171,7 @@ describe "Routing" do
'looks good'
end
}
get "/foo?#{param_string(input)}"
get "/foo?#{build_query(input)}"
assert ok?
assert_equal 'looks good', body
end