summaryrefslogtreecommitdiff
path: root/test/cgi/test_cgi_session.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-22 12:36:19 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-22 12:36:19 +0000
commitb53d7429fcf5dcea805a33f7ddbedee3d0087253 (patch)
tree22b5b6ee383965d0f1678954746a2a3b7fe547f3 /test/cgi/test_cgi_session.rb
parentab8114f481a1c7934f10af3a8eea37a7fd17abbf (diff)
merges r20309 from ruby_1_9_1 to trunk.
* test/cgi/test_cgi_session.rb (setup, teardown): uses a temporary directory for testing session stores. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi/test_cgi_session.rb')
-rw-r--r--test/cgi/test_cgi_session.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/test/cgi/test_cgi_session.rb b/test/cgi/test_cgi_session.rb
index c041b9cf593..d5120b933c4 100644
--- a/test/cgi/test_cgi_session.rb
+++ b/test/cgi/test_cgi_session.rb
@@ -3,19 +3,18 @@ require 'cgi'
require 'cgi/session'
require 'cgi/session/pstore'
require 'stringio'
+require 'tmpdir'
class CGISessionTest < Test::Unit::TestCase
-
-
def setup
- FileUtils.rm(Dir::glob(File.dirname(__FILE__)+"/session_dir/*"))
+ @session_dir = Dir.mktmpdir('__test_dir__')+'/session_dir/'
+ FileUtils.mkdir_p @session_dir
end
-
def teardown
@environ.each do |key, val| ENV.delete(key) end
$stdout = STDOUT
-# FileUtils.rm(Dir::glob(File.dirname(__FILE__)+"/session_dir/*"))
+ FileUtils.rm_rf(@session_dir)
end
def test_cgi_session_filestore
@@ -31,7 +30,7 @@ class CGISessionTest < Test::Unit::TestCase
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 = CGI::Session.new(cgi,"tmpdir"=>@session_dir)
session["key1"]=value1
session["key2"]=value2
assert_equal(value1,session["key1"])
@@ -49,7 +48,7 @@ class CGISessionTest < Test::Unit::TestCase
}
ENV.update(@environ)
cgi = CGI.new
- session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir")
+ session = CGI::Session.new(cgi,"tmpdir"=>@session_dir)
$stdout = StringIO.new
assert_equal(value1,session["key1"])
assert_equal(value2,session["key2"])
@@ -69,7 +68,7 @@ class CGISessionTest < Test::Unit::TestCase
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 = CGI::Session.new(cgi,"tmpdir"=>@session_dir,"database_manager"=>CGI::Session::PStore)
session["key1"]=value1
session["key2"]=value2
assert_equal(value1,session["key1"])
@@ -87,7 +86,7 @@ class CGISessionTest < Test::Unit::TestCase
}
ENV.update(@environ)
cgi = CGI.new
- session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir","database_manager"=>CGI::Session::PStore)
+ session = CGI::Session.new(cgi,"tmpdir"=>@session_dir,"database_manager"=>CGI::Session::PStore)
$stdout = StringIO.new
assert_equal(value1,session["key1"])
assert_equal(value2,session["key2"])