Permalink
Browse files

Add data and tests for aliases

  • Loading branch information...
rixth committed May 10, 2011
1 parent cb61386 commit 0936a3b6c0d379a7d2011001a1e998fa787d9afc
Showing with 28 additions and 4 deletions.
  1. +4 −4 test/samples/venues.json
  2. +24 −0 test/test_soulmate.rb
View
@@ -1,5 +1,5 @@
-{"id":1,"term":"Dodger Stadium","score":85,"data":{"url":"\/dodger-stadium-tickets\/","subtitle":"Los Angeles, CA"}}
-{"id":28,"term":"Angel Stadium","score":85,"data":{"url":"\/angel-stadium-tickets\/","subtitle":"Anaheim, CA"}}
-{"id":30,"term":"Chase Field ","score":85,"data":{"url":"\/chase-field-tickets\/","subtitle":"Phoenix, AZ"}}
-{"id":29,"term":"Sun Life Stadium","score":84,"data":{"url":"\/sun-life-stadium-tickets\/","subtitle":"Miami, FL"}}
+{"id":1,"term":"Dodger Stadium","score":85,"data":{"url":"\/dodger-stadium-tickets\/","subtitle":"Los Angeles, CA"},"aliases":["Chavez Ravine"]}
+{"id":28,"term":"Angel Stadium","score":85,"data":{"url":"\/angel-stadium-tickets\/","subtitle":"Anaheim, CA"},"aliases":["Edison International Field of Anaheim"]}
+{"id":30,"term":"Chase Field ","score":85,"data":{"url":"\/chase-field-tickets\/","subtitle":"Phoenix, AZ"},"aliases":["Bank One Ballpark", "Bank One Stadium"]}
+{"id":29,"term":"Sun Life Stadium","score":84,"data":{"url":"\/sun-life-stadium-tickets\/","subtitle":"Miami, FL"},"aliases":["Dolphins Stadium","Land Shark Stadium"]}
{"id":2,"term":"Turner Field","score":83,"data":{"url":"\/turner-field-tickets\/","subtitle":"Atlanta, GA"}}
View
@@ -18,4 +18,28 @@ def test_integration_can_load_values_and_query
assert_equal 3, results.size
assert_equal 'Angel Stadium', results[0]['term']
end
+
+ def test_integration_can_load_values_and_query_via_aliases
+ items = []
+ venues = File.open(File.expand_path(File.dirname(__FILE__)) + '/samples/venues.json', "r")
+ venues.each_line do |venue|
+ items << JSON.parse(venue)
+ end
+
+ items_loaded = Soulmate::Loader.new('venues').load(items)
+
+ assert_equal 5, items_loaded
+
+ 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']
+
+ # 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!
+
+ results = matcher.matches_for_term('stadium', :limit => 5)
+ assert_equal 4, results.size
+ end
end

0 comments on commit 0936a3b

Please sign in to comment.