Sha256: 36ac58a6a4518e230af48187faf2d307f9f6168e4608a34b769140fb9d355f5c
Contents?: true
Size: 844 Bytes
Versions: 1
Compression:
Stored size: 844 Bytes
Contents
require 'test_helper' class IndicesTest < ActiveSupport::TestCase setup do Indices.build end teardown do Indices.destroy end test 'namespace' do assert_equal 'dummy_test', Indices.namespace end test 'find' do assert Indices.find(:products) end test 'exist' do assert Indices.exist?(:products) end test 'suggest' do shop = Shop.create ['Les Paul', 'Stratocaster'].each do |name| product = shop.products.create(name: name) product.run_callbacks :commit end sleep 2 assert_equal [], suggest('', shop) assert_equal ['Les Paul'], suggest('les', shop) assert_equal ['Stratocaster'], suggest('str', shop) end private def suggest(term, shop) Indices.suggest(:products, term, shop: shop).map do |suggestion| suggestion[:text] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
indices-0.0.1 | test/indices_test.rb |