Skip to content

Commit

Permalink
Merge pull request #155 from tjgrathwell/fix-for-ruby-2
Browse files Browse the repository at this point in the history
Fix issues with running Ruby 2.0.0 and using Heroku Toolbelt
  • Loading branch information
kmayer committed Oct 22, 2013
2 parents 29a6d0b + 060193b commit 9a29a97
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
47 changes: 47 additions & 0 deletions features/shell_execution.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@slow_process @announce-cmd
Feature: heroku_san can shell out to heroku without errors

Scenario: Bundling a ruby 2.0 project
Given I run `mkdir -p ruby2test`
And I cd to "ruby2test"
And I write to "Gemfile" with:
"""
source "https://rubygems.org"
ruby '2.0.0'
gem 'heroku_san', :path => '../../../.'
"""

And I write to "get_heroku_version.rb" with:
"""
#!/usr/bin/env ruby
puts ENV['RUBY_VERSION']
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
require 'bundler/setup'
require 'heroku_san'
api = HerokuSan::API.new
api.sh('cool_app', 'version')
"""
And I write to "run_in_ruby_2.sh" with:
"""
#!/usr/bin/env bash
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
rvm use 2.0.0
bundle install
ruby get_heroku_version.rb
"""
And I run `chmod +x run_in_ruby_2.sh`
And I cleanly run `./run_in_ruby_2.sh`
Then the output should contain "heroku-toolbelt"
# Fail if we see "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0"
Then the output should not contain "Your Ruby version"
Then the output should not contain "your Gemfile specified"

4 changes: 4 additions & 0 deletions features/step_definitions/remote_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def run_clean(cmd)
run_clean "bundle install"
end

When /^I cleanly run `([^`]*)`$/ do |cmd|
run_clean(cmd)
end

Then /^rake reports that the heroku: tasks are available$/ do
output = run_clean 'rake -T heroku:'
assert_partial_output 'rake heroku:apps', output
Expand Down
6 changes: 3 additions & 3 deletions lib/heroku_san/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def sh(app, *command)
show_command = cmd.join(' ')
$stderr.puts show_command if @debug

ok = system "heroku", *cmd
ok = Bundler.with_clean_env { system "heroku", *cmd }

status = $?
ok or fail "Command failed with status (#{status.exitstatus}): [heroku #{show_command}]"
Expand All @@ -35,13 +35,13 @@ def method_missing(name, *args)
private

def auth_token
ENV['HEROKU_API_KEY'] || `heroku auth:token`.chomp
ENV['HEROKU_API_KEY'] || Bundler.with_clean_env { `heroku auth:token`.chomp }
rescue Errno::ENOENT
nil
end

def preflight_check_for_cli
raise "The Heroku Toolbelt is required for this action. http://toolbelt.heroku.com" if system('heroku version') == nil
raise "The Heroku Toolbelt is required for this action. http://toolbelt.heroku.com" if Bundler.with_clean_env { system('heroku version') == nil }
end
end
end

0 comments on commit 9a29a97

Please sign in to comment.