Sha256: 652911b6659f17c9209bfaa0063c92756002e4cbf256eebb108ae316e707d272

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'

# Doesn't really test the concurrency, but basic smoke test with fake
# searchers. 
class MultiSearcherTest < ActiveSupport::TestCase
  setup do
    BentoSearch.register_engine("one") do |conf|
      conf.engine = "MockEngine"      
    end
    BentoSearch.register_engine("two") do |conf|
      conf.engine = "MockEngine"      
    end
    BentoSearch.register_engine("three") do |conf|
      conf.engine = "MockEngine"      
    end
  end
  
  teardown do
    BentoSearch.reset_engine_registrations!
  end
  
  
  def test_multisearch
    searcher = BentoSearch::MultiSearcher.new(:one, :two, :three)
    start_returnval = searcher.start("cancer")
    
    assert_same searcher, start_returnval
    
    results = searcher.results
    
    assert_kind_of Hash, results
    assert_equal ["one", "two", "three"].sort, results.keys.sort
    
    ["one", "two", "three"].each do |key|
      assert_kind_of BentoSearch::Results, results[key]
    end
    
    # call results again, we get an empty hash, can only call
    # results once per start. 
    new_results = searcher.results
    assert_kind_of Hash, new_results
    assert_empty new_results
    
  end
    
  
  
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bento_search-1.5.0 test/unit/multi_searcher_test.rb
bento_search-1.4.4 test/unit/multi_searcher_test.rb
bento_search-1.4.3 test/unit/multi_searcher_test.rb
bento_search-1.4.2 test/unit/multi_searcher_test.rb
bento_search-1.3.0 test/unit/multi_searcher_test.rb
bento_search-1.2.2 test/unit/multi_searcher_test.rb
bento_search-1.2.1 test/unit/multi_searcher_test.rb
bento_search-1.2.0 test/unit/multi_searcher_test.rb
bento_search-1.1.0 test/unit/multi_searcher_test.rb
bento_search-1.0.6 test/unit/multi_searcher_test.rb
bento_search-1.0.4 test/unit/multi_searcher_test.rb
bento_search-1.0.3 test/unit/multi_searcher_test.rb
bento_search-1.0.2 test/unit/multi_searcher_test.rb
bento_search-1.0.1 test/unit/multi_searcher_test.rb
bento_search-1.0.0 test/unit/multi_searcher_test.rb
bento_search-0.9.0 test/unit/multi_searcher_test.rb
bento_search-0.8.0 test/unit/multi_searcher_test.rb
bento_search-0.7.0 test/unit/multi_searcher_test.rb
bento_search-0.6.0 test/unit/multi_searcher_test.rb
bento_search-0.5.0 test/unit/multi_searcher_test.rb