From 43dfbbd92d421882a678ede558ab485cf80f7d9f Mon Sep 17 00:00:00 2001 From: Jon Yurek Date: Wed, 27 Oct 2010 17:37:59 -0400 Subject: [PATCH] Fakes out the heroku command for cucumber. --- features/step_definitions/rails_application_steps.rb | 12 +++++++++++- features/support/terminal.rb | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/features/step_definitions/rails_application_steps.rb b/features/step_definitions/rails_application_steps.rb index 5ccd715..d161440 100644 --- a/features/step_definitions/rails_application_steps.rb +++ b/features/step_definitions/rails_application_steps.rb @@ -294,7 +294,17 @@ def rails_non_initializer_hoptoad_config_file end When /^I configure the Heroku gem shim with "([^\"]*)"$/ do |api_key| - HoptoadGenerator.any_instance.stubs(:heroku_api_key).with(api_key) + heroku_script_bin = File.join(TEMP_DIR, "bin") + FileUtils.mkdir_p(heroku_script_bin) + heroku_script = File.join(heroku_script_bin, "heroku") + File.open(heroku_script, "w") do |f| + f.puts "#!/bin/sh" + f.puts "if [[ $1 == 'console' && $2 == 'puts ENV[%{HOPTOAD_API_KEY}]' ]]; then" + f.puts " echo #{api_key}" + f.puts "fi" + end + FileUtils.chmod(0755, heroku_script) + @terminal.prepend_path(heroku_script_bin) end When /^I configure the application to filter parameter "([^\"]*)"$/ do |parameter| diff --git a/features/support/terminal.rb b/features/support/terminal.rb index 125ee27..b38fe1e 100644 --- a/features/support/terminal.rb +++ b/features/support/terminal.rb @@ -32,7 +32,8 @@ def run(command) output << "#{command}\n" FileUtils.cd(@cwd) do - cmdline = "#{environment_settings} #{command} 2>&1" + # The ; forces ruby to shell out so the env settings work right + cmdline = "#{environment_settings} #{command} 2>&1 ; " logger.debug(cmdline) result = `#{cmdline}` logger.debug(result) @@ -74,6 +75,10 @@ def uninstall_gem(gem) `gem uninstall -i #{BUILT_GEM_ROOT} #{gem}` end + def prepend_path(path) + @environment_variables['PATH'] = path + ":" + @environment_variables['PATH'] + end + private def install_gem_to(root, gem)