spec/lib/query/weights_spec.rb in picky-3.0.0.pre5 vs spec/lib/query/weights_spec.rb in picky-3.0.0
- old
+ new
@@ -1,9 +1,9 @@
require 'spec_helper'
describe Picky::Query::Weights do
-
+
context 'with weights' do
before(:each) do
@weights = described_class.new [:test1, :test2] => 6,
[:test1] => 5,
[:test3] => 3,
@@ -16,10 +16,21 @@
[:test5, :test1] => 2,
[:test1, :test5] => 2,
[:test3, :test1] => 2,
[:test1, :test3] => 2
end
-
+
+ describe 'score_for' do
+ it 'gets the category names from the combinations' do
+ combinations = [
+ stub(:combination1, :category_name => :test1),
+ stub(:combination1, :category_name => :test2)
+ ]
+
+ @weights.score_for(combinations).should == +6
+ end
+ end
+
describe "weight_for" do
it "should return zero if there is no specific weight" do
@weights.weight_for([:not_a_specific_allocation]).should be_zero
end
end
\ No newline at end of file