Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Add data and tests for aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
rixth committed May 10, 2011
1 parent cb61386 commit 0936a3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/samples/venues.json
Original file line number Diff line number Diff line change
@@ -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"}}
24 changes: 24 additions & 0 deletions test/test_soulmate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.