Permalink
Browse files

Remove the --cedar option, detect cedar automatically

  • Loading branch information...
1 parent 4d2b13e commit 6bd53af25329fdbb125d9ab8d3ee8ef82cd11361 @jyurek jyurek committed Sep 7, 2011
Showing with 28 additions and 22 deletions.
  1. +9 −3 lib/kumade/deployer.rb
  2. +1 −5 lib/kumade/runner.rb
  3. +18 −4 spec/kumade/deployer_spec.rb
  4. +0 −10 spec/kumade/runner_spec.rb
@@ -3,11 +3,10 @@ class Deployer < Base
DEPLOY_BRANCH = "deploy"
attr_reader :environment, :pretending, :git
- def initialize(environment = 'staging', pretending = false, cedar = false)
+ def initialize(environment = 'staging', pretending = false)
super()
@environment = environment
@pretending = pretending
- @cedar = cedar
@git = Git.new(pretending, environment)
@branch = @git.current_branch
end
@@ -45,7 +44,7 @@ def post_deploy
end
def heroku(command)
- heroku_command = if @cedar
+ heroku_command = if cedar?
"bundle exec heroku run"
else
"bundle exec heroku"
@@ -54,6 +53,13 @@ def heroku(command)
"Failed to run #{command} on Heroku")
end
+ def cedar?
+ return @cedar unless @cedar.nil?
+ heroku("stack").split("\n").grep(/\*/).any? do |line|
@tapajos
tapajos Sep 9, 2011 Contributor

Infinite loop here. Issue #38

+ line.include?("cedar")
+ end
+ end
+
def ensure_clean_git
git.ensure_clean_git
end
@@ -21,7 +21,7 @@ def self.deploy
puts "==> In Pretend Mode"
end
puts "==> Deploying to: #{environment}"
- Deployer.new(environment, pretending?, @options[:cedar]).deploy
+ Deployer.new(environment, pretending?).deploy
puts "==> Deployed to: #{environment}"
end
@@ -34,10 +34,6 @@ def self.parse_arguments!(args)
options[:pretend] = p
end
- opts.on("-c", "--cedar", "Use this if your app is on cedar") do |cedar|
- options[:cedar] = cedar
- end
-
opts.on_tail('-v', '--version', 'Show version') do
puts "kumade #{Kumade::VERSION}"
exit
@@ -435,19 +435,33 @@ class More
end
end
-describe Kumade::Deployer, "#heroku" do
+describe Kumade::Deployer, "#cedar?" do
context "when on Cedar" do
- subject { Kumade::Deployer.new('staging', false, cedar = true) }
+ subject { Kumade::Deployer.new('staging', false) }
+ before { subject.stub(:heroku).and_return(" bamboo\n* cedar\n") }
+ its(:cedar?) { should be_true }
+ end
+ context "when not on Cedar" do
+ subject { Kumade::Deployer.new('staging', false) }
+ before { subject.stub(:heroku).and_return("* bamboo\n cedar\n") }
+ its(:cedar?) { should be_false }
+ end
+end
+
+describe Kumade::Deployer, "#heroku" do
+ context "when on Cedar" do
+ subject { Kumade::Deployer.new('staging', false) }
+ before { subject.stub(:cedar?).and_return(true) }
it "runs commands with `run`" do
subject.should_receive(:run_or_error).with("bundle exec heroku run rake --remote staging", //)
subject.heroku("rake")
end
end
context "when not on Cedar" do
- subject { Kumade::Deployer.new('staging', false, cedar = false) }
-
+ subject { Kumade::Deployer.new('staging', false) }
+ before { subject.stub(:cedar?).and_return(false) }
it "runs commands without `run`" do
subject.should_receive(:run_or_error).with("bundle exec heroku rake --remote staging", //)
subject.heroku("rake")
@@ -26,16 +26,6 @@
subject.run([environment], out)
end
- %w(-c --cedar).each do |cedar_arg|
- it "uses cedar when run with #{cedar_arg}" do
- deployer = double("deployer").as_null_object
- Kumade::Deployer.should_receive(:new).
- with(anything, anything, true).
- and_return(deployer)
-
- subject.run([environment, cedar_arg], out)
- end
- end
end
describe Kumade::Runner do

0 comments on commit 6bd53af

Please sign in to comment.