2011-01-28 23:46:47 +00:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 07:48:56 +00:00
|
|
|
require 'rubygems/gem_runner'
|
|
|
|
|
2011-01-28 23:46:47 +00:00
|
|
|
class TestGemGemRunner < Gem::TestCase
|
2007-11-10 07:48:56 +00:00
|
|
|
|
2012-11-29 06:52:18 +00:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@orig_args = Gem::Command.build_args
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
|
|
|
|
|
|
|
Gem::Command.build_args = @orig_args
|
|
|
|
end
|
|
|
|
|
2007-11-10 07:48:56 +00:00
|
|
|
def test_do_configuration
|
|
|
|
Gem.clear_paths
|
|
|
|
|
|
|
|
temp_conf = File.join @tempdir, '.gemrc'
|
|
|
|
|
|
|
|
other_gem_path = File.join @tempdir, 'other_gem_path'
|
|
|
|
other_gem_home = File.join @tempdir, 'other_gem_home'
|
|
|
|
|
|
|
|
Gem.ensure_gem_subdirectories other_gem_path
|
|
|
|
Gem.ensure_gem_subdirectories other_gem_home
|
|
|
|
|
|
|
|
File.open temp_conf, 'w' do |fp|
|
|
|
|
fp.puts "gem: --commands"
|
|
|
|
fp.puts "gemhome: #{other_gem_home}"
|
|
|
|
fp.puts "gempath:"
|
|
|
|
fp.puts " - #{other_gem_path}"
|
|
|
|
fp.puts "rdoc: --all"
|
|
|
|
end
|
|
|
|
|
|
|
|
gr = Gem::GemRunner.new
|
|
|
|
gr.send :do_configuration, %W[--config-file #{temp_conf}]
|
|
|
|
|
2012-11-29 06:52:18 +00:00
|
|
|
assert_equal [other_gem_path, other_gem_home], Gem.path
|
2007-11-10 07:48:56 +00:00
|
|
|
assert_equal %w[--commands], Gem::Command.extra_args
|
|
|
|
end
|
|
|
|
|
2012-11-29 06:52:18 +00:00
|
|
|
def test_build_args_are_handled
|
2009-06-09 21:38:59 +00:00
|
|
|
Gem.clear_paths
|
|
|
|
|
2012-11-29 06:52:18 +00:00
|
|
|
cls = Class.new(Gem::Command) do
|
|
|
|
def execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test_obj = cls.new :ba_test
|
|
|
|
|
|
|
|
cmds = Gem::CommandManager.new
|
|
|
|
cmds.register_command :ba_test, test_obj
|
|
|
|
|
|
|
|
runner = Gem::GemRunner.new :command_manager => cmds
|
|
|
|
runner.run(%W[ba_test -- --build_arg1 --build_arg2])
|
2009-06-09 21:38:59 +00:00
|
|
|
|
2012-11-29 06:52:18 +00:00
|
|
|
assert_equal %w[--build_arg1 --build_arg2], test_obj.options[:build_args]
|
2009-06-09 21:38:59 +00:00
|
|
|
end
|
|
|
|
|
2007-11-10 07:48:56 +00:00
|
|
|
end
|
|
|
|
|