Commit 6404b0723d7838012e4e8b50c2145803a51d53b5
1 parent
e5eb1a0b
Exists in
master
and in
5 other branches
Improved test name [skip ci]
Showing
1 changed file
with
17 additions
and
17 deletions
Show diff stats
test/misspellings_test.rb
1 | 1 | require_relative "test_helper" |
2 | 2 | |
3 | 3 | class MisspellingsTest < Minitest::Test |
4 | - def test_misspellings | |
4 | + def test_false | |
5 | 5 | store_names ["abc", "abd", "aee"] |
6 | 6 | assert_search "abc", ["abc"], misspellings: false |
7 | 7 | end |
8 | 8 | |
9 | - def test_misspellings_distance | |
9 | + def test_distance | |
10 | 10 | store_names ["abbb", "aabb"] |
11 | 11 | assert_search "aaaa", ["aabb"], misspellings: {distance: 2} |
12 | 12 | end |
13 | 13 | |
14 | - def test_misspellings_prefix_length | |
14 | + def test_prefix_length | |
15 | 15 | store_names ["ap", "api", "apt", "any", "nap", "ah", "ahi"] |
16 | 16 | assert_search "ap", ["ap"], misspellings: {prefix_length: 2} |
17 | 17 | assert_search "api", ["ap", "api", "apt"], misspellings: {prefix_length: 2} |
18 | 18 | end |
19 | 19 | |
20 | - def test_misspellings_prefix_length_operator | |
20 | + def test_prefix_length_operator | |
21 | 21 | store_names ["ap", "api", "apt", "any", "nap", "ah", "aha"] |
22 | 22 | assert_search "ap ah", ["ap", "ah"], operator: "or", misspellings: {prefix_length: 2} |
23 | 23 | assert_search "api ahi", ["ap", "api", "apt", "ah", "aha"], operator: "or", misspellings: {prefix_length: 2} |
24 | 24 | end |
25 | 25 | |
26 | - def test_misspellings_fields_operator | |
26 | + def test_fields_operator | |
27 | 27 | store [ |
28 | 28 | {name: "red", color: "red"}, |
29 | 29 | {name: "blue", color: "blue"}, |
... | ... | @@ -34,55 +34,55 @@ class MisspellingsTest < Minitest::Test |
34 | 34 | assert_search "red blue", ["red", "blue", "cyan", "magenta"], operator: "or", fields: ["color"], misspellings: false |
35 | 35 | end |
36 | 36 | |
37 | - def test_misspellings_below_unmet | |
37 | + def test_below_unmet | |
38 | 38 | store_names ["abc", "abd", "aee"] |
39 | 39 | assert_search "abc", ["abc", "abd"], misspellings: {below: 2} |
40 | 40 | end |
41 | 41 | |
42 | - def test_misspellings_below_unmet_result | |
42 | + def test_below_unmet_result | |
43 | 43 | store_names ["abc", "abd", "aee"] |
44 | 44 | assert Product.search("abc", misspellings: {below: 2}).misspellings? |
45 | 45 | end |
46 | 46 | |
47 | - def test_misspellings_below_met | |
47 | + def test_below_met | |
48 | 48 | store_names ["abc", "abd", "aee"] |
49 | 49 | assert_search "abc", ["abc"], misspellings: {below: 1} |
50 | 50 | end |
51 | 51 | |
52 | - def test_misspellings_below_met_result | |
52 | + def test_below_met_result | |
53 | 53 | store_names ["abc", "abd", "aee"] |
54 | 54 | assert !Product.search("abc", misspellings: {below: 1}).misspellings? |
55 | 55 | end |
56 | 56 | |
57 | - def test_misspellings_field_correct_spelling_still_works | |
57 | + def test_field_correct_spelling_still_works | |
58 | 58 | store [{name: "Sriracha", color: "blue"}] |
59 | 59 | assert_misspellings "Sriracha", ["Sriracha"], {fields: [:name, :color]} |
60 | 60 | assert_misspellings "blue", ["Sriracha"], {fields: [:name, :color]} |
61 | 61 | end |
62 | 62 | |
63 | - def test_misspellings_field_enabled | |
63 | + def test_field_enabled | |
64 | 64 | store [{name: "Sriracha", color: "blue"}] |
65 | 65 | assert_misspellings "siracha", ["Sriracha"], {fields: [:name]} |
66 | 66 | assert_misspellings "clue", ["Sriracha"], {fields: [:color]} |
67 | 67 | end |
68 | 68 | |
69 | - def test_misspellings_field_disabled | |
69 | + def test_field_disabled | |
70 | 70 | store [{name: "Sriracha", color: "blue"}] |
71 | 71 | assert_misspellings "siracha", [], {fields: [:color]} |
72 | 72 | assert_misspellings "clue", [], {fields: [:name]} |
73 | 73 | end |
74 | 74 | |
75 | - def test_misspellings_field_with_transpositions | |
75 | + def test_field_with_transpositions | |
76 | 76 | store [{name: "Sriracha", color: "blue"}] |
77 | 77 | assert_misspellings "lbue", [], {transpositions: false, fields: [:color]} |
78 | 78 | end |
79 | 79 | |
80 | - def test_misspellings_field_with_edit_distance | |
80 | + def test_field_with_edit_distance | |
81 | 81 | store [{name: "Sriracha", color: "blue"}] |
82 | 82 | assert_misspellings "crue", ["Sriracha"], {edit_distance: 2, fields: [:color]} |
83 | 83 | end |
84 | 84 | |
85 | - def test_misspellings_field_multiple | |
85 | + def test_field_multiple | |
86 | 86 | store [ |
87 | 87 | {name: "Greek Yogurt", color: "white"}, |
88 | 88 | {name: "Green Onions", color: "yellow"} |
... | ... | @@ -91,14 +91,14 @@ class MisspellingsTest < Minitest::Test |
91 | 91 | assert_misspellings "mellow", ["Green Onions"], {fields: [:name, :color]} |
92 | 92 | end |
93 | 93 | |
94 | - def test_misspellings_field_requires_explicit_search_fields | |
94 | + def test_field_requires_explicit_search_fields | |
95 | 95 | store_names ["Sriracha"] |
96 | 96 | assert_raises(ArgumentError) do |
97 | 97 | assert_search "siracha", ["Sriracha"], {misspellings: {fields: [:name]}} |
98 | 98 | end |
99 | 99 | end |
100 | 100 | |
101 | - def test_misspellings_field_word_start | |
101 | + def test_field_word_start | |
102 | 102 | store_names ["Sriracha"] |
103 | 103 | assert_search "siracha", ["Sriracha"], fields: [{name: :word_middle}], misspellings: {fields: [:name]} |
104 | 104 | end | ... | ... |