spec/functional/realtime_spec.rb in picky-4.31.1 vs spec/functional/realtime_spec.rb in picky-4.31.2

- old
+ new

@@ -105,11 +105,20 @@ index.add Book.new(2, "Title New", "Author New") books.search('Titl').ids.should == [2,1] end + it 'will not have duplicate result from adding something twice' do + books.search('Titl').ids.should == [1] + index.add Book.new(2, "Title New", "Author New") + index.add Book.new(2, "New Title", "New Author") + index.add Book.new(2, "Title New", "Author New") + + books.search('Titl').ids.should == [2,1] + end + it 'allows replacing something' do index.replace Book.new(1, "Title New", "Author New") end it 'is findable after replacing' do books.search('Ne').ids.should == [] @@ -132,10 +141,21 @@ index.replace Book.new(1, "Title New", "Author New") books.search('title:Ne').ids.should == [1] end + it 'does not unnecessarily change the position if a category already contains it' do + books.search('title:Title').ids.should == [1] + + index.add Book.new(2, "Title New", "Author New") + + books.search('title:Title').ids.should == [2,1] + + index.replace Book.new(1, "Title", "Author") + + books.search('title:Title').ids.should == [2,1] + end end context 'non-partial' do it 'finds the first entry' do books.search('Titl').ids.should == [1] @@ -256,14 +276,14 @@ end end end end - context 'special index' do + context 'index with key_format :to_sym' do let(:index) do Picky::Index.new(:books) do key_format :to_sym - source [] + category :title category :author, similarity: Picky::Generators::Similarity::DoubleMetaphone.new(3) end end let(:books) { Picky::Search.new index } \ No newline at end of file