factor out shared context for specs which needs a depot
[coquelicot.git] / spec / spec_helper.rb
index 369e923..adb946f 100644 (file)
@@ -24,3 +24,23 @@ require 'rack/test'
 require 'rspec'
 
 require 'coquelicot'
+
+shared_context 'with Coquelicot::Application' do
+  def app
+    Coquelicot::Application
+  end
+
+  before do
+    app.set :environment, :test
+  end
+
+  around(:each) do |example|
+    path = Dir.mktmpdir('coquelicot')
+    begin
+      app.set :depot_path, path
+      example.run
+    ensure
+      FileUtils.remove_entry_secure path
+    end
+  end
+end