use an around block instead of before/after to create temporary depot in specs
authorLunar <lunar@anargeek.net>
Mon, 13 Feb 2012 17:31:13 +0000 (18:31 +0100)
committerLunar <lunar@anargeek.net>
Tue, 14 Feb 2012 17:38:58 +0000 (18:38 +0100)
spec/coquelicot_spec.rb

index 09a5448..279fa3a 100644 (file)
@@ -39,12 +39,16 @@ describe 'Coquelicot' do
     app.set :upload_password, Digest::SHA1.hexdigest(UPLOAD_PASSWORD)
 
     app.set :environment, :test
-
-    app.set :depot_path, Dir.mktmpdir('coquelicot')
   end
 
-  after do
-    FileUtils.remove_entry_secure Coquelicot.depot.path
+  around(:each) do |example|
+    path = Dir.mktmpdir('coquelicot')
+    begin
+      app.set :depot_path, path
+      example.run
+    ensure
+      FileUtils.remove_entry_secure Coquelicot.depot.path
+    end
   end
 
   it "should offer an upload form" do