[Groonga-commit] droonga/fluent-plugin-droonga at c4de210 [master] Test: setup @handler and other related variables by HandlerHelper

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Nov 20 14:58:59 JST 2013


YUKI Hiroshi	2013-11-20 14:58:59 +0900 (Wed, 20 Nov 2013)

  New Revision: c4de2105ea678495b861890cd7bbce6459c09039
  https://github.com/droonga/fluent-plugin-droonga/commit/c4de2105ea678495b861890cd7bbce6459c09039

  Message:
    Test: setup @handler and other related variables by HandlerHelper

  Modified files:
    test/helper/handler_helper.rb
    test/plugin/handler/test_handler_groonga.rb
    test/plugin/handler/test_handler_search.rb

  Modified: test/helper/handler_helper.rb (+10 -1)
===================================================================
--- test/helper/handler_helper.rb    2013-11-20 14:54:07 +0900 (dc63895)
+++ test/helper/handler_helper.rb    2013-11-20 14:58:59 +0900 (e129551)
@@ -14,10 +14,19 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 module HandlerHelper
-  def setup_stub_emit
+  def setup_handler(handler_class)
+    @worker = StubWorker.new
+    @handler = handler_class.new(@worker)
+
     @messages = []
     stub(@handler).emit do |message|
       @messages << message
     end
   end
+
+  def teardown_handler
+    @handler = nil
+    @worker = nil
+    @messages = nil
+  end
 end

  Modified: test/plugin/handler/test_handler_groonga.rb (+1 -12)
===================================================================
--- test/plugin/handler/test_handler_groonga.rb    2013-11-20 14:54:07 +0900 (1c65913)
+++ test/plugin/handler/test_handler_groonga.rb    2013-11-20 14:58:59 +0900 (11f1b7c)
@@ -20,7 +20,7 @@ class GroongaHandlerTest < Test::Unit::TestCase
 
   def setup
     setup_database
-    setup_handler
+    setup_handler(Droonga::GroongaHandler)
   end
 
   def teardown
@@ -29,17 +29,6 @@ class GroongaHandlerTest < Test::Unit::TestCase
   end
 
   private
-  def setup_handler
-    @worker = StubWorker.new
-    @handler = Droonga::GroongaHandler.new(@worker)
-    setup_stub_emit
-  end
-
-  def teardown_handler
-    @handler = nil
-  end
-
-  private
   def dump
     database_dumper = Groonga::DatabaseDumper.new(:database => @database)
     database_dumper.dump

  Modified: test/plugin/handler/test_handler_search.rb (+3 -11)
===================================================================
--- test/plugin/handler/test_handler_search.rb    2013-11-20 14:54:07 +0900 (8020850)
+++ test/plugin/handler/test_handler_search.rb    2013-11-20 14:58:59 +0900 (00e39f5)
@@ -16,9 +16,11 @@
 require "droonga/plugin/handler_search"
 
 class SearchHandlerTest < Test::Unit::TestCase
+  include HandlerHelper
+
   def setup
     setup_database
-    setup_handler
+    setup_handler(Droonga::SearchHandler)
   end
 
   def teardown
@@ -32,16 +34,6 @@ class SearchHandlerTest < Test::Unit::TestCase
     super
   end
 
-  def setup_handler
-    @worker = StubWorker.new
-    @handler = Droonga::SearchHandler.new(@worker)
-    setup_stub_emit
-  end
-
-  def teardown_handler
-    @handler = nil
-  end
-
   def search(request)
     @handler.search(request)
     normalize_result_set(@messages.last)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index