Permalink
Browse files

Add test

  • Loading branch information...
1 parent 424051c commit 9f4dda59c5ba6ce8755beb4ad440f130bc1a2f3b @HungYuHei HungYuHei committed Feb 4, 2013
Showing with 12 additions and 2 deletions.
  1. +1 −0 test/samples/venues.json
  2. +11 −2 test/test_soulmate.rb
View
@@ -4,3 +4,4 @@
{"id":29,"term":"Sun Life Stadium","score":75,"data":{"url":"\/sun-life-stadium-tickets\/","subtitle":"Miami, FL"},"aliases":["Dolphins Stadium","Land Shark Stadium"]}
{"id":2,"term":"Turner Field","score":50,"data":{"url":"\/turner-field-tickets\/","subtitle":"Atlanta, GA"}}
{"id":3,"term":"Citi Field","score":92,"data":{"url":"\/citi-field-tickets\/","subtitle":"Atlanta, GA"},"aliases":["Shea Stadium"]}
+{"id":8,"term":"中国佛山 李小龙","score":94,"data":{"url":"\/Bruce Lee\/","subtitle":"Chinese Foshan"},"aliases":["Li XiaoLong"]}
View
@@ -1,3 +1,5 @@
+# coding: utf-8
+
require 'helper'
class TestSoulmate < Test::Unit::TestCase
@@ -10,7 +12,7 @@ def test_integration_can_load_values_and_query
items_loaded = Soulmate::Loader.new('venues').load(items)
- assert_equal 6, items_loaded.size
+ assert_equal 7, items_loaded.size
matcher = Soulmate::Matcher.new('venues')
results = matcher.matches_for_term('stad', :limit => 5)
@@ -28,14 +30,19 @@ def test_integration_can_load_values_and_query_via_aliases
items_loaded = Soulmate::Loader.new('venues').load(items)
- assert_equal 6, items_loaded.size
+ assert_equal 7, items_loaded.size
matcher = Soulmate::Matcher.new('venues')
results = matcher.matches_for_term('land shark stadium', :limit => 5)
assert_equal 1, results.size
assert_equal 'Sun Life Stadium', results[0]['term']
+ # Test Chinese
+ results = matcher.matches_for_term('中国', :limit => 5)
+ assert_equal 1, results.size
+ assert_equal '中国佛山 李小龙', results[0]['term']
+
# Make sure we don't get dupes between aliases and the original term
# this shouldn't happen due to Redis doing an intersect, but just in case!
@@ -101,5 +108,7 @@ def test_prefixes_for_phrase
assert_equal ["te", "tes", "test", "testi", "testin", "th", "thi", "this"], loader.prefixes_for_phrase("testin' this")
assert_equal ["te", "tes", "test"], loader.prefixes_for_phrase("test test")
assert_equal ["so", "sou", "soul", "soulm", "soulma", "soulmat", "soulmate"], loader.prefixes_for_phrase("SoUlmATE")
+
+ assert_equal ['测试', '测试中', '测试中文', 'te', 'tes', 'test'], loader.prefixes_for_phrase('测试中文 test')
end
end

0 comments on commit 9f4dda5

Please sign in to comment.