[Tomoe-cvs 1114] CVS update: tomoe/test

アーカイブの一覧に戻る

Kouhei Sutou kous****@users*****
2006年 11月 27日 (月) 14:21:31 JST


Index: tomoe/test/context_spec.rb
diff -u tomoe/test/context_spec.rb:1.10 tomoe/test/context_spec.rb:1.11
--- tomoe/test/context_spec.rb:1.10	Sun Nov 26 16:30:37 2006
+++ tomoe/test/context_spec.rb	Mon Nov 27 14:21:31 2006
@@ -5,7 +5,7 @@
     @context = Tomoe::Context.new
     test_dir = File.expand_path(File.join(File.dirname(__FILE__)))
     @context.load_config(@config_file.path)
-    @context.load_recognizer(@recognizer_dir, "simple")
+    @context.load_recognizer(recognizer_dir, "simple")
   end
 
   def numbers_to_point(str)
@@ -14,9 +14,10 @@
     point
   end
 
-  specify "Search by strokes" do
-    Dir.glob(File.join(@test_data_dir, "*.data")).each do |file|
-      base = File.basename(file)
+  test_data_dir = TomoeSpecUtils::Config.test_data_dir
+  Dir.glob(File.join(test_data_dir, "*.data")).each do |file|
+    base = File.basename(file)
+    specify "Search by strokes for #{base}" do
       expected = [base]
       writing = Tomoe::Writing.new
       File.open(file) do |f|
Index: tomoe/test/tomoe-spec-utils.rb
diff -u tomoe/test/tomoe-spec-utils.rb:1.7 tomoe/test/tomoe-spec-utils.rb:1.8
--- tomoe/test/tomoe-spec-utils.rb:1.7	Mon Nov 27 13:49:04 2006
+++ tomoe/test/tomoe-spec-utils.rb	Mon Nov 27 14:21:31 2006
@@ -46,13 +46,29 @@
   end
 
   module Config
+    module_function
+    def base_dir
+      File.expand_path(File.dirname(__FILE__))
+    end
+
+    def top_dir
+      File.expand_path(File.join(base_dir, ".."))
+    end
+
+    def data_dir
+      File.join(top_dir, "data")
+    end
+
+    def test_data_dir
+      File.join(base_dir, "data")
+    end
+
+    def recognizer_dir
+      File.join(top_dir, "recognizer", ".libs")
+    end
+
     def setup_context
       super
-      @base_dir = File.expand_path(File.dirname(__FILE__))
-      @top_dir = File.expand_path(File.join(@base_dir, ".."))
-      @data_dir = File.join(@top_dir, "data")
-      @test_data_dir = File.join(@base_dir, "data")
-      @recognizer_dir = File.join(@top_dir, "recognizer", ".libs")
       @config_file = Tempfile.new("tomoe")
       setup_config_file
     end
@@ -63,7 +79,7 @@
 
     def setup_config_file
       files = %w(kanjidic2.xml readingtest.xml all.xml)
-      names = files.collect {|file| File.join(@data_dir, file)}.join(";")
+      names = files.collect {|file| File.join(data_dir, file)}.join(";")
       @config_file.open
       @config_file.puts(<<-EOC)
 [config]
@@ -71,12 +87,12 @@
 
 [all-dictionary]
 type = xml
-file = #{File.join(@data_dir, "all.xml")}
+file = #{File.join(data_dir, "all.xml")}
 use = true
 
 [kanjidic2-dictionary]
 type = xml
-file = #{File.join(@data_dir, "kanjidic2.xml")}
+file = #{File.join(data_dir, "kanjidic2.xml")}
 
 EOC
       @config_file.close


tomoe-cvs メーリングリストの案内
アーカイブの一覧に戻る