Skip to content
Browse files

Spec for shared folder task. New gem dependency on fakefs

  • Loading branch information...
1 parent d68df27 commit 3d30d8a1a64cc6b51a6b9e8b3b1ee966b1d18d6b @peterjmit peterjmit committed
Showing with 49 additions and 0 deletions.
  1. +1 −0 .gemfile
  2. +1 −0 lib/capifony_symfony2.rb
  3. +39 −0 spec/capifony_symfony2_shared_spec.rb
  4. +8 −0 spec/spec_helper.rb
View
1 .gemfile
@@ -5,3 +5,4 @@ gemspec
gem 'rake'
gem 'rspec'
gem 'capistrano-spec', :git => 'git://github.com/mydrive/capistrano-spec.git'
+gem 'fakefs', :require => 'fakefs/safe'
View
1 lib/capifony_symfony2.rb
@@ -21,6 +21,7 @@ def self.load_into(configuration)
load 'symfony2/doctrine'
load 'symfony2/propel'
load 'symfony2/web'
+ load 'symfony2/shared'
# Symfony application path
set :app_path, "app"
View
39 spec/capifony_symfony2_shared_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+require 'fakefs/safe'
+
+describe "Capifony::Symfony2 - shared" do
+ before do
+ @configuration = Capistrano::Configuration.new
+ @configuration.extend(Capistrano::Spec::ConfigurationExtension)
+
+ @configuration.set :application, 'test-app'
+ @configuration.set :latest_release, '/var/www/releases/20120927'
+ @configuration.set :previous_release, '/var/www/releases/20120920'
+ @configuration.set :current_path, '/var/www/current'
+ @configuration.set :shared_path, '/var/www/shared'
+ @configuration.set :remote_tmp_dir, '/tmp'
+ @configuration.set :maintenance_basename, 'maintenance'
+ @configuration.set :try_sudo, ''
+
+ Capifony::Symfony2.load_into(@configuration)
+ end
+
+ subject { @configuration }
+
+ it "defines shared folder tasks" do
+ @configuration.find_task('shared:folder:download').should_not == nil
+ end
+
+ context "when runnning shared:folder:download", fakefs: true do
+ before do
+ @configuration.find_and_execute_task('shared:folder:download')
+ @filename = "test-app.remote_shared.#{Time.now.utc.strftime("%Y%m%d%H%M%S")}.tar.gz"
+ @file = "/tmp/#{@filename}"
+ end
+
+ it { should have_run(" sh -c \'cd /var/www/shared; tar -zcvf #{@file} --exclude=\'cached-copy\' .\'") }
+ it { should have_gotten("#{@file}").to("backups/#{@filename}") }
+ it { should have_run(" rm -f #{@file}") }
+ end
+end
View
8 spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'bundler/setup'
+require 'fakefs/spec_helpers'
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -12,6 +13,7 @@
RSpec.configure do |config|
config.include Capistrano::Spec::Matchers
config.include Capistrano::Spec::Helpers
+ config.include FakeFS::SpecHelpers, fakefs: true
end
require 'capifony_symfony2'
@@ -22,3 +24,9 @@ def capifony_pretty_print(msg)
def capifony_puts_ok
end
+
+def capifony_progress_start(msg = '')
+end
+
+def capifony_progress_update(sent, total)
+end

0 comments on commit 3d30d8a

Please sign in to comment.
Something went wrong with that request. Please try again.