Skip to content

Commit

Permalink
GREEN build
Browse files Browse the repository at this point in the history
  • Loading branch information
kmayer committed Mar 13, 2016
1 parent 47612a9 commit 4b008c5
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 254 deletions.
32 changes: 8 additions & 24 deletions features/shell_execution.feature
@@ -1,45 +1,29 @@
@slow_process @announce-cmd
Feature: heroku_san can shell out to heroku without errors

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

And I run `gem install bundler`
And I run bundle install
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('any_app_name', 'auth:whoami')
"""
And I write to "run_in_ruby_2.sh" with:
"""
#!/usr/bin/env bash
rbenv local 2.2.4
bundle install
ruby get_heroku_version.rb
api.sh(nil, 'status')
"""
And I run `chmod +x run_in_ruby_2.sh`
And I cleanly run `./run_in_ruby_2.sh`
And I run `chmod +x get_heroku_version.rb`
And I cleanly run `bundle exec ruby ./get_heroku_version.rb`
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"
Then the output should contain "Production"
Then the output should contain "Development"

7 changes: 4 additions & 3 deletions features/step_definitions/remote_steps.rb
@@ -1,6 +1,7 @@
World(Aruba::Api)
require 'active_support/core_ext/string/strip'
require 'godot'
require 'bundler'

Given /^I have a new Rails project$/ do
cmd = "rails new test_app --quiet --force --skip-bundle --skip-javascript --skip-test-unit --skip-sprockets"
Expand Down Expand Up @@ -191,7 +192,7 @@ def run_clean(cmd)
end
output = run_clean 'rake heroku:apps'
assert_partial_output "test_app is shorthand for the Heroku app #{@app} located at:", output
assert_partial_output "git@heroku.com:#{@app}.git", output
assert_partial_output "https://git.heroku.com/#{@app}.git", output
assert_partial_output "@ #{sha} master", output
end

Expand All @@ -200,13 +201,13 @@ def run_clean(cmd)
test_app:
app: #{@app}
addons:
- heroku-postgresql:hobby-dev
- deployhooks:email
END_CONFIG

output = run_clean 'rake test_app heroku:addons'
# The output should show the new one ...
assert_partial_output "heroku-postgresql:hobby-dev", output
assert_partial_output "deployhooks:email", output
end

Then /^(?:heroku_san|issue \d+) (?:is green|has been fixed)$/ do
Expand Down
7 changes: 5 additions & 2 deletions lib/heroku_san/api.rb
@@ -1,4 +1,5 @@
require 'time'
require 'bundler'

module HerokuSan
class API
Expand All @@ -9,12 +10,14 @@ def initialize(options = {})
def sh(app, *command)
preflight_check_for_cli

cmd = (command + ['--app', app, "--exit-code"]).compact
cmd = command
cmd << ['--app', app] if app
cmd << '--exit-code' if command.first == 'run'

show_command = cmd.join(' ')
$stderr.puts show_command if @debug

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

status = $?
ok or fail "Command failed with status (#{status.exitstatus}): [heroku #{show_command}]"
Expand Down
2 changes: 1 addition & 1 deletion lib/heroku_san/stage.rb
Expand Up @@ -24,7 +24,7 @@ def app
end

def repo
@options['repo'] ||= "git@heroku.com:#{app}.git"
@options['repo'] ||= "https://git.heroku.com/#{app}.git"
end

def stack
Expand Down
4 changes: 2 additions & 2 deletions spec/heroku_san/git_spec.rb
Expand Up @@ -7,9 +7,9 @@ class GitTest; include HerokuSan::Git; end
describe "#git_push" do
it "pushes to heroku" do
expect(subject).to receive(:sh).with("git update-ref refs/heroku_san/deploy HEAD^{commit}")
expect(subject).to receive(:sh).with("git push git@heroku.com:awesomeapp.git refs/heroku_san/deploy:refs/heads/master")
expect(subject).to receive(:sh).with("git push https://git.heroku.com/awesomeapp.git refs/heroku_san/deploy:refs/heads/master")
expect(subject).to receive(:sh).with("git update-ref -d refs/heroku_san/deploy")
subject.git_push(nil, 'git@heroku.com:awesomeapp.git')
subject.git_push(nil, 'https://git.heroku.com/awesomeapp.git')
end

it "pushes a specific commit to heroku" do
Expand Down

0 comments on commit 4b008c5

Please sign in to comment.