spec/lib/query/indexes_spec.rb in picky-3.6.16 vs spec/lib/query/indexes_spec.rb in picky-4.0.0pre1

- old
+ new

@@ -1,13 +1,13 @@ require 'spec_helper' describe Picky::Query::Indexes do - + before(:each) do - Picky::Query::IndexesCheck.stub! :check_backend_types + Picky::Query::IndexesCheck.stub! :check_backends end - + 3.times do |i| n = i + 1 name = :"index#{n}" indexed = :"indexed#{n}" let(name) { stub name, :internal_indexed => stub(indexed) } @@ -17,11 +17,11 @@ indexes = described_class.allocate indexes.stub! :map_categories indexes.send :initialize, index1, index2, index3 indexes end - + describe 'expand_combinations_from' do it 'generates all possible combinations from the given ones' do combinations = [[1,2,3], [:a, :b, :c], [:k, :l]] indexes.expand_combinations_from(combinations).should == [ @@ -45,26 +45,26 @@ [3, :c, :l] ] end it 'can handle small combinations' do combinations = [[1], [2], [3]] - + indexes.expand_combinations_from(combinations).should == [[1, 2, 3]] end it 'can handle empty combinations' do combinations = [[1,2,3], [:a, :b, :c], []] - + indexes.expand_combinations_from(combinations).should == [] end it 'can handle empty combinations' do combinations = [[], [:a, :b, :c], []] - + indexes.expand_combinations_from(combinations).should == [] end it 'can handle totally empty combinations' do combinations = [[], [], []] - + indexes.expand_combinations_from(combinations).should == [] end it 'is fast in a complicated case' do combinations = [[1,2,3], [:a, :b, :c], [:k, :l]] @@ -84,27 +84,27 @@ combinations = [[], [], []] performance_of { indexes.expand_combinations_from(combinations) }.should < 0.00045 end end - + describe 'prepared_allocations_for' do before(:each) do @allocations = stub :allocations indexes.stub! :allocations_for => @allocations end it 'calls the right method in order' do @allocations.should_receive(:uniq).once.ordered.with() @allocations.should_receive(:calculate_score).once.ordered.with(:some_weights) @allocations.should_receive(:sort!).once.ordered.with() - + indexes.prepared_allocations_for :some_tokens, :some_weights end it 'calls the right method in order' do @allocations.should_receive(:uniq).once.ordered.with() @allocations.should_receive(:calculate_score).once.ordered.with({}) @allocations.should_receive(:sort!).once.ordered.with() - + indexes.prepared_allocations_for :some_tokens end end end \ No newline at end of file