test and fix #call example

This commit is contained in:
Konstantin Haase 2011-04-17 12:56:03 +02:00
parent 97620ef4ff
commit 039675f4b4
7 changed files with 23 additions and 6 deletions

View File

@ -909,7 +909,7 @@ anderen Route gefordert wird. Um das zu erreichen, lässt sich +call+ nutzen:
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
[status, headers, body.map(&:upcase)]
end
get '/bar' do

View File

@ -884,7 +884,7 @@ servir. Para lograr esto, podés usar +call+:
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
[status, headers, body.map(&:upcase)]
end
get '/bar' do

View File

@ -912,7 +912,7 @@ simplement +call+ :
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
[status, headers, body.map(&:upcase)]
end
get '/bar' do

View File

@ -864,7 +864,7 @@ of calling another route. Simply use +call+ to achieve this:
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
[status, headers, body.map(&:upcase)]
end
get '/bar' do

View File

@ -859,7 +859,7 @@ Thin - это более производительный и функциона
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
[status, headers, body.map(&:upcase)]
end
get '/bar' do

View File

@ -844,7 +844,7 @@ Session被用来在请求之间保持状态。如果被激活每一个用户
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
[status, headers, body.map(&:upcase)]
end
get '/bar' do

View File

@ -1043,6 +1043,23 @@ class RoutingTest < Test::Unit::TestCase
assert not_found?
end
it 'allows using call to fire another request internally' do
mock_app do
get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, headers, body.map(&:upcase)]
end
get '/bar' do
"bar"
end
end
get '/foo'
assert ok?
assert_body "BAR"
end
it 'plays well with other routing middleware' do
middleware = Sinatra.new
inner_app = Sinatra.new { get('/foo') { 'hello' } }