spec/lib/indexed/bundle_realtime_spec.rb in picky-3.6.7 vs spec/lib/indexed/bundle_realtime_spec.rb in picky-3.6.8

- old
+ new

@@ -11,11 +11,11 @@ @similarity = Picky::Generators::Similarity::DoubleMetaphone.new 3 @bundle = described_class.new :some_name, @category, @weights, @partial, @similarity end it 'is by default empty' do - @bundle.realtime_mapping.should == {} + @bundle.realtime.should == {} end it 'is by default empty' do @bundle.weights.should == {} end it 'is by default empty' do @@ -23,93 +23,184 @@ end it 'is by default empty' do @bundle.similarity.should == {} end - describe 'combined' do - it 'works correctly' do - @bundle.add 1, :title - @bundle.add 2, :title + context 'strings' do + describe 'combined' do + it 'works correctly' do + @bundle.add 1, 'title' + @bundle.add 2, 'title' - @bundle.realtime_mapping.should == { 1 => [:title], 2 => [:title] } - @bundle.inverted.should == { :title => [2,1] } - @bundle.weights.should == { :title => 0.693 } - @bundle.similarity.should == { :TTL => [:title] } - end - it 'works correctly' do - @bundle.add 1, :title - @bundle.add 2, :title - @bundle.remove 1 - @bundle.remove 2 + @bundle.realtime.should == { 1 => ['title'], 2 => ['title'] } + @bundle.inverted.should == { 'title' => [2,1] } + @bundle.weights.should == { 'title' => 0.693 } + @bundle.similarity.should == { 'TTL' => ['title'] } + end + it 'works correctly' do + @bundle.add 1, 'title' + @bundle.add 2, 'title' + @bundle.remove 1 + @bundle.remove 2 - @bundle.realtime_mapping.should == {} - @bundle.weights.should == {} - @bundle.inverted.should == {} - @bundle.similarity.should == {} - end - it 'works correctly' do - @bundle.add 1, :title - @bundle.add 1, :other - @bundle.add 1, :whatever - @bundle.remove 1 + @bundle.realtime.should == {} + @bundle.weights.should == {} + @bundle.inverted.should == {} + @bundle.similarity.should == {} + end + it 'works correctly' do + @bundle.add 1, 'title' + @bundle.add 1, 'other' + @bundle.add 1, 'whatever' + @bundle.remove 1 - @bundle.realtime_mapping.should == {} - @bundle.weights.should == {} - @bundle.inverted.should == {} - @bundle.similarity.should == {} - end - it 'works correctly' do - @bundle.add 1, :title - @bundle.add 2, :thing - @bundle.add 1, :other - @bundle.remove 1 + @bundle.realtime.should == {} + @bundle.weights.should == {} + @bundle.inverted.should == {} + @bundle.similarity.should == {} + end + it 'works correctly' do + @bundle.add 1, 'title' + @bundle.add 2, 'thing' + @bundle.add 1, 'other' + @bundle.remove 1 - @bundle.realtime_mapping.should == { 2 => [:thing] } - @bundle.weights.should == { :thing => 0.0 } - @bundle.inverted.should == { :thing => [2] } - @bundle.similarity.should == { :"0NK" => [:thing] } - end - it 'works correctly' do - @bundle.add 1, :title - @bundle.add 1, :title + @bundle.realtime.should == { 2 => ['thing'] } + @bundle.weights.should == { 'thing' => 0.0 } + @bundle.inverted.should == { 'thing' => [2] } + @bundle.similarity.should == { '0NK' => ['thing'] } + end + it 'works correctly' do + @bundle.add 1, 'title' + @bundle.add 1, 'title' - @bundle.realtime_mapping.should == { 1 => [:title] } - @bundle.weights.should == { :title => 0.0 } - @bundle.inverted.should == { :title => [1] } - @bundle.similarity.should == { :TTL => [:title] } + @bundle.realtime.should == { 1 => ['title'] } + @bundle.weights.should == { 'title' => 0.0 } + @bundle.inverted.should == { 'title' => [1] } + @bundle.similarity.should == { 'TTL' => ['title'] } + end + it 'works correctly' do + @bundle.add 1, 'title' + @bundle.remove 1 + @bundle.remove 1 + + @bundle.realtime.should == {} + @bundle.weights.should == {} + @bundle.inverted.should == {} + @bundle.similarity.should == {} + end end - it 'works correctly' do - @bundle.add 1, :title - @bundle.remove 1 - @bundle.remove 1 - @bundle.realtime_mapping.should == {} - @bundle.weights.should == {} - @bundle.inverted.should == {} - @bundle.similarity.should == {} + describe 'add' do + it 'works correctly' do + @bundle.add 1, 'title' + + @bundle.realtime.should == { 1 => ['title'] } + + @bundle.add 2, 'other' + + @bundle.realtime.should == { 1 => ['title'], 2 => ['other'] } + + @bundle.add 1, 'thing' + + @bundle.realtime.should == { 1 => ['title', 'thing'], 2 => ['other'] } + end + it 'works correctly' do + @bundle.add 1, 'title' + + @bundle.weights.should == { 'title' => 0.0 } + @bundle.inverted.should == { 'title' => [1] } + @bundle.similarity.should == { 'TTL' => ['title'] } + end end end - describe 'add' do - it 'works correctly' do - @bundle.add 1, :title + context 'symbols' do + describe 'combined' do + it 'works correctly' do + @bundle.add 1, :title + @bundle.add 2, :title - @bundle.realtime_mapping.should == { 1 => [:title] } + @bundle.realtime.should == { 1 => [:title], 2 => [:title] } + @bundle.inverted.should == { :title => [2,1] } + @bundle.weights.should == { :title => 0.693 } + @bundle.similarity.should == { :TTL => [:title] } + end + it 'works correctly' do + @bundle.add 1, :title + @bundle.add 2, :title + @bundle.remove 1 + @bundle.remove 2 - @bundle.add 2, :other + @bundle.realtime.should == {} + @bundle.weights.should == {} + @bundle.inverted.should == {} + @bundle.similarity.should == {} + end + it 'works correctly' do + @bundle.add 1, :title + @bundle.add 1, :other + @bundle.add 1, :whatever + @bundle.remove 1 - @bundle.realtime_mapping.should == { 1 => [:title], 2 => [:other] } + @bundle.realtime.should == {} + @bundle.weights.should == {} + @bundle.inverted.should == {} + @bundle.similarity.should == {} + end + it 'works correctly' do + @bundle.add 1, :title + @bundle.add 2, :thing + @bundle.add 1, :other + @bundle.remove 1 - @bundle.add 1, :thing + @bundle.realtime.should == { 2 => [:thing] } + @bundle.weights.should == { :thing => 0.0 } + @bundle.inverted.should == { :thing => [2] } + @bundle.similarity.should == { :"0NK" => [:thing] } + end + it 'works correctly' do + @bundle.add 1, :title + @bundle.add 1, :title - @bundle.realtime_mapping.should == { 1 => [:title, :thing], 2 => [:other] } + @bundle.realtime.should == { 1 => [:title] } + @bundle.weights.should == { :title => 0.0 } + @bundle.inverted.should == { :title => [1] } + @bundle.similarity.should == { :TTL => [:title] } + end + it 'works correctly' do + @bundle.add 1, :title + @bundle.remove 1 + @bundle.remove 1 + + @bundle.realtime.should == {} + @bundle.weights.should == {} + @bundle.inverted.should == {} + @bundle.similarity.should == {} + end end - it 'works correctly' do - @bundle.add 1, :title - @bundle.weights.should == { :title => 0.0 } - @bundle.inverted.should == { :title => [1] } - @bundle.similarity.should == { :TTL => [:title] } + describe 'add' do + it 'works correctly' do + @bundle.add 1, :title + + @bundle.realtime.should == { 1 => [:title] } + + @bundle.add 2, :other + + @bundle.realtime.should == { 1 => [:title], 2 => [:other] } + + @bundle.add 1, :thing + + @bundle.realtime.should == { 1 => [:title, :thing], 2 => [:other] } + end + it 'works correctly' do + @bundle.add 1, :title + + @bundle.weights.should == { :title => 0.0 } + @bundle.inverted.should == { :title => [1] } + @bundle.similarity.should == { :TTL => [:title] } + end end end end \ No newline at end of file