diff options
Diffstat (limited to 'test/rubygems/test_gem_commands_install_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_install_command.rb | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index caf52f147d..f86d2837ea 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -6,7 +6,6 @@ class TestGemCommandsInstallCommand < Gem::TestCase def setup super - common_installer_setup @cmd = Gem::Commands::InstallCommand.new @cmd.options[:document] = [] @@ -169,7 +168,8 @@ class TestGemCommandsInstallCommand < Gem::TestCase # This is needed because we need to exercise the cache path # within SpecFetcher - path = File.join Gem.spec_cache_dir, "not-there.nothing%80", "latest_specs.4.8" + path = File.join Gem.user_home, '.gem', 'specs', "not-there.nothing%80", + "latest_specs.4.8" FileUtils.mkdir_p File.dirname(path) @@ -633,6 +633,67 @@ ERROR: Possible alternatives: non_existent_with_hint assert_equal x, e end + def test_execute_installs_dependencies + r, r_gem = util_gem 'r', '1', 'q' => '= 1' + q, q_gem = util_gem 'q', '1' + + util_setup_fake_fetcher + util_setup_spec_fetcher r, q + + Gem::Specification.reset + + @fetcher.data["#{@gem_repo}gems/#{q.file_name}"] = read_binary(q_gem) + @fetcher.data["#{@gem_repo}gems/#{r.file_name}"] = read_binary(r_gem) + + @cmd.options[:args] = ["r"] + + e = nil + use_ui @ui do + e = assert_raises Gem::SystemExitException do + capture_io do + @cmd.execute + end + end + end + + out = @ui.output.split "\n" + assert_equal "2 gems installed", out.shift + assert out.empty?, out.inspect + + assert_equal %w[q-1 r-1], @cmd.installed_specs.map { |spec| spec.full_name } + + assert_equal 0, e.exit_code + end + + def test_execute_satisfy_deps_of_local_from_sources + r, r_gem = util_gem 'r', '1', 'q' => '= 1' + q, q_gem = util_gem 'q', '1' + + util_setup_fake_fetcher + util_setup_spec_fetcher r, q + + Gem::Specification.reset + + @fetcher.data["#{@gem_repo}gems/#{q.file_name}"] = read_binary(q_gem) + + @cmd.options[:args] = [r_gem] + + use_ui @ui do + e = assert_raises Gem::SystemExitException do + capture_io do + @cmd.execute + end + end + assert_equal 0, e.exit_code + end + + assert_equal %w[q-1 r-1], @cmd.installed_specs.map { |spec| spec.full_name } + + out = @ui.output.split "\n" + assert_equal "2 gems installed", out.shift + assert out.empty?, out.inspect + end + def test_execute_uses_from_a_gemdeps util_setup_fake_fetcher util_setup_spec_fetcher @@ -890,3 +951,4 @@ ERROR: Possible alternatives: non_existent_with_hint end + |