fixed a bug in IndexReader#read which returned a hash instead of an
array
This commit is contained in:
parent
3e12494e44
commit
9a1c4eff90
|
@ -29,8 +29,9 @@ class Polecat
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
documents += Marshal.load(File.read(file))
|
documents += Marshal.load(File.read(file))
|
||||||
end
|
end
|
||||||
|
documents
|
||||||
else
|
else
|
||||||
{}
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ describe "IndexReader#read" do
|
||||||
@path = prepare_index_dir
|
@path = prepare_index_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a hash with all documents" do
|
it "returns a array with all documents" do
|
||||||
r = Polecat::IndexReader.new @path
|
r = Polecat::IndexReader.new @path
|
||||||
r.read.class.should == Hash
|
r.read.class.should == Array
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an empty hash for a empty directory" do
|
it "returns an empty hash for a empty directory" do
|
||||||
|
@ -23,6 +23,13 @@ describe "IndexReader#read" do
|
||||||
r.read.count.should == 1
|
r.read.count.should == 1
|
||||||
end
|
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
|
it "merges all documents from different files together" do
|
||||||
w = Polecat::IndexWriter.new @path
|
w = Polecat::IndexWriter.new @path
|
||||||
w.add Spec::FooDocument.new(:id => 23)
|
w.add Spec::FooDocument.new(:id => 23)
|
||||||
|
|
Loading…
Reference in New Issue