spec/lib/indexed/wrappers/exact_first_spec.rb in picky-3.6.4 vs spec/lib/indexed/wrappers/exact_first_spec.rb in picky-3.6.6

- old
+ new

@@ -41,34 +41,46 @@ describe 'ids' do it "uses first the exact, then the partial ids" do @exact.stub! :ids => [1,4,5,6] @partial.stub! :ids => [2,3,7] - @wrapper.ids(:anything).should == [1,4,5,6,2,3,7] + @wrapper.ids(stub(:token, :text => :anything, :partial? => true)).should == [1,4,5,6,2,3,7] end + it "uses only the exact ids" do + @exact.stub! :ids => [1,4,5,6] + @partial.stub! :ids => [2,3,7] + + @wrapper.ids(stub(:token, :text => :anything, :partial? => false)).should == [1,4,5,6] + end end describe 'weight' do context "exact with weight" do before(:each) do - @exact.stub! :weight => 1.23 + @exact.stub! :weight => 0.12 end context "partial with weight" do before(:each) do - @partial.stub! :weight => 0.12 + @partial.stub! :weight => 1.23 end it "uses the higher weight" do - @wrapper.weight(:anything).should == 1.23 + @wrapper.weight(stub(:token, :text => :anything, :partial? => true)).should == 1.23 end + it "uses the exact weight" do + @wrapper.weight(stub(:token, :text => :anything, :partial? => false)).should == 0.12 + end end context "partial without weight" do before(:each) do @partial.stub! :weight => nil end it "uses the exact weight" do - @wrapper.weight(:anything).should == 1.23 + @wrapper.weight(stub(:token, :text => :anything, :partial? => true)).should == 0.12 end + it "uses the exact weight" do + @wrapper.weight(stub(:token, :text => :anything, :partial? => false)).should == 0.12 + end end end context "exact without weight" do before(:each) do @exact.stub! :weight => nil @@ -76,18 +88,24 @@ context "partial with weight" do before(:each) do @partial.stub! :weight => 0.12 end it "uses the partial weight" do - @wrapper.weight(:anything).should == 0.12 + @wrapper.weight(stub(:token, :text => :anything, :partial? => true)).should == 0.12 end + it "uses the exact weight" do + @wrapper.weight(stub(:token, :text => :anything, :partial? => false)).should == nil + end end context "partial without weight" do before(:each) do @partial.stub! :weight => nil end - it "is zero" do - @wrapper.weight(:anything).should == 0 + it "is nil" do + @wrapper.weight(stub(:token, :text => :anything, :partial? => true)).should == nil + end + it "is nil" do + @wrapper.weight(stub(:token, :text => :anything, :partial? => false)).should == nil end end end end \ No newline at end of file