Skip to content
Browse files

Initial thor work

  • Loading branch information...
1 parent df75d58 commit fffa96bdabd64739c117bcfe2bc7275157332420 @gabebw gabebw committed Jul 28, 2011
View
5 bin/kumade
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require 'kumade'
+
+Kumade::ThorTask.start
View
32 features/kumade_executable.feature
@@ -0,0 +1,32 @@
+Feature: Kumade executable
+ As a user
+ I want to be able to use the kumade executable
+ So I can have a better experience than Rake provides
+
+ Background:
+ Given a directory named "executable"
+ And I cd to "executable"
+
+ Scenario: Pretend mode
+ When I run `kumade -p`
+ Then the output should contain "In Pretend Mode"
+
+ Scenario: Default environment is staging
+ When I run `kumade -p`
+ Then the output should contain "==> Deploying to: staging"
+ And the output should contain "==> Deployed to: staging"
+
+ Scenario: Can deploy to staging
+ When I run `kumade deploy staging -p`
+ Then the output should contain "==> Deploying to: staging"
+ And the output should contain "==> Deployed to: staging"
+
+ Scenario: Can deploy to production
+ When I run `kumade deploy production -p`
+ Then the output should contain "==> Deploying to: production"
+ And the output should contain "==> Deployed to: production"
+
+ Scenario: Cannot deploy to arbitrary environment
+ When I run `kumade deploy bamboo -p`
+ Then the output should contain "==> Deploying to: bamboo"
+ And the output should contain "==> Cannot deploy: env must be either staging or production"
View
3 features/step_definitions/dependency_steps.rb
@@ -0,0 +1,3 @@
+When /^I add "([^"]*)" from this project as a dependency$/ do |gem_name|
+ append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "#{PROJECT_ROOT}"})
+end
View
1 kumade.gemspec
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.add_dependency('heroku')
+ s.add_dependency('thor', '~> 0.14')
s.add_development_dependency('rake', '~> 0.8.7')
s.add_development_dependency('rspec', '~> 2.6.0')
View
1 lib/kumade.rb
@@ -1,4 +1,5 @@
require 'kumade/deployer'
+require 'kumade/thor_task'
class Kumade
def self.load_tasks
View
29 lib/kumade/thor_task.rb
@@ -0,0 +1,29 @@
+require 'thor'
+
+class Kumade
+ class ThorTask < Thor
+ default_task :deploy
+
+ desc "deploy [ENV]", "Deploy to ENV (default: staging)"
+ method_option :pretend, :aliases => "-p", :desc => "Pretend Mode - print out what kumade would do"
+ def deploy(environment = 'staging')
+ say("==> In Pretend Mode", :red) if options[:pretend]
+ say "==> Deploying to: #{environment}"
+
+ case environment
+ when 'staging'
+ unless options[:pretend]
+ Kumade.deployer.deploy_to_staging
+ end
+ say "==> Deployed to: staging", :green
+ when 'production'
+ unless options[:pretend]
+ Kumade.deployer.deploy_to_production
+ end
+ say "==> Deployed to: production", :green
+ else
+ say "==> Cannot deploy: env must be either staging or production"
+ end
+ end
+ end
+end
View
17 spec/thor_task_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+class Kumade
+ describe ThorTask, "deploy" do
+ before { subject.stub(:say) }
+
+ it "calls the staging deploy method when called with staging" do
+ Deployer.any_instance.should_receive(:deploy_to_staging)
+ subject.deploy('staging')
+ end
+
+ it "calls the production deploy method when called with production" do
+ Deployer.any_instance.should_receive(:deploy_to_production)
+ subject.deploy('production')
+ end
+ end
+end

0 comments on commit fffa96b

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