[前][次][番号順一覧][スレッド一覧]

ruby-changes:8780

From: yugui <ko1@a...>
Date: Sat, 22 Nov 2008 21:36:33 +0900 (JST)
Subject: [ruby-changes:8780] Ruby:r20316 (trunk): merges r20309 from ruby_1_9_1 to trunk.

yugui	2008-11-22 21:36:19 +0900 (Sat, 22 Nov 2008)

  New Revision: 20316

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20316

  Log:
    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.

  Modified files:
    trunk/test/cgi/test_cgi_session.rb

Index: test/cgi/test_cgi_session.rb
===================================================================
--- test/cgi/test_cgi_session.rb	(revision 20315)
+++ test/cgi/test_cgi_session.rb	(revision 20316)
@@ -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/

[前][次][番号順一覧][スレッド一覧]