[Groonga-commit] ranguba/groonga-client-model at d13e224 [master] Support using config/groonga.yml in test

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 20 17:32:13 JST 2016


Kouhei Sutou	2016-12-20 17:32:13 +0900 (Tue, 20 Dec 2016)

  New Revision: d13e22468417fee87f66888f6d018af8dd6ed608
  https://github.com/ranguba/groonga-client-model/commit/d13e22468417fee87f66888f6d018af8dd6ed608

  Message:
    Support using config/groonga.yml in test

  Copied files:
    lib/groonga_client_model/test/groonga_server_runner.rb
      (from lib/groonga_client_model/test/fixture.rb)
  Modified files:
    lib/groonga_client_model/client.rb
    lib/groonga_client_model/spec_helper.rb
    lib/groonga_client_model/test/fixture.rb
    lib/groonga_client_model/test_helper.rb

  Modified: lib/groonga_client_model/client.rb (+1 -0)
===================================================================
--- lib/groonga_client_model/client.rb    2016-12-20 16:55:09 +0900 (771751e)
+++ lib/groonga_client_model/client.rb    2016-12-20 17:32:13 +0900 (c8bfdfd)
@@ -24,6 +24,7 @@ module GroongaClientModel
       end
     end
 
+    attr_reader :url
     def initialize(url=nil)
       @url = url || self.class.url || "http://127.0.0.1:10041"
     end

  Modified: lib/groonga_client_model/spec_helper.rb (+5 -3)
===================================================================
--- lib/groonga_client_model/spec_helper.rb    2016-12-20 16:55:09 +0900 (26e6e11)
+++ lib/groonga_client_model/spec_helper.rb    2016-12-20 17:32:13 +0900 (48b622d)
@@ -14,7 +14,6 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-require "groonga/client/spec-helper"
 require "groonga_client_model/test/fixture"
 
 module GroongaClientModel
@@ -22,11 +21,14 @@ module GroongaClientModel
     extend ActiveSupport::Concern
 
     included do
-      include Groonga::Client::SpecHelper
       include Test::Fixture
 
       before(:each) do
-        setup_groonga_schema
+        setup_groonga
+      end
+
+      after(:each) do
+        teardown_groonga
       end
     end
   end

  Modified: lib/groonga_client_model/test/fixture.rb (+9 -9)
===================================================================
--- lib/groonga_client_model/test/fixture.rb    2016-12-20 16:55:09 +0900 (b187eb8)
+++ lib/groonga_client_model/test/fixture.rb    2016-12-20 17:32:13 +0900 (21845c8)
@@ -14,19 +14,19 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+require "groonga_client_model/test/groonga_server_runner"
+
 module GroongaClientModel
   module Test
     module Fixture
-      def setup_groonga_schema
-        return if @groonga_server_runner.using_running_server?
+      def setup_groonga
+        @groonga_server_runner = GroongaServerRunner.new
+        @groonga_server_runner.run
+      end
 
-        if defined?(Rails)
-          base_dir = Rails.root
-        else
-          base_dir = Pathname.pwd
-        end
-        schema_loader = SchemaLoader.new(base_dir)
-        schema_loader.load
+      def teardown_groonga
+        return if @groonga_server_runner.nil?
+        @groonga_server_runner.stop
       end
     end
   end

  Copied: lib/groonga_client_model/test/groonga_server_runner.rb (+23 -3) 70%
===================================================================
--- lib/groonga_client_model/test/fixture.rb    2016-12-20 16:55:09 +0900 (b187eb8)
+++ lib/groonga_client_model/test/groonga_server_runner.rb    2016-12-20 17:32:13 +0900 (7abe1f6)
@@ -14,11 +14,22 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+require "pathname"
+require "uri"
+
+require "groonga/client/test/groonga-server-runner"
+
 module GroongaClientModel
   module Test
-    module Fixture
-      def setup_groonga_schema
-        return if @groonga_server_runner.using_running_server?
+    class GroongaServerRunner < Groonga::Client::Test::GroongaServerRunner
+      def initialize
+        super
+        @client = Client.new
+      end
+
+      def run
+        super
+        return if using_running_server?
 
         if defined?(Rails)
           base_dir = Rails.root
@@ -28,6 +39,15 @@ module GroongaClientModel
         schema_loader = SchemaLoader.new(base_dir)
         schema_loader.load
       end
+
+      def url
+        @url ||= URI(@client.url)
+      end
+
+      private
+      def open_client(&block)
+        @client.open(&block)
+      end
     end
   end
 end

  Modified: lib/groonga_client_model/test_helper.rb (+7 -5)
===================================================================
--- lib/groonga_client_model/test_helper.rb    2016-12-20 16:55:09 +0900 (231d8ad)
+++ lib/groonga_client_model/test_helper.rb    2016-12-20 17:32:13 +0900 (06c42c1)
@@ -14,19 +14,21 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-require "groonga/client/test-helper"
 require "groonga_client_model/test/fixture"
 
 module GroongaClientModel
   module TestHelper
+    include Test::Fixture
+
     extend ActiveSupport::Concern
 
     included do
-      include Groonga::Client::TestHelper
-      include Test::Fixture
-
       setup do
-        setup_groonga_schema
+        setup_groonga
+      end
+
+      teardown do
+        teardown_groonga
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



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