Sha256: a4860d140a083562acf542237e22ca85b837cd980331a4fd05a641e7f9c5a8d5

Contents?: true

Size: 1.25 KB

Versions: 38

Compression:

Stored size: 1.25 KB

Contents

require_relative "test_helper"

class SimilarTest < Minitest::Test
  def test_similar
    store_names ["Annie's Naturals Organic Shiitake & Sesame Dressing"]
    assert_search "Annie's Naturals Shiitake & Sesame Vinaigrette", ["Annie's Naturals Organic Shiitake & Sesame Dressing"], similar: true
  end

  def test_fields
    store_names ["1% Organic Milk", "2% Organic Milk", "Popcorn"]
    assert_equal ["2% Organic Milk"], Product.where(name: "1% Organic Milk").first.similar(fields: ["name"]).map(&:name)
  end

  def test_order
    store_names ["Lucerne Milk Chocolate Fat Free", "Clover Fat Free Milk"]
    assert_order "Lucerne Fat Free Chocolate Milk", ["Lucerne Milk Chocolate Fat Free", "Clover Fat Free Milk"], similar: true
  end

  def test_limit
    store_names ["1% Organic Milk", "2% Organic Milk", "Fat Free Organic Milk", "Popcorn"]
    assert_equal ["2% Organic Milk"], Product.where(name: "1% Organic Milk").first.similar(fields: ["name"], order: ["name"], limit: 1).map(&:name)
  end

  def test_per_page
    store_names ["1% Organic Milk", "2% Organic Milk", "Fat Free Organic Milk", "Popcorn"]
    assert_equal ["2% Organic Milk"], Product.where(name: "1% Organic Milk").first.similar(fields: ["name"], order: ["name"], per_page: 1).map(&:name)
  end
end

Version data entries

38 entries across 38 versions & 3 rubygems

Version Path
searchkick-2.5.0 test/similar_test.rb
searchkick-hooopo-2.4.1 test/similar_test.rb
searchkick-hooopo-2.4.0 test/similar_test.rb
searchkick-2.4.0 test/similar_test.rb
searchkick-hooopo-2.3.5 test/similar_test.rb
searchkick-2.3.2 test/similar_test.rb
searchkick-hooopo-2.3.4 test/similar_test.rb
searchkick-2.3.1 test/similar_test.rb
searchkick-hooopo-2.3.3 test/similar_test.rb
searchkick-hooopo-2.3.2 test/similar_test.rb
searchkick-hooopo-2.3.1 test/similar_test.rb
searchkick-hooopo-2.3.0 test/similar_test.rb
searchkick-2.3.0 test/similar_test.rb
searchkick-2.2.1 test/similar_test.rb
searchkick-2.2.0 test/similar_test.rb
searchkick-2.1.1 test/similar_test.rb
searchkick-2.1.0 test/similar_test.rb
searchkick-2.0.4 test/similar_test.rb
searchkick-2.0.3 test/similar_test.rb
searchkick-2.0.2 test/similar_test.rb