Sha256: 2d483a208ec2e6fe9931e9ab6dbec2d7b696e0735f8d5793a2ba9fb5710cf7a0
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'abstract_unit' include ActsAsIndexed class SearchIndexTest < ActiveSupport::TestCase def teardown destroy_index end def test_should_check_for_non_existing_index SearchIndex.any_instance.expects(:exists?).returns(false) File.expects(:open).never assert build_search_index end def test_should_check_for_existing_index SearchIndex.any_instance.expects(:exists?).returns(true) SearchIndex.any_instance.expects(:load_record_size).returns(0) assert build_search_index end def test_add_record search_index = build_search_index mock_record = mock(:id => 123) mock_condensed_record = ['mock','condensed','record'] search_index.expects(:condense_record).with(mock_record).returns(mock_condensed_record) search_index.expects(:load_atoms).with(mock_condensed_record) search_index.expects(:add_occurences).with(mock_condensed_record,123) search_index.add_record(mock_record) end def test_add_records search_index = build_search_index mock_records = ['record0', 'record1'] search_index.expects(:add_record).with('record0', true) search_index.expects(:add_record).with('record1', true) search_index.add_records(mock_records) end private def build_search_index(root = index_loc, index_depth = 2, fields = [:title, :body], min_word_size = 3) SearchIndex.new([root], index_depth, fields, min_word_size) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_indexed-0.6.6 | test/search_index_test.rb |