1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added TestResponse#binary_content that'll return as a string the data sent through send_data/send_file for testing #500 [Alexey]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@467 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-01-20 14:43:59 +00:00
parent b40d3c9e62
commit 93f7cb2a80
2 changed files with 19 additions and 0 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Added TestResponse#binary_content that'll return as a string the data sent through send_data/send_file for testing #500 [Alexey]
* Added @request.env['RAW_POST_DATA'] for people who need access to the data before Ruby's CGI has parsed it #505 [bitsweat]
* Fixed that a default fragment store wan't being set to MemoryStore as intended.

View file

@ -191,6 +191,23 @@ module ActionController #:nodoc:
headers['cookie'].inject({}) { |hash, cookie| hash[cookie.name] = cookie; hash }
end
# Returns binary content (downloadable file), converted to a String
def binary_content
raise "Response body is not a Proc: #{body.inspect}" unless body.kind_of?(Proc)
require 'stringio'
sio = StringIO.new
begin
$stdout = sio
body.call
ensure
$stdout = STDOUT
end
sio.rewind
sio.read
end
end
class TestSession #:nodoc: