2011-05-26 21:18:46 +02:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
|
|
|
|
|
|
describe "IndexWriter#add" do
|
2011-06-06 18:47:01 +02:00
|
|
|
let (:path) { prepare_index_dir }
|
|
|
|
let (:doc1) { Spec::TestDocument.new :id => 1 }
|
|
|
|
let (:doc2) { Spec::TestDocument.new :id => 2 }
|
|
|
|
let (:w) { w = Polecat::IndexWriter.new path }
|
2011-05-26 21:18:46 +02:00
|
|
|
|
|
|
|
it "adds the object to the list of objects" do
|
2011-06-06 18:47:01 +02:00
|
|
|
w.add doc1
|
2011-05-26 21:18:46 +02:00
|
|
|
w.count.should == 1
|
|
|
|
end
|
|
|
|
|
2011-06-09 21:27:32 +02:00
|
|
|
it "takes multiple documents and stores them" do
|
2011-06-06 18:47:01 +02:00
|
|
|
w.add doc1
|
|
|
|
w.add doc2
|
|
|
|
w.count.should == 2
|
|
|
|
end
|
|
|
|
|
2011-05-26 21:18:46 +02:00
|
|
|
it "raises an error, when the object is not a document" do
|
2011-06-06 18:47:01 +02:00
|
|
|
lambda { Polecat::IndexWriter.new(path).add "foo" }.should(
|
2011-05-26 21:18:46 +02:00
|
|
|
raise_error(ArgumentError))
|
|
|
|
end
|
|
|
|
end
|