1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

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 get '/foo' do
status, headers, body = call env.merge("PATH_INFO" => '/bar') status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase] [status, headers, body.map(&:upcase)]
end end
get '/bar' do get '/bar' do

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1043,6 +1043,23 @@ class RoutingTest < Test::Unit::TestCase
assert not_found? assert not_found?
end 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 it 'plays well with other routing middleware' do
middleware = Sinatra.new middleware = Sinatra.new
inner_app = Sinatra.new { get('/foo') { 'hello' } } inner_app = Sinatra.new { get('/foo') { 'hello' } }