diff options
author | elijah <elijah@riseup.net> | 2016-10-05 14:35:56 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2016-10-05 14:35:56 -0700 |
commit | 7abfbd6abae14fa6a72350f7b75268ff561354ee (patch) | |
tree | af5c969c905a8d2a95f2b2aa7c4dd6f4b8763126 /test/test_helper.rb | |
parent | cc57bc6c0ff99d88f3bfeff1b04297e9b91e6988 (diff) | |
parent | f95e08ef7d8defbde4a19e138b1ac4ebc9677669 (diff) |
Merge branch 'develop'
# Conflicts:
# lib/leap_cli/version.rb
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r-- | test/test_helper.rb | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index f7ec6d9..cd856a3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,6 +7,7 @@ require 'gli' require 'fileutils' DEBUG = true +TEST = true module LeapCli::Commands extend GLI::App @@ -19,7 +20,7 @@ class Minitest::Test def initialize(*args) super(*args) - LeapCli::Bootstrap::setup([], test_provider_path) + LeapCli::Bootstrap::setup([], provider_path) LeapCli::Bootstrap::load_libraries(LeapCli::Commands) end @@ -43,33 +44,56 @@ class Minitest::Test end def leap_bin(*args) - `cd #{test_provider_path} && #{ruby_path} #{base_path}/bin/leap --no-color #{args.join ' '}` + cmd = "cd #{provider_path} && PLATFORM_DIR=#{platform_path} #{base_path}/bin/leap --debug --yes --no-color #{args.join ' '}" + `#{cmd}` end - def test_provider_path + def leap_bin!(*args) + output = leap_bin(*args) + exit_code = $? + assert_equal 0, exit_code, + "The command `leap #{args.join(' ')}` should have exited 0 " + + "(was #{exit_code}).\n" + + "Output was: #{output}" + output + end + + def provider_path "#{base_path}/test/provider" end + # + # for tests, we assume that the leap_platform code is + # in a sister directory to leap_cli. + # + def platform_path + ENV['PLATFORM_DIR'] || "#{base_path}/../leap_platform" + end + def cleanup_files(*args) - Dir.chdir(test_provider_path) do + Dir.chdir(provider_path) do args.each do |file| FileUtils.rm_r(file) if File.exist?(file) end end end + # + # we no longer support ruby 1.8, but this might be useful in the future + # def with_multiple_rubies(&block) - if ENV["RUBY"] - ENV["RUBY"].split(',').each do |ruby| - self.ruby_path = `which #{ruby}`.strip - next unless ruby_path.chars.any? - yield - end - else - self.ruby_path = `which ruby`.strip - yield - end - self.ruby_path = "" + yield + # if ENV["RUBY"] + # ENV["RUBY"].split(',').each do |ruby| + # self.ruby_path = `which #{ruby}`.strip + # next unless ruby_path.chars.any? + # yield + # end + # else + # self.ruby_path = `which ruby`.strip + # yield + # end + # self.ruby_path = "" end end |