properly delete file in case of errors in StoredFile.create
[coquelicot.git] / spec / coquelicot / stored_file_spec.rb
index 1b701ba..eff5981 100644 (file)
@@ -209,7 +209,17 @@ module Coquelicot
         end
       end
       context 'when the given block raise an error' do
-        it 'should not create a file'
+        it 'should not create a file' do
+          path = File.expand_path('stored_file', @tmpdir)
+          begin
+            StoredFile.create(path, 'secret', {}) do
+              raise StandardError.new
+            end
+          rescue StandardError
+            # that was expected!
+          end
+          File.should_not exist(path)
+        end
       end
     end