aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/cgi_test.rb
diff options
context:
space:
mode:
authorEzra Zygmuntowicz <ez@engineyard.com>2008-06-01 11:25:11 -0700
committerJoshua Peek <josh@joshpeek.com>2008-06-01 11:25:11 -0700
commit06cb20708be13fbf736447aa0e5e6dd7d64c8b5d (patch)
treec2ac7798ef3aacbf7b44ef4b104fac71bc8a2eb7 /actionpack/test/controller/cgi_test.rb
parent3282bf3b5016f0c9028cfff1012e8c31a13b40b7 (diff)
downloadrails-06cb20708be13fbf736447aa0e5e6dd7d64c8b5d.tar.gz
rails-06cb20708be13fbf736447aa0e5e6dd7d64c8b5d.tar.bz2
rails-06cb20708be13fbf736447aa0e5e6dd7d64c8b5d.zip
Added Rack processor
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/test/controller/cgi_test.rb')
-rwxr-xr-xactionpack/test/controller/cgi_test.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb
index 87f72fda77..f0f3a4b826 100755
--- a/actionpack/test/controller/cgi_test.rb
+++ b/actionpack/test/controller/cgi_test.rb
@@ -114,3 +114,36 @@ class CgiRequestNeedsRewoundTest < BaseCgiTest
assert_equal 0, request.body.pos
end
end
+
+class CgiResponseTest < BaseCgiTest
+ def setup
+ super
+ @fake_cgi.expects(:header).returns("HTTP/1.0 200 OK\nContent-Type: text/html\n")
+ @response = ActionController::CgiResponse.new(@fake_cgi)
+ @output = StringIO.new('')
+ end
+
+ def test_simple_output
+ @response.body = "Hello, World!"
+
+ @response.out(@output)
+ assert_equal "HTTP/1.0 200 OK\nContent-Type: text/html\nHello, World!", @output.string
+ end
+
+ def test_head_request
+ @fake_cgi.env_table['REQUEST_METHOD'] = 'HEAD'
+ @response.body = "Hello, World!"
+
+ @response.out(@output)
+ assert_equal "HTTP/1.0 200 OK\nContent-Type: text/html\n", @output.string
+ end
+
+ def test_streaming_block
+ @response.body = Proc.new do |response, output|
+ 5.times { |n| output.write(n) }
+ end
+
+ @response.out(@output)
+ assert_equal "HTTP/1.0 200 OK\nContent-Type: text/html\n01234", @output.string
+ end
+end