Skip to content

Commit

Permalink
Add preflight check for Toolbelt (CLI)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmayer committed Nov 13, 2012
1 parent af68e72 commit e5b537f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Thumbs.db
tmp
.idea/**
*.swp
.rspec
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
heroku_san (4.0.1)
heroku_san (4.0.2)
activesupport
heroku-api (>= 0.1.2)
rake
Expand Down Expand Up @@ -60,8 +60,8 @@ GEM
git-smart (0.1.9)
colorize
godot (0.1.0)
heroku-api (0.3.5)
excon (~> 0.16.1)
heroku-api (0.3.6)
excon (~> 0.16.7)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ task :default => :spec
desc "Run all specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = 'spec/**/*_spec.rb'
t.rspec_opts = ["-c", "-f progress"]
end
5 changes: 5 additions & 0 deletions lib/heroku_san/stage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,17 @@ def auth_token
end

def sh_heroku(*command)
preflight_check_for_cli
cmd = (command + ['--app', app]).compact
show_command = cmd.join(' ')
$stderr.puts show_command if @debug
ok = system "heroku", *cmd
status = $?
ok or fail "Command failed with status (#{status.exitstatus}): [heroku #{show_command}]"
end

def preflight_check_for_cli
raise "The Heroku Toolbelt is required for this action. http://toolbelt.heroku.com" if system('heroku version') == nil
end
end
end
3 changes: 3 additions & 0 deletions spec/heroku_san/stage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
include Git
subject { HerokuSan::Stage.new('production', {"app" => "awesomeapp", "stack" => "cedar"})}
STOCK_CONFIG = {"BUNDLE_WITHOUT"=>"development:test", "LANG"=>"en_US.UTF-8", "RACK_ENV"=>"production"}
before do
HerokuSan::Stage.any_instance.stub(:preflight_check_for_cli)
end

context "initializes" do
subject { HerokuSan::Stage.new('production',
Expand Down

0 comments on commit e5b537f

Please sign in to comment.