spec/lib/indexing/bundle/redis_spec.rb in picky-2.6.0 vs spec/lib/indexing/bundle/redis_spec.rb in picky-2.7.0

- old
+ new

@@ -8,51 +8,51 @@ @partial = stub :partial @weights = stub :weights @similarity = stub :similarity end - let(:index) { described_class.new :some_name, @category, @similarity, @partial, @weights } + let(:index) { described_class.new :some_name, @category, @weights, @partial, @similarity } describe 'raise_cache_missing' do it 'does something' do expect { index.raise_cache_missing :similarity - }.to raise_error("Error: The similarity cache for some_index:some_category:some_name is missing.") + }.to raise_error("Error: The similarity cache for test:some_index:some_category:some_name is missing.") end end describe 'warn_cache_small' do it 'warns the user' do - index.should_receive(:warn).once.with "Warning: similarity cache for some_index:some_category:some_name smaller than 16 bytes." + index.should_receive(:warn).once.with "Warning: similarity cache for test:some_index:some_category:some_name smaller than 16 bytes." index.warn_cache_small :similarity end end describe 'identifier' do it 'should return a specific identifier' do - index.identifier.should == 'some_index:some_category:some_name' + index.identifier.should == 'test:some_index:some_category:some_name' end end describe 'initialize_index_for' do context 'token not yet assigned' do before(:each) do - index.stub! :index => {} + index.stub! :inverted => {} end it 'should assign it an empty array' do - index.initialize_index_for :some_token + index.initialize_inverted_index_for :some_token - index.index[:some_token].should == [] + index.inverted[:some_token].should == [] end end context 'token already assigned' do before(:each) do index.stub! :index => { :some_token => :already_assigned } end it 'should not assign it anymore' do - index.initialize_index_for :some_token + index.initialize_inverted_index_for :some_token index.index[:some_token].should == :already_assigned end end end @@ -62,12 +62,12 @@ files = stub :files files.should_receive(:retrieve).once.and_yield ' 1234', :some_token index.stub! :files => files @ary = stub :ary - @index.should_receive(:[]).any_number_of_times.and_return @ary - index.stub! :index => @index + inverted = stub :inverted, :[] => @ary + index.stub! :inverted => inverted end context 'id key format' do before(:each) do index.should_receive(:[]).once.with(:key_format).and_return :to_i end @@ -97,17 +97,17 @@ index.retrieve end end end - describe 'load_from_index_file' do + describe 'load_from_prepared_index_file' do it 'should call two methods in order' do - index.should_receive(:load_from_index_generation_message).once.ordered + index.should_receive(:load_from_prepared_index_generation_message).once.ordered index.should_receive(:clear).once.ordered index.should_receive(:retrieve).once.ordered - index.load_from_index_file + index.load_from_prepared_index_file end end describe 'generate_derived' do it 'should call two methods in order' do @@ -127,20 +127,22 @@ end end describe 'generate_caches_from_source' do it 'should call two methods in order' do - index.should_receive(:load_from_index_file).once.ordered + index.should_receive(:load_from_prepared_index_file).once.ordered index.should_receive(:generate_caches_from_memory).once.ordered index.generate_caches_from_source end end describe 'dump' do it 'should trigger dumps' do - index.should_receive(:dump_index).once.with + index.stub! :timed_exclaim + + index.should_receive(:dump_inverted).once.with index.should_receive(:dump_weights).once.with index.should_receive(:dump_similarity).once.with index.should_receive(:dump_configuration).once.with index.dump @@ -254,10 +256,10 @@ end end describe 'initialization' do it 'should initialize the index correctly' do - index.index.should == {} + index.inverted.should == {} end it 'should initialize the weights index correctly' do index.weights.should == {} end it 'should initialize the similarity index correctly' do \ No newline at end of file