[Groonga-commit] ranguba/chupa-text at 6db4d21 [master] Add a test to use decomposer

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 31 23:00:19 JST 2013


Kouhei Sutou	2013-12-31 23:00:19 +0900 (Tue, 31 Dec 2013)

  New Revision: 6db4d213b1d318d1319c8dd75638eaf145db5a3e
  https://github.com/ranguba/chupa-text/commit/6db4d213b1d318d1319c8dd75638eaf145db5a3e

  Message:
    Add a test to use decomposer

  Modified files:
    test/test-feeder.rb

  Modified: test/test-feeder.rb (+28 -0)
===================================================================
--- test/test-feeder.rb    2013-12-31 22:46:21 +0900 (fca81a5)
+++ test/test-feeder.rb    2013-12-31 23:00:19 +0900 (8c518b1)
@@ -44,5 +44,33 @@ class TestFeeder < Test::Unit::TestCase
         assert_equal([], feed(data))
       end
     end
+
+    sub_test_case("use decomposer") do
+      class HTMLDecomposer < ChupaText::Decomposer
+        def target?(data)
+          data.content_type == "text/html"
+        end
+
+        def decompose(data)
+          extracted = ChupaText::Data.new
+          extracted.content_type = "text/plain"
+          extracted.body = data.body.gsub(/<.+?>/, "")
+          extracted
+        end
+      end
+
+      def setup
+        super
+        decomposer = HTMLDecomposer.new
+        @feeder.add_decomposer(decomposer)
+      end
+
+      def test_decompose
+        data = ChupaText::Data.new
+        data.content_type = "text/html"
+        data.body = "<html><body>Hello</body></html>"
+        assert_equal(["Hello"], feed(data))
+      end
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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