Sha256: 77216528bbe5792abf56b9beb218a5de951d662c4d92a0845dbee24dd89ed223
Contents?: true
Size: 844 Bytes
Versions: 1
Compression:
Stored size: 844 Bytes
Contents
require 'test_helper' class IndexesTest < 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.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
indexes-0.0.1 | test/indexes_test.rb |