OSDN Git Service

../shogi_server.rb, ../shogi_server/util.rb: Refactored mkdir_for to Mkdir.mkdir_for.
[shogi-server/shogi-server.git] / test / TC_util.rb
index d3d4931..fcdae10 100644 (file)
@@ -1,4 +1,5 @@
 $:.unshift File.join(File.dirname(__FILE__), "..")
 $:.unshift File.join(File.dirname(__FILE__), "..")
+$topdir = File.expand_path File.dirname(__FILE__)
 require 'test/unit'
 require 'shogi_server/util'
 
 require 'test/unit'
 require 'shogi_server/util'
 
@@ -35,3 +36,24 @@ class TestShogiServer < Test::Unit::TestCase
   end
 
 end
   end
 
 end
+
+
+class TestMkdir < Test::Unit::TestCase
+  def setup
+    @test_dir = File.join($topdir, "hoge", "hoo", "foo.txt")
+  end
+
+  def teardown
+    if FileTest.directory?(File.dirname(@test_dir))
+      Dir.rmdir(File.dirname(@test_dir))
+      Dir.rmdir(File.join($topdir, "hoge"))
+    end
+  end
+
+  def test_mkdir_for
+    assert !FileTest.directory?(File.dirname(@test_dir))
+    ShogiServer::Mkdir.mkdir_for(@test_dir)
+    assert FileTest.directory?(File.dirname(@test_dir))
+  end
+
+end