test/match_test.rb in searchkick-0.9.0 vs test/match_test.rb in searchkick-0.9.1

- old
+ new

@@ -110,10 +110,31 @@ def test_misspelling_ziploc store_names ["Ziploc"] assert_search "zip lock", ["Ziploc"] end + def test_misspelling_zucchini_transposition + store_names ["zucchini"] + assert_search "zuccihni", [] # doesn't work without transpositions:true option + assert_search "zuccihni", ["zucchini"], misspellings: {transpositions: true} + end + + def test_misspelling_lasagna + store_names ["lasagna"] + assert_search "lasanga", ["lasagna"], misspellings: {transpositions: true} + assert_search "lasgana", ["lasagna"], misspellings: {transpositions: true} + assert_search "lasaang", [], misspellings: {transpositions: true} # triple transposition, shouldn't work + assert_search "lsagana", [], misspellings: {transpositions: true} # triple transposition, shouldn't work + end + + def test_misspelling_lasagna_pasta + store_names ["lasagna pasta"] + assert_search "lasanga", ["lasagna pasta"], misspellings: {transpositions: true} + assert_search "lasanga pasta", ["lasagna pasta"], misspellings: {transpositions: true} + assert_search "lasanga pasat", ["lasagna pasta"], misspellings: {transpositions: true} # both words misspelled with a transposition should still work + end + # spaces def test_spaces_in_field store_names ["Red Bull"] assert_search "redbull", ["Red Bull"] @@ -149,9 +170,24 @@ end def test_to_be_or_not_to_be store_names ["to be or not to be"] assert_search "to be", ["to be or not to be"] + end + + def test_apostrophe + store_names ["Ben and Jerry's"] + assert_search "ben and jerrys", ["Ben and Jerry's"] + end + + def test_ampersand_index + store_names ["Ben & Jerry's"] + assert_search "ben and jerrys", ["Ben & Jerry's"] + end + + def test_ampersand_search + store_names ["Ben and Jerry's"] + assert_search "ben & jerrys", ["Ben and Jerry's"] end def test_unsearchable store [ {name: "Unsearchable", description: "Almond"}