Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Divided RSpec files into 3 files.

  • Loading branch information...
commit e2814e611117fc60f7886b18b0bab08beb41a16a 1 parent 6375b0b
@kiyoka kiyoka authored
View
17 Rakefile
@@ -20,21 +20,30 @@ begin
gemspec.homepage = "http://github.com/kiyoka/fuzzy-string-match"
gemspec.authors = ["Kiyoka Nishiyama"]
gemspec.files = FileList['lib/*.rb',
- 'test/*.rb',
+ 'test/basic_spec.rb',
+ 'test/mutibyte_spec.rb',
'benchmark/*.rb',
'LICENSE.txt',
'README.md'].to_a
- gemspec.add_development_dependency( "rspec" )
- gemspec.add_development_dependency( "amatch" )
+ gemspec.add_dependency( "rspec" )
gemspec.add_dependency('RubyInline', '>= 3.8.6')
+ gemspec.add_development_dependency( "amatch" )
gemspec.required_ruby_version = '>= 1.9.1'
end
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install jeweler"
end
+task :default => [:test] do
+end
+
task :test do
- sh "ruby -I ./lib /usr/local/bin/rspec -b ./test/fuzzystringmatch_spec.rb"
+ sh "ruby -I ./lib `which rspec` -b ./test/basic_spec.rb"
+ sh "ruby -I ./lib `which rspec` -b ./test/mutibyte_spec.rb"
+end
+
+task :test_dev do
+ sh "ruby -I ./lib `which rspec` -b ./test/verify_with_amatch_spec.rb"
end
task :bench do
View
67 test/basic_spec.rb
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
#
-# fuzzystringmatch_spec.rb - "RSpec file for FuzzyStringMatch module "
+# basic_spec.rb - "Basic test-cases for FuzzyStringMatch module "
#
-# Copyright (c) 2010 Kiyoka Nishiyama <kiyoka@sumibi.org>
+# Copyright (c) 2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -22,7 +22,6 @@
#
#
require 'fuzzystringmatch'
-require 'amatch'
describe FuzzyStringMatch, "when some string distances (Pure) are" do
before do
@@ -75,65 +74,3 @@
}.should be_true
end
end
-
-def amatch_getDistance( s1, s2 )
- @jarow = Amatch::JaroWinkler.new( s1 )
- @jarow.match( s2 )
-end
-
-
-describe FuzzyStringMatch, "when some UTF8 string distances (Pure) are" do
- before do
- @jarow = FuzzyStringMatch::JaroWinkler.new.create
- end
- it "should" do
- @jarow.getDistance( "al", "al" ).should == 1.0
- @jarow.getDistance( "martha", "marhta" ).should be_within(0.0001).of(0.9611)
- @jarow.getDistance( "jones", "johnson" ).should be_within(0.0001).of(0.8323)
- @jarow.getDistance( "abcvwxyz", "cabvwxyz" ).should be_within(0.0001).of(0.9583)
- @jarow.getDistance( "dwayne", "duane" ).should be_within(0.0001).of(0.8400)
- @jarow.getDistance( "dixon", "dicksonx" ).should be_within(0.0001).of(0.8133)
- @jarow.getDistance( "fvie", "ten" ).should == 0.0
- lambda {
- d1 = @jarow.getDistance("zac ephron", "zac efron")
- d2 = @jarow.getDistance("zac ephron", "kai ephron")
- d1 > d2
- }.should be_true
- lambda {
- d1 = @jarow.getDistance("brittney spears", "britney spears")
- d2 = @jarow.getDistance("brittney spears", "brittney startzman")
- d1 > d2
- }.should be_true
- @jarow.getDistance( "スパゲティー", "スパゲッティー" ).should be_within(0.0001).of(0.9666)
- @jarow.getDistance( "スパゲティー", "スパゲティ" ).should be_within(0.0001).of(0.9722)
- @jarow.getDistance( "スティービー・ワンダー", "スピーディー・ワンダー" ).should be_within(0.0001).of(0.8561)
- @jarow.getDistance( "マイケル・ジャクソン", "ジャイケル・マクソン" ).should be_within(0.0001).of(0.8000)
- @jarow.getDistance( "まつもとゆきひろ", "まつもとひろゆき" ).should be_within(0.0001).of(0.9500)
- @jarow.getDistance( "クライエント", "クライアント" ).should be_within(0.0001).of(0.9222)
- @jarow.getDistance( "サーバー", "サーバ" ).should be_within(0.0001).of(0.9416)
- end
-end
-
-
-describe Amatch, "when use Amatch gem, results are" do
- it "should" do
- amatch_getDistance( "henka", "henkan" ).should be_within(0.0001).of(0.9666) ## amatch's result value is different from lucene version.
- amatch_getDistance( "al", "al" ).should == 1.0
- amatch_getDistance( "martha", "marhta" ).should be_within(0.0001).of(0.9611)
- amatch_getDistance( "jones", "johnson" ).should be_within(0.0001).of(0.8323)
- amatch_getDistance( "abcvwxyz", "cabvwxyz" ).should be_within(0.0001).of(0.9583)
- amatch_getDistance( "dwayne", "duane" ).should be_within(0.0001).of(0.8400)
- amatch_getDistance( "dixon", "dicksonx" ).should be_within(0.0001).of(0.8133)
- amatch_getDistance( "fvie", "ten" ).should == 0.0
- lambda {
- d1 = amatch_getDistance("zac ephron", "zac efron")
- d2 = amatch_getDistance("zac ephron", "kai ephron")
- d1 > d2
- }.should be_true
- lambda {
- d1 = amatch_getDistance("brittney spears", "britney spears")
- d2 = amatch_getDistance("brittney spears", "brittney startzman")
- d1 > d2
- }.should be_true
- end
-end
View
56 test/mutibyte_spec.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+# -*- encoding: utf-8 -*-
+#
+# basic_spec.rb - "Multibyte test-cases for FuzzyStringMatch module "
+#
+# Copyright (c) 2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+require 'fuzzystringmatch'
+
+describe FuzzyStringMatch, "when some UTF8 string distances (Pure) are" do
+ before do
+ @jarow = FuzzyStringMatch::JaroWinkler.new.create
+ end
+ it "should" do
+ @jarow.getDistance( "al", "al" ).should == 1.0
+ @jarow.getDistance( "martha", "marhta" ).should be_within(0.0001).of(0.9611)
+ @jarow.getDistance( "jones", "johnson" ).should be_within(0.0001).of(0.8323)
+ @jarow.getDistance( "abcvwxyz", "cabvwxyz" ).should be_within(0.0001).of(0.9583)
+ @jarow.getDistance( "dwayne", "duane" ).should be_within(0.0001).of(0.8400)
+ @jarow.getDistance( "dixon", "dicksonx" ).should be_within(0.0001).of(0.8133)
+ @jarow.getDistance( "fvie", "ten" ).should == 0.0
+ lambda {
+ d1 = @jarow.getDistance("zac ephron", "zac efron")
+ d2 = @jarow.getDistance("zac ephron", "kai ephron")
+ d1 > d2
+ }.should be_true
+ lambda {
+ d1 = @jarow.getDistance("brittney spears", "britney spears")
+ d2 = @jarow.getDistance("brittney spears", "brittney startzman")
+ d1 > d2
+ }.should be_true
+ @jarow.getDistance( "スパゲティー", "スパゲッティー" ).should be_within(0.0001).of(0.9666)
+ @jarow.getDistance( "スパゲティー", "スパゲティ" ).should be_within(0.0001).of(0.9722)
+ @jarow.getDistance( "スティービー・ワンダー", "スピーディー・ワンダー" ).should be_within(0.0001).of(0.8561)
+ @jarow.getDistance( "マイケル・ジャクソン", "ジャイケル・マクソン" ).should be_within(0.0001).of(0.8000)
+ @jarow.getDistance( "まつもとゆきひろ", "まつもとひろゆき" ).should be_within(0.0001).of(0.9500)
+ @jarow.getDistance( "クライエント", "クライアント" ).should be_within(0.0001).of(0.9222)
+ @jarow.getDistance( "サーバー", "サーバ" ).should be_within(0.0001).of(0.9416)
+ end
+end
View
54 test/verify_with_amatch_spec.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+# -*- encoding: utf-8 -*-
+#
+# basic_spec.rb - "Verify test-cases for FuzzyStringMatch module "
+#
+# Copyright (c) 2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+require 'fuzzystringmatch'
+require 'amatch'
+
+
+def amatch_getDistance( s1, s2 )
+ @jarow = Amatch::JaroWinkler.new( s1 )
+ @jarow.match( s2 )
+end
+
+describe Amatch, "when use Amatch gem, results are" do
+ it "should" do
+ amatch_getDistance( "henka", "henkan" ).should be_within(0.0001).of(0.9666) ## amatch's result value is different from lucene version.
+ amatch_getDistance( "al", "al" ).should == 1.0
+ amatch_getDistance( "martha", "marhta" ).should be_within(0.0001).of(0.9611)
+ amatch_getDistance( "jones", "johnson" ).should be_within(0.0001).of(0.8323)
+ amatch_getDistance( "abcvwxyz", "cabvwxyz" ).should be_within(0.0001).of(0.9583)
+ amatch_getDistance( "dwayne", "duane" ).should be_within(0.0001).of(0.8400)
+ amatch_getDistance( "dixon", "dicksonx" ).should be_within(0.0001).of(0.8133)
+ amatch_getDistance( "fvie", "ten" ).should == 0.0
+ lambda {
+ d1 = amatch_getDistance("zac ephron", "zac efron")
+ d2 = amatch_getDistance("zac ephron", "kai ephron")
+ d1 > d2
+ }.should be_true
+ lambda {
+ d1 = amatch_getDistance("brittney spears", "britney spears")
+ d2 = amatch_getDistance("brittney spears", "brittney startzman")
+ d1 > d2
+ }.should be_true
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.