Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial thor work

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

0 comments on commit fffa96b

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