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

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix issue #38
  • Loading branch information
tapajos authored and Gabe Berke-Williams committed Sep 10, 2011
1 parent 2879fbc commit 645014c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/kumade/deployer.rb
@@ -1,4 +1,5 @@
require "rake"
require 'cocaine'

module Kumade
class Deployer < Base
Expand Down Expand Up @@ -58,11 +59,10 @@ def heroku(command)
run_or_error("#{heroku_command} #{command} --remote #{environment}",
"Failed to run #{command} on Heroku")
end

def cedar?
return @cedar unless @cedar.nil?

@cedar = heroku("stack").split("\n").grep(/\*/).any? do |line|
@cedar = Cocaine::CommandLine.new("bundle exec heroku stack --remote #{environment}").run.split("\n").grep(/\*/).any? do |line|
line.include?("cedar")
end
end
Expand Down
24 changes: 20 additions & 4 deletions spec/kumade/deployer_spec.rb
Expand Up @@ -438,16 +438,32 @@ class More
end

describe Kumade::Deployer, "#cedar?" do
let(:cocaine_mock) { mock("Cocaine::CommandLine") }
before { Cocaine::CommandLine.should_receive(:new).with("bundle exec heroku stack --remote staging").and_return(cocaine_mock) }
context "when on Cedar" do
subject { Kumade::Deployer.new('staging', false) }
before { subject.stub(:heroku).and_return(" bamboo\n* cedar\n") }
its(:cedar?) { should be_true }
it "should be true" do
cocaine_mock.should_receive(:run).and_return(%{
aspen-mri-1.8.6
bamboo-mri-1.9.2
bamboo-ree-1.8.7
* cedar (beta)
})
subject.cedar?.should be_true
end
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 }
it "should be false" do
cocaine_mock.should_receive(:run).and_return(%{
aspen-mri-1.8.6
* bamboo-mri-1.9.2
bamboo-ree-1.8.7
cedar (beta)
})
subject.cedar?.should be_false
end
end
end

Expand Down

0 comments on commit 645014c

Please sign in to comment.