From e5b537f4c2a0eb9cc91e3579d25b68ac11895cc8 Mon Sep 17 00:00:00 2001 From: Kenneth Mayer Date: Tue, 13 Nov 2012 08:32:19 -0800 Subject: [PATCH] Add preflight check for Toolbelt (CLI) --- .gitignore | 1 + Gemfile.lock | 6 +++--- Rakefile | 1 - lib/heroku_san/stage.rb | 5 +++++ spec/heroku_san/stage_spec.rb | 3 +++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 758ed45..6fbcfa4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Thumbs.db tmp .idea/** *.swp +.rspec diff --git a/Gemfile.lock b/Gemfile.lock index 3d72f90..800ef10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - heroku_san (4.0.1) + heroku_san (4.0.2) activesupport heroku-api (>= 0.1.2) rake @@ -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) diff --git a/Rakefile b/Rakefile index 95392b6..0a8becb 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/lib/heroku_san/stage.rb b/lib/heroku_san/stage.rb index eaebc86..6ca1cf6 100644 --- a/lib/heroku_san/stage.rb +++ b/lib/heroku_san/stage.rb @@ -139,6 +139,7 @@ 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 @@ -146,5 +147,9 @@ def sh_heroku(*command) 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 diff --git a/spec/heroku_san/stage_spec.rb b/spec/heroku_san/stage_spec.rb index 7ca41c5..359102c 100644 --- a/spec/heroku_san/stage_spec.rb +++ b/spec/heroku_san/stage_spec.rb @@ -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',