ruby-changes:8773
From: yugui <ko1@a...>
Date: Sat, 22 Nov 2008 21:12:29 +0900 (JST)
Subject: [ruby-changes:8773] Ruby:r20309 (ruby_1_9_1): * test/cgi/test_cgi_session.rb (setup, teardown): uses a temporary
yugui 2008-11-22 21:11:50 +0900 (Sat, 22 Nov 2008) New Revision: 20309 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20309 Log: * test/cgi/test_cgi_session.rb (setup, teardown): uses a temporary directory for testing session stores. Modified files: branches/ruby_1_9_1/test/cgi/test_cgi_session.rb Index: ruby_1_9_1/test/cgi/test_cgi_session.rb =================================================================== --- ruby_1_9_1/test/cgi/test_cgi_session.rb (revision 20308) +++ ruby_1_9_1/test/cgi/test_cgi_session.rb (revision 20309) @@ -3,19 +3,18 @@ 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 @@ 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 @@ } 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 @@ 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 @@ } 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"]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/