diff --git a/.gitignore b/.gitignore index e74bf5c..94739bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# ignore test directories +spec/index_dir/* + # rcov generated coverage diff --git a/lib/polecat/index.rb b/lib/polecat/index.rb index 9311b4a..a906c04 100644 --- a/lib/polecat/index.rb +++ b/lib/polecat/index.rb @@ -16,7 +16,7 @@ class Polecat # returns true, if it has an index def index_dir? - false + File.exists?(@path + '/index.txt') end def write term diff --git a/spec/index_spec.rb b/spec/index_spec.rb index a05139a..71708f5 100644 --- a/spec/index_spec.rb +++ b/spec/index_spec.rb @@ -29,7 +29,11 @@ describe "Index" do i.index_dir?.should == false end - it "returns true, if the directory contains an index" + it "returns true, if the directory contains an index" do + i = Polecat::Index.new @path + i.write 'foo' + i.index_dir?.should == true + end end describe "#write" do @@ -63,5 +67,12 @@ describe "Index" do i.write "foo" i.search("foo").should == 0 end + + it "returns nil, when no match was found" do + i = Polecat::Index.new @path + i.write "foo" + i.write "bar" + i.search("baz").should == nil + end end end