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

Ruby 1.9: fix encoding for test_file_stream

This commit is contained in:
Jeremy Kemper 2009-08-01 20:07:28 -07:00
parent ec94c2550d
commit f2a35723c8

View file

@ -4,7 +4,7 @@ require 'abstract_unit'
module TestFileUtils module TestFileUtils
def file_name() File.basename(__FILE__) end def file_name() File.basename(__FILE__) end
def file_path() File.expand_path(__FILE__) end def file_path() File.expand_path(__FILE__) end
def file_data() File.open(file_path, 'rb') { |f| f.read } end def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end
end end
class SendFileController < ActionController::Base class SendFileController < ActionController::Base
@ -60,6 +60,7 @@ class SendFileTest < ActionController::TestCase
require 'stringio' require 'stringio'
output = StringIO.new output = StringIO.new
output.binmode output.binmode
output.string.force_encoding(file_data.encoding) if output.string.respond_to?(:force_encoding)
assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } } assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } }
assert_equal file_data, output.string assert_equal file_data, output.string
end end