Sha256: ad2689a93ec833fea17104827b635c3e28e09bfca82bbb9819da1915bccf5f7e

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require_relative "test_helper"

class MisspellingsTest < Minitest::Test
  def test_misspellings
    store_names ["abc", "abd", "aee"]
    assert_search "abc", ["abc"], misspellings: false
  end

  def test_misspellings_distance
    store_names ["abbb", "aabb"]
    assert_search "aaaa", ["aabb"], misspellings: {distance: 2}
  end

  def test_misspellings_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
    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
    store [
      {name: "red", color: "red"},
      {name: "blue", color: "blue"},
      {name: "cyan", color: "blue green"},
      {name: "magenta", color: "red blue"},
      {name: "green", color: "green"}
    ]
    assert_search "red blue", ["red", "blue", "cyan", "magenta"], operator: "or", fields: ["color"], misspellings: false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
searchkick-1.0.3 test/misspellings_test.rb