summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-08 15:38:48 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-08 15:38:48 +0000
commit9b139fe5892388653b1c213c633e031c778bd875 (patch)
treeed7a1858a1a7c6c0330096cf8555cb615c5d1e22 /test
parent641f43de973d51a7d463b067833d4a71706d6c5c (diff)
fix test for 1.8
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rwxr-xr-xtest/cgi/test_cgi_multipart.rb6
-rwxr-xr-xtest/cgi/test_cgi_session.rb59
-rwxr-xr-xtest/cgi/test_cgi_tag_helper.rb2
3 files changed, 57 insertions, 10 deletions
diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb
index 34f077e9c5a..47a41f6488b 100755
--- a/test/cgi/test_cgi_multipart.rb
+++ b/test/cgi/test_cgi_multipart.rb
@@ -135,7 +135,11 @@ class CGIMultipartTest < Test::Unit::TestCase
ENV['CONTENT_LENGTH'] = input.length.to_s
ENV['REQUEST_METHOD'] = 'POST'
## set $stdin
- tmpfile = Tempfile.new(self.name, :binmode => true)
+ tmpfile = if RUBY_VERSION >="1.9"
+ Tempfile.new(self.name, :binmode => true)
+ else
+ Tempfile.new(self.name)
+ end
tmpfile << input
tmpfile.rewind()
$stdin = tmpfile
diff --git a/test/cgi/test_cgi_session.rb b/test/cgi/test_cgi_session.rb
index 41935eeb48c..c041b9cf593 100755
--- a/test/cgi/test_cgi_session.rb
+++ b/test/cgi/test_cgi_session.rb
@@ -1,6 +1,7 @@
require 'test/unit'
require 'cgi'
require 'cgi/session'
+require 'cgi/session/pstore'
require 'stringio'
class CGISessionTest < Test::Unit::TestCase
@@ -14,10 +15,10 @@ class CGISessionTest < Test::Unit::TestCase
def teardown
@environ.each do |key, val| ENV.delete(key) end
$stdout = STDOUT
- FileUtils.rm(Dir::glob(File.dirname(__FILE__)+"/session_dir/*"))
+# FileUtils.rm(Dir::glob(File.dirname(__FILE__)+"/session_dir/*"))
end
- def test_cgi_session_core
+ def test_cgi_session_filestore
@environ = {
'REQUEST_METHOD' => 'GET',
# 'QUERY_STRING' => 'id=123&id=456&id=&str=%40h+%3D%7E+%2F%5E%24%2F',
@@ -25,13 +26,16 @@ class CGISessionTest < Test::Unit::TestCase
'SERVER_SOFTWARE' => 'Apache 2.2.0',
'SERVER_PROTOCOL' => 'HTTP/1.1',
}
+ value1="value1"
+ value2="\x8F\xBC\x8D]"
+ value2.force_encoding("SJIS") if RUBY_VERSION>="1.9"
ENV.update(@environ)
cgi = CGI.new
session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir")
- session["key1"]="value1"
- session["key2"]="\x8F\xBC\x8D]".force_encoding("SJIS")
- assert_equal("value1",session["key1"])
- assert_equal("\x8F\xBC\x8D]".force_encoding("SJIS"),session["key2"])
+ session["key1"]=value1
+ session["key2"]=value2
+ assert_equal(value1,session["key1"])
+ assert_equal(value2,session["key2"])
session.close
$stdout = StringIO.new
cgi.out{""}
@@ -47,9 +51,48 @@ class CGISessionTest < Test::Unit::TestCase
cgi = CGI.new
session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir")
$stdout = StringIO.new
- assert_equal("value1",session["key1"])
- assert_equal("\x8F\xBC\x8D]".force_encoding("SJIS"),session["key2"])
+ assert_equal(value1,session["key1"])
+ assert_equal(value2,session["key2"])
session.close
end
+ def test_cgi_session_pstore
+ @environ = {
+ 'REQUEST_METHOD' => 'GET',
+ # 'QUERY_STRING' => 'id=123&id=456&id=&str=%40h+%3D%7E+%2F%5E%24%2F',
+ # 'HTTP_COOKIE' => '_session_id=12345; name1=val1&val2;',
+ 'SERVER_SOFTWARE' => 'Apache 2.2.0',
+ 'SERVER_PROTOCOL' => 'HTTP/1.1',
+ }
+ value1="value1"
+ value2="\x8F\xBC\x8D]"
+ value2.force_encoding("SJIS") if RUBY_VERSION>="1.9"
+ ENV.update(@environ)
+ cgi = CGI.new
+ session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir","database_manager"=>CGI::Session::PStore)
+ session["key1"]=value1
+ session["key2"]=value2
+ assert_equal(value1,session["key1"])
+ assert_equal(value2,session["key2"])
+ session.close
+ $stdout = StringIO.new
+ cgi.out{""}
+
+ @environ = {
+ 'REQUEST_METHOD' => 'GET',
+ # 'HTTP_COOKIE' => "_session_id=#{session_id}",
+ 'QUERY_STRING' => "_session_id=#{session.session_id}",
+ 'SERVER_SOFTWARE' => 'Apache 2.2.0',
+ 'SERVER_PROTOCOL' => 'HTTP/1.1',
+ }
+ ENV.update(@environ)
+ cgi = CGI.new
+ session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir","database_manager"=>CGI::Session::PStore)
+ $stdout = StringIO.new
+ assert_equal(value1,session["key1"])
+ assert_equal(value2,session["key2"])
+ session.close
+
+
+ end
end
diff --git a/test/cgi/test_cgi_tag_helper.rb b/test/cgi/test_cgi_tag_helper.rb
index f28146a0266..6e726b93a39 100755
--- a/test/cgi/test_cgi_tag_helper.rb
+++ b/test/cgi/test_cgi_tag_helper.rb
@@ -318,7 +318,7 @@ class CGITagHelperTest < Test::Unit::TestCase
assert_match(/^<INPUT .*TYPE="checkbox".*>bb<INPUT .*TYPE="checkbox".*>dd$/,str)
assert_match(/^<INPUT .*NAME="foo".*>bb<INPUT .*NAME="foo".*>dd$/,str)
assert_match(/^<INPUT .*>bb<INPUT .*CHECKED.*>dd$/,str)
- assert_match(/<INPUT .*TYPE="text".*>/,cgi.text_field(:name=>"name",:value=>"value"))
+ assert_match(/<INPUT .*TYPE="text".*>/,cgi.text_field(:name=>"name",:value=>"value")) if RUBY_VERSION>="1.9"
if RUBY_VERSION>="1.9"
str=cgi.radio_group("foo",["aa","bb"],["cc","dd",false])
assert_match(/^<INPUT .*VALUE="aa".*>bb<INPUT .*VALUE="cc".*>dd$/,str)