Sha256: bdee97b5a4c938ff703f9bd9434e78f68062410ce23081a7d770009e9469c84d
Contents?: true
Size: 854 Bytes
Versions: 3
Compression:
Stored size: 854 Bytes
Contents
require 'test_helper' class IndexTest < ActiveSupport::TestCase setup do Indexes.build end teardown do Indexes.destroy end test 'namespace' do assert_equal 'dummy_test', Indexes.namespace end test 'find' do assert Indexes.definitions.find(:products) end test 'exist' do assert Indexes.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) Indexes.suggest(:products, term, shop: shop).map do |suggestion| suggestion[:text] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
indexes-4.0.0.2 | test/index_test.rb |
indexes-4.0.0.1 | test/index_test.rb |
indexes-4.0.0.0 | test/index_test.rb |