Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add kumade:pre_deploy rake hook

  • Loading branch information...
commit 8bd28248dbff28d83be596d42000e1500f2e52f5 1 parent 769e80d
@joshuaclayton joshuaclayton authored
View
21 features/rake_task_pre_deploy.feature
@@ -0,0 +1,21 @@
+@slow
+Feature: Rake task that always runs during pre deploy
+ As a user
+ I want a Rake task that runs before deployment
+ So that I can hook into the deployment process
+
+ Scenario: Pre-deploy task runs during deployment
+ Given a new Rails application with Kumade and Jammit
+ When I create a Heroku remote named "pretend-staging"
+ And I add a pre-deploy rake task that prints "Hi!"
+ And I run kumade with "pretend-staging"
+ Then the output should contain "kumade:pre_deploy"
+ And the output should contain "Hi!"
+
+ Scenario: Pre-deploy task does not run when pretending
+ Given a new Rails application with Kumade and Jammit
+ When I create a Heroku remote named "pretend-staging"
+ And I add a pre-deploy rake task that prints "Hi!"
+ And I run kumade with "pretend-staging -p"
+ Then the output should contain "kumade:pre_deploy"
+ But the output should not contain "Hi!"
View
12 features/step_definitions/rake_steps.rb
@@ -36,3 +36,15 @@
commit_everything_in_repo
end
+
+When /^I add a pre-deploy rake task that prints "Hi!"$/ do
+ append_to_file("Rakefile", <<-CUSTOM_TASK)
+ namespace :kumade do
+ task :pre_deploy do
+ puts 'Hi!'
+ end
+ end
+ CUSTOM_TASK
+
+ commit_everything_in_repo
+end
View
7 lib/kumade/deployer.rb
@@ -28,6 +28,7 @@ def deploy
def pre_deploy
ensure_clean_git
+ run_predeploy_task
package_assets
sync_origin
end
@@ -59,5 +60,11 @@ def ensure_heroku_remote_exists
Kumade.configuration.outputter.error(%{Cannot deploy: "#{Kumade.configuration.environment}" remote does not exist})
end
end
+
+ private
+
+ def run_predeploy_task
+ RakeTaskRunner.new("kumade:pre_deploy").invoke
+ end
end
end
View
16 spec/kumade/deployer_spec.rb
@@ -1,7 +1,14 @@
require 'spec_helper'
describe Kumade::Deployer, "#pre_deploy", :with_mock_outputter do
- let(:git) { subject.git }
+ let(:git) { subject.git }
+ let(:rake_task_runner) { stub("RakeTaskRunner", :invoke => true) }
+ let(:packager) { stub("packager", :run => true) }
+
+ before do
+ Kumade::Packager.stubs(:new => packager)
+ Kumade::RakeTaskRunner.stubs(:new).with("kumade:pre_deploy").returns(rake_task_runner)
+ end
it "calls the correct methods" do
git.expects(:ensure_clean_git)
@@ -10,6 +17,13 @@
subject.pre_deploy
end
+
+ it "invokes the kumade:pre_deploy task" do
+ subject.pre_deploy
+
+ Kumade::RakeTaskRunner.should have_received(:new).with("kumade:pre_deploy")
+ rake_task_runner.should have_received(:invoke)
+ end
end
describe Kumade::Deployer, "#deploy", :with_mock_outputter do
Please sign in to comment.
Something went wrong with that request. Please try again.