Commit 02df0da3d5cd13c544494fc3be747e145fa8cc07

Authored by Andrew Kane
1 parent cc9689aa

New test file for suggestions

Showing 2 changed files with 30 additions and 27 deletions   Show diff stats
test/match_test.rb
... ... @@ -127,31 +127,4 @@ class TestMatch < Minitest::Unit::TestCase
127 127 assert_search "hum", ["Hummus"], autocomplete: true, fields: [:name]
128 128 end
129 129  
130   - # suggest
131   -
132   - def test_suggest
133   - store_names ["Great White Shark", "Hammerhead Shark", "Tiger Shark"]
134   - assert_suggest "How Big is a Tigre Shar", "how big is a tiger shark"
135   - end
136   -
137   - def test_suggest_perfect
138   - store_names ["Tiger Shark", "Great White Shark"]
139   - assert_suggest "Tiger Shark", nil # no correction
140   - end
141   -
142   - def test_suggest_phrase
143   - store_names ["Tiger Shark", "Sharp Teeth", "Sharp Mind"]
144   - assert_suggest "How to catch a tiger shar", "how to catch a tiger shark"
145   - end
146   -
147   - def test_suggest_without_option
148   - assert_raises(RuntimeError){ Product.search("hi").suggestion }
149   - end
150   -
151   - protected
152   -
153   - def assert_suggest(term, expected)
154   - assert_equal expected, Product.search(term, suggest: true).suggestion
155   - end
156   -
157 130 end
... ...
test/suggest_test.rb 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +require_relative "test_helper"
  2 +
  3 +class TestSuggest < Minitest::Unit::TestCase
  4 +
  5 + def test_basic
  6 + store_names ["Great White Shark", "Hammerhead Shark", "Tiger Shark"]
  7 + assert_suggest "How Big is a Tigre Shar", "how big is a tiger shark"
  8 + end
  9 +
  10 + def test_perfect
  11 + store_names ["Tiger Shark", "Great White Shark"]
  12 + assert_suggest "Tiger Shark", nil # no correction
  13 + end
  14 +
  15 + def test_phrase
  16 + store_names ["Tiger Shark", "Sharp Teeth", "Sharp Mind"]
  17 + assert_suggest "How to catch a tiger shar", "how to catch a tiger shark"
  18 + end
  19 +
  20 + def test_without_option
  21 + assert_raises(RuntimeError){ Product.search("hi").suggestion }
  22 + end
  23 +
  24 + protected
  25 +
  26 + def assert_suggest(term, expected)
  27 + assert_equal expected, Product.search(term, suggest: true).suggestion
  28 + end
  29 +
  30 +end
... ...