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

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
This commit is contained in:
yugui 2008-11-22 12:36:19 +00:00
parent ab8114f481
commit b53d7429fc

View file

@ -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"])