diff --git a/test/misspellings_test.rb b/test/misspellings_test.rb index 2d59656..5cff4d5 100644 --- a/test/misspellings_test.rb +++ b/test/misspellings_test.rb @@ -1,29 +1,29 @@ require_relative "test_helper" class MisspellingsTest < Minitest::Test - def test_misspellings + def test_false store_names ["abc", "abd", "aee"] assert_search "abc", ["abc"], misspellings: false end - def test_misspellings_distance + def test_distance store_names ["abbb", "aabb"] assert_search "aaaa", ["aabb"], misspellings: {distance: 2} end - def test_misspellings_prefix_length + def test_prefix_length store_names ["ap", "api", "apt", "any", "nap", "ah", "ahi"] assert_search "ap", ["ap"], misspellings: {prefix_length: 2} assert_search "api", ["ap", "api", "apt"], misspellings: {prefix_length: 2} end - def test_misspellings_prefix_length_operator + def test_prefix_length_operator store_names ["ap", "api", "apt", "any", "nap", "ah", "aha"] assert_search "ap ah", ["ap", "ah"], operator: "or", misspellings: {prefix_length: 2} assert_search "api ahi", ["ap", "api", "apt", "ah", "aha"], operator: "or", misspellings: {prefix_length: 2} end - def test_misspellings_fields_operator + def test_fields_operator store [ {name: "red", color: "red"}, {name: "blue", color: "blue"}, @@ -34,55 +34,55 @@ class MisspellingsTest < Minitest::Test assert_search "red blue", ["red", "blue", "cyan", "magenta"], operator: "or", fields: ["color"], misspellings: false end - def test_misspellings_below_unmet + def test_below_unmet store_names ["abc", "abd", "aee"] assert_search "abc", ["abc", "abd"], misspellings: {below: 2} end - def test_misspellings_below_unmet_result + def test_below_unmet_result store_names ["abc", "abd", "aee"] assert Product.search("abc", misspellings: {below: 2}).misspellings? end - def test_misspellings_below_met + def test_below_met store_names ["abc", "abd", "aee"] assert_search "abc", ["abc"], misspellings: {below: 1} end - def test_misspellings_below_met_result + def test_below_met_result store_names ["abc", "abd", "aee"] assert !Product.search("abc", misspellings: {below: 1}).misspellings? end - def test_misspellings_field_correct_spelling_still_works + def test_field_correct_spelling_still_works store [{name: "Sriracha", color: "blue"}] assert_misspellings "Sriracha", ["Sriracha"], {fields: [:name, :color]} assert_misspellings "blue", ["Sriracha"], {fields: [:name, :color]} end - def test_misspellings_field_enabled + def test_field_enabled store [{name: "Sriracha", color: "blue"}] assert_misspellings "siracha", ["Sriracha"], {fields: [:name]} assert_misspellings "clue", ["Sriracha"], {fields: [:color]} end - def test_misspellings_field_disabled + def test_field_disabled store [{name: "Sriracha", color: "blue"}] assert_misspellings "siracha", [], {fields: [:color]} assert_misspellings "clue", [], {fields: [:name]} end - def test_misspellings_field_with_transpositions + def test_field_with_transpositions store [{name: "Sriracha", color: "blue"}] assert_misspellings "lbue", [], {transpositions: false, fields: [:color]} end - def test_misspellings_field_with_edit_distance + def test_field_with_edit_distance store [{name: "Sriracha", color: "blue"}] assert_misspellings "crue", ["Sriracha"], {edit_distance: 2, fields: [:color]} end - def test_misspellings_field_multiple + def test_field_multiple store [ {name: "Greek Yogurt", color: "white"}, {name: "Green Onions", color: "yellow"} @@ -91,14 +91,14 @@ class MisspellingsTest < Minitest::Test assert_misspellings "mellow", ["Green Onions"], {fields: [:name, :color]} end - def test_misspellings_field_requires_explicit_search_fields + def test_field_requires_explicit_search_fields store_names ["Sriracha"] assert_raises(ArgumentError) do assert_search "siracha", ["Sriracha"], {misspellings: {fields: [:name]}} end end - def test_misspellings_field_word_start + def test_field_word_start store_names ["Sriracha"] assert_search "siracha", ["Sriracha"], fields: [{name: :word_middle}], misspellings: {fields: [:name]} end -- libgit2 0.21.0