factor out shared context for specs which needs a depot
authorLunar <lunar@anargeek.net>
Mon, 12 Mar 2012 15:42:06 +0000 (16:42 +0100)
committerLunar <lunar@anargeek.net>
Fri, 23 Mar 2012 17:11:29 +0000 (18:11 +0100)
spec/coquelicot_spec.rb
spec/spec_helper.rb

index f8bcb10..9fd42ca 100644 (file)
@@ -25,9 +25,7 @@ UPLOAD_PASSWORD = 'secret'
 describe 'Coquelicot' do
   include Rack::Test::Methods
 
-  def app
-    Coquelicot::Application
-  end
+  include_context 'with Coquelicot::Application'
 
   def upload(opts={})
     opts = { :file => Rack::Test::UploadedFile.new(__FILE__, 'text/x-script.ruby'),
@@ -42,20 +40,6 @@ describe 'Coquelicot' do
              select { |h| h.start_with? "http://#{last_request.host}/" }[0]
   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 Coquelicot.depot.path
-    end
-  end
-
   it "should offer an upload form" do
     get '/'
     last_response.should be_ok
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