From 039675f4b41176f56bcd167715714c95f338b050 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sun, 17 Apr 2011 12:56:03 +0200 Subject: [PATCH] test and fix #call example --- README.de.rdoc | 2 +- README.es.rdoc | 2 +- README.fr.rdoc | 2 +- README.rdoc | 2 +- README.ru.rdoc | 2 +- README.zh.rdoc | 2 +- test/routing_test.rb | 17 +++++++++++++++++ 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.de.rdoc b/README.de.rdoc index a7605d871e..1cc1cc4cc6 100644 --- a/README.de.rdoc +++ b/README.de.rdoc @@ -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 diff --git a/README.es.rdoc b/README.es.rdoc index 30a61fb6a3..fff627a59c 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -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 diff --git a/README.fr.rdoc b/README.fr.rdoc index bb01a0c4cb..abcbf183c3 100644 --- a/README.fr.rdoc +++ b/README.fr.rdoc @@ -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 diff --git a/README.rdoc b/README.rdoc index 8fcd14738a..895472cc2d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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 diff --git a/README.ru.rdoc b/README.ru.rdoc index d347127b21..792336be77 100644 --- a/README.ru.rdoc +++ b/README.ru.rdoc @@ -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 diff --git a/README.zh.rdoc b/README.zh.rdoc index 83faf8e023..649f98552b 100644 --- a/README.zh.rdoc +++ b/README.zh.rdoc @@ -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 diff --git a/test/routing_test.rb b/test/routing_test.rb index 6edd2582df..5745d575dd 100644 --- a/test/routing_test.rb +++ b/test/routing_test.rb @@ -1043,6 +1043,23 @@ def authorize(username, password) 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' } }