0
0
Fork 0

fixed a bug in IndexReader#read which returned a hash instead of an

array
This commit is contained in:
Gibheer 2011-05-30 22:22:52 +02:00
parent 3e12494e44
commit 9a1c4eff90
2 changed files with 11 additions and 3 deletions

View File

@ -29,8 +29,9 @@ class Polecat
files.each do |file|
documents += Marshal.load(File.read(file))
end
documents
else
{}
[]
end
end

View File

@ -5,9 +5,9 @@ describe "IndexReader#read" do
@path = prepare_index_dir
end
it "returns a hash with all documents" do
it "returns a array with all documents" do
r = Polecat::IndexReader.new @path
r.read.class.should == Hash
r.read.class.should == Array
end
it "returns an empty hash for a empty directory" do
@ -23,6 +23,13 @@ describe "IndexReader#read" do
r.read.count.should == 1
end
it "returns an array of documents" do
w = Polecat::IndexWriter.new @path
w.add Spec::FooDocument.new(:id => 23)
w.write
w.create_reader.read[0].kind_of?(Polecat::Document).should == true
end
it "merges all documents from different files together" do
w = Polecat::IndexWriter.new @path
w.add Spec::FooDocument.new(:id => 23)