specify and implement behaviour of Depot#file_exists? when there is a link with no...
authorLunar <lunar@anargeek.net>
Tue, 6 Mar 2012 15:41:51 +0000 (16:41 +0100)
committerLunar <lunar@anargeek.net>
Fri, 23 Mar 2012 17:11:29 +0000 (18:11 +0100)
lib/coquelicot/depot.rb
spec/coquelicot/depot_spec.rb

index 38aa7f8..31f4e3c 100644 (file)
@@ -59,7 +59,7 @@ module Coquelicot
     def file_exists?(link)
       lockfile.lock do
         name = read_link(link)
-        return !name.nil?
+        return name && File.exists?(full_path(name))
       end
     end
 
index d9e7a8e..ee16231 100644 (file)
@@ -167,7 +167,13 @@ module Coquelicot
         it { should be_true }
       end
       context 'when there is a link with no matching file' do
-        it 'should not be true'
+        before(:each) do
+          depot.should_receive(:gen_random_file_name).
+            and_return('file', 'link')
+          add_file
+          File.unlink File.expand_path('file', @tmpdir)
+        end
+        it { should_not be_true }
       end
     end