diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-23 00:14:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-23 00:14:48 +0000 |
commit | 738515d12b8a0544bb6de9809b3edc9e2d9277f8 (patch) | |
tree | 0392c92493d1ee101f830404d3c3d8793f1a20ce /test/cgi/test_cgi_multipart.rb | |
parent | da861d79b701ed24aa3a4e2f303fd00096359341 (diff) | |
download | ruby-738515d12b8a0544bb6de9809b3edc9e2d9277f8.tar.gz |
* test/cgi: check by Encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi/test_cgi_multipart.rb')
-rw-r--r-- | test/cgi/test_cgi_multipart.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb index 717640e4f0..c123aa80b5 100644 --- a/test/cgi/test_cgi_multipart.rb +++ b/test/cgi/test_cgi_multipart.rb @@ -32,7 +32,7 @@ class MultiPart def initialize(boundary=nil) @boundary = boundary || create_boundary() @buf = '' - @buf.force_encoding("ascii-8bit") if RUBY_VERSION>="1.9" + @buf.force_encoding(::Encoding::ASCII_8BIT) if defined?(::Encoding) end attr_reader :boundary @@ -44,11 +44,8 @@ class MultiPart buf << "Content-Disposition: form-data: name=\"#{name}\"#{s}\r\n" buf << "Content-Type: #{content_type}\r\n" if content_type buf << "\r\n" - if RUBY_VERSION>="1.9" - buf << value.dup.force_encoding("ASCII-8BIT") - else - buf << value - end + value = value.dup.force_encoding(::Encoding::ASCII_8BIT) if defined?(::Encoding) + buf << value buf << "\r\n" return self end @@ -192,7 +189,7 @@ class CGIMultipartTest < Test::Unit::TestCase {:name=>'image1', :value=>_read('small.png'), :filename=>'small.png', :content_type=>'image/png'}, # small image ] - @data[1][:value].force_encoding("UTF-8") if RUBY_VERSION>="1.9" + @data[1][:value].force_encoding(::Encoding::UTF_8) if defined?(::Encoding) @expected_class = StringIO _test_multipart() end @@ -208,7 +205,7 @@ class CGIMultipartTest < Test::Unit::TestCase {:name=>'image1', :value=>_read('large.png'), :filename=>'large.png', :content_type=>'image/png'}, # large image ] - @data[1][:value].force_encoding("UTF-8") if RUBY_VERSION>="1.9" + @data[1][:value].force_encoding(::Encoding::UTF_8) if defined?(::Encoding) @expected_class = Tempfile _test_multipart() end |