spec/lib/query/allocation_spec.rb in picky-3.1.0 vs spec/lib/query/allocation_spec.rb in picky-3.1.1
- old
+ new
@@ -3,11 +3,11 @@
describe Picky::Query::Allocation do
before(:each) do
@backend = stub :backend
@index = stub :index, :result_identifier => :some_result_identifier, :backend => @backend
- @combinations = stub :combinations
+ @combinations = stub :combinations, :empty? => false
@allocation = described_class.new @index, @combinations
end
describe "eql?" do
# TODO This works, but is not acceptable.
@@ -130,11 +130,11 @@
end
describe 'to_result' do
context 'with few combinations' do
before(:each) do
- @allocation = described_class.new @index, stub(:combinations, :to_result => [:some_result])
+ @allocation = described_class.new @index, stub(:combinations, :empty? => false, :to_result => [:some_result])
@allocation.instance_variable_set :@score, :some_score
end
context 'with ids' do
it 'should output an array of information' do
@backend.stub! :ids => [1,2,3]
@@ -145,11 +145,13 @@
end
end
end
context 'with results' do
before(:each) do
- combinations = stub :combinations, :to_result => [:some_result1, :some_result2]
+ combinations = stub :combinations,
+ :empty? => false,
+ :to_result => [:some_result1, :some_result2]
@allocation = described_class.new @index, combinations
@allocation.instance_variable_set :@score, :some_score
end
context 'with ids' do
it 'should output an array of information' do
@@ -161,11 +163,11 @@
end
end
end
context 'without results' do
before(:each) do
- @allocation = described_class.new @index, stub(:combinations, :to_result => [])
+ @allocation = described_class.new @index, stub(:combinations, :empty? => true)
@allocation.instance_variable_set :@score, :some_score
end
it 'should return nil' do
@backend.stub! :ids => []
@@ -176,10 +178,10 @@
end
end
describe 'to_json' do
before(:each) do
- @allocation = described_class.new @index, stub(:combination, :to_result => [:some_result1, :some_result2])
+ @allocation = described_class.new @index, stub(:combination, :empty? => false, :to_result => [:some_result1, :some_result2])
@allocation.instance_variable_set :@score, :some_score
end
it 'should output the correct json string' do
@backend.stub! :ids => [1,2,3,4,5,6,7]
\ No newline at end of file