Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test coverage for filtering

  • Loading branch information...
commit 5a2a38ec945d7fa4f801fe7134f83d773f40e861 1 parent cb61386
@rixth rixth authored
Showing with 24 additions and 5 deletions.
  1. +5 −5 test/samples/venues.json
  2. +19 −0 test/test_soulmate.rb
View
10 test/samples/venues.json
@@ -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":2,"term":"Turner Field","score":83,"data":{"url":"\/turner-field-tickets\/","subtitle":"Atlanta, GA"}}
+{"id":1,"term":"Dodger Stadium","score":85,"filterable":{"coast":"west"},"data":{"url":"\/dodger-stadium-tickets\/","subtitle":"Los Angeles, CA"}}
+{"id":28,"term":"Angel Stadium","score":85,"filterable":{"coast":"west"},"data":{"url":"\/angel-stadium-tickets\/","subtitle":"Anaheim, CA"}}
+{"id":30,"term":"Chase Field ","score":85,"filterable":{"coast":"west"},"data":{"url":"\/chase-field-tickets\/","subtitle":"Phoenix, AZ"}}
+{"id":29,"term":"Sun Life Stadium","score":84,"filterable":{"coast":"east"},"data":{"url":"\/sun-life-stadium-tickets\/","subtitle":"Miami, FL"}}
+{"id":2,"term":"Turner Field","score":83,"filterable":{"coast":"east"},"data":{"url":"\/turner-field-tickets\/","subtitle":"Atlanta, GA"}}
View
19 test/test_soulmate.rb
@@ -18,4 +18,23 @@ 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_with_filters
+ 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('stad', :filters => { :coast => 'west' },
+ :limit => 5)
+
+ assert_equal 2, results.size
+ assert_equal 'Angel Stadium', results[0]['term']
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.