Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Use deployer's deploy_to methods and remove unused cucumber code
Browse files Browse the repository at this point in the history
  • Loading branch information
gabebw committed Jul 26, 2011
1 parent aaae7f3 commit 3dbdfd5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 170 deletions.
45 changes: 3 additions & 42 deletions features/deploying.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,19 @@ Feature: Deploying to Heroku

Background:
Given a directory named "deployer"
When I cd to "deployer"
And I write to "Gemfile" with:
"""
source "http://rubygems.org"
gem "rake", "0.8.7"
"""
And I add "kumade" from this project as a dependency
And I stub out git push
And I stub out git force push
And I cd to "deployer"
And I stub out the "staging" deploy method
And I stub out the "production" deploy method
And I load the tasks
And I initialize a git repo
And I commit everything in the current directory to git

Scenario: deploy task is an alias for deploy:staging
When I successfully run the rake task "deploy"
Then the output should contain "Force pushed master -> staging"

Scenario: Deploying to staging calls pre_deploy task
Given I stub out the "deploy:pre_deploy" task
And I successfully run the rake task "deploy:staging"
Then the output should contain "[stub] Ran deploy:pre_deploy"

Scenario: Deploying to production calls pre_deploy task
Given I stub out the "deploy:pre_deploy" task
When I successfully run the rake task "deploy:production"
Then the output should contain "[stub] Ran deploy:pre_deploy"

Scenario: Deploying to staging
When I successfully run the rake task "deploy:staging"
Then the output should contain "Force pushed master -> staging"
And the output should contain "Pushed master -> origin"

Scenario: Deploying to production
When I successfully run the rake task "deploy:production"
Then the output should contain "Force pushed master -> production"
And the output should contain "Pushed master -> origin"

Scenario: Pushing to origin fails
Given that pushing to origin fails
When I run the rake task "deploy:pre_deploy"
Then the output should contain "Failed to push master -> origin"

Scenario: Pre-deploy hook checks for clean git repo
When I append to "Rakefile" with:
"""
# Dirtying up your git repo
"""
And I run the rake task "deploy:pre_deploy"
Then the output should contain "Cannot deploy: repo is not clean"

Scenario: Pre-deploy hook checks that rake passes
When I add a failing default task
And I commit everything in the current directory to git
And I run the rake task "deploy:pre_deploy"
Then the output should contain "Cannot deploy: tests did not pass"
1 change: 0 additions & 1 deletion features/loading_tasks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Feature: Loading tasks
gem "rake", "0.8.7"
gem "kumade"
"""
And I add "kumade" from this project as a dependency
And I write to "Rakefile" with:
"""
require 'kumade'
Expand Down
4 changes: 0 additions & 4 deletions features/step_definitions/dependency_steps.rb

This file was deleted.

72 changes: 0 additions & 72 deletions features/step_definitions/git_steps.rb

This file was deleted.

3 changes: 0 additions & 3 deletions features/step_definitions/package_steps.rb

This file was deleted.

10 changes: 10 additions & 0 deletions features/step_definitions/stub_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Given /^I stub out the "([^"]+)" deploy method$/ do |environment|
append_to_file("Rakefile", <<-RAKE)
class Kumade::Deployer
def deploy_to_#{environment}
puts "Force pushed master -> #{environment}"
end
end
RAKE
end
32 changes: 0 additions & 32 deletions features/step_definitions/task_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,6 @@
}
end

When /^I add a failing default task$/ do
steps %{
When I append to "Rakefile" with:
"""
task :failing_task do
raise "I am the failboat!"
end
task :default => :failing_task
"""
}
end

When /^I successfully run the rake task "([^"]*)"$/ do |task_name|
When %{I successfully run `bundle exec rake #{task_name}`}
end

When /^I run the rake task "([^"]*)"$/ do |task_name|
When %{I run `bundle exec rake #{task_name}`}
end

Given /^I stub out the "([^"]+)" task$/ do |task_name|
insert_after_tasks_are_loaded(<<-CONTENT)
class Rake::Task
def overwrite(&block)
@actions.clear
enhance(&block)
end
end
Rake::Task['#{task_name}'].overwrite do
puts "[stub] Ran #{task_name}"
end
CONTENT
end
20 changes: 4 additions & 16 deletions lib/kumade/tasks/deploy.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,13 @@ class Kumade

namespace :deploy do
desc "Deploy to Heroku staging"
task :staging => :pre_deploy do
deployer.git_force_push('staging')
task :staging do
deployer.deploy_to_staging
end

desc "Deploy to Heroku production"
task :production => :pre_deploy do
deployer.git_force_push('production')
end

task :pre_deploy => [:clean_git, :rake_passes, :package_assets] do
deployer.git_push('origin')
end

task :clean_git do
deployer.ensure_clean_git
end

task :rake_passes do
deployer.ensure_rake_passes
task :production do
deployer.deploy_to_production
end
end
end

0 comments on commit 3dbdfd5

Please sign in to comment.