aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb111
-rw-r--r--test/rubygems/test_gem_dependency_resolver_vendor_specification.rb11
-rw-r--r--test/rubygems/test_gem_request_set.rb28
-rw-r--r--test/rubygems/test_gem_source.rb10
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb18
-rw-r--r--test/rubygems/test_gem_specification.rb9
-rw-r--r--test/rubygems/test_gem_stub_specification.rb21
7 files changed, 108 insertions, 100 deletions
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index 24159e4c71..625d85e372 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -38,10 +38,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = [@a2.name]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -62,10 +61,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
assert @cmd.options[:version].satisfied_by?(@a2_pre.version)
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -83,10 +81,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code
ensure
Dir.chdir orig_dir
end
@@ -131,7 +128,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = %w[no_such_gem]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
assert_equal 2, e.exit_code
@@ -156,7 +153,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = %w[nonexistent]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
assert_equal 2, e.exit_code
@@ -184,7 +181,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = %w[nonexistent]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
assert_equal 2, e.exit_code
@@ -206,7 +203,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = [misspelled]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
@@ -230,7 +227,7 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [misspelled]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
@@ -273,10 +270,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2_pre.name]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -296,10 +292,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2_pre.name]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -319,10 +314,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2_pre.name]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -347,14 +341,12 @@ ERROR: Possible alternatives: non_existent_with_hint
begin
Dir.chdir @tempdir
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
ensure
Dir.chdir old
end
-
- assert_equal 0, e.exit_code
end
wait_for_child_process_to_exit
@@ -383,14 +375,12 @@ ERROR: Possible alternatives: non_existent_with_hint
begin
Dir.chdir @tempdir
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
ensure
Dir.chdir old
end
-
- assert_equal 0, e.exit_code
end
path = @a2.build_info_file
@@ -410,12 +400,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2.name]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -448,10 +435,9 @@ ERROR: Possible alternatives: non_existent_with_hint
use_ui @ui do
Dir.chdir @tempdir do
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code
end
end
@@ -478,10 +464,9 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
- e = assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- assert_equal 0, e.exit_code
ensure
Dir.chdir orig_dir
end
@@ -529,7 +514,7 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
- assert_raises Gem::SystemExitException do
+ assert_raises Gem::MockGemUi::SystemExitException do
@cmd.execute
end
ensure
@@ -560,7 +545,7 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
ensure
@@ -582,7 +567,7 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
- e = assert_raises Gem::SystemExitException do
+ e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
ensure
@@ -607,12 +592,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2.name]
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -639,12 +621,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -667,12 +646,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@@ -698,12 +674,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@@ -733,12 +706,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@@ -768,12 +738,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@@ -808,12 +775,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@@ -850,12 +814,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
- e = assert_raises Gem::SystemExitException do
- capture_io do
- @cmd.execute
- end
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
+ @cmd.execute
end
- assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
diff --git a/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb b/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
index 7617243234..c1d668c777 100644
--- a/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
+++ b/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
@@ -10,15 +10,6 @@ class TestGemDependencyResolverVendorSpecification < Gem::TestCase
@spec = Gem::Specification.new 'a', 1
end
- def test_initialize
- v_spec = Gem::DependencyResolver::VendorSpecification.new @set, @spec
-
- assert_equal 'a', v_spec.name
- assert_equal v(1), v_spec.version
- assert_equal Gem::Platform::RUBY, v_spec.platform
- assert_equal Gem::Source::Vendor.new, v_spec.source
- end
-
def test_equals2
v_spec_a = Gem::DependencyResolver::VendorSpecification.new @set, @spec
@@ -80,7 +71,7 @@ class TestGemDependencyResolverVendorSpecification < Gem::TestCase
v_spec = Gem::DependencyResolver::VendorSpecification.new @set, spec
- assert_equal v(1), spec.version
+ assert_equal v(1), v_spec.version
end
end
diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb
index 5076072791..12a1942d54 100644
--- a/test/rubygems/test_gem_request_set.rb
+++ b/test/rubygems/test_gem_request_set.rb
@@ -56,6 +56,34 @@ class TestGemRequestSet < Gem::TestCase
assert_equal ["a-2", "b-2"], names
end
+ def test_resolve_vendor
+ a_name, _, a_directory = vendor_gem 'a', 1 do |s|
+ s.add_dependency 'b', '~> 2.0'
+ end
+
+ b_name, _, b_directory = vendor_gem 'b', 2
+
+ rs = Gem::RequestSet.new
+
+ Tempfile.open 'gem.deps.rb' do |io|
+ io.puts <<-gems_deps_rb
+ gem "#{a_name}", :path => "#{a_directory}"
+ gem "#{b_name}", :path => "#{b_directory}"
+ gems_deps_rb
+
+ io.flush
+
+ rs.load_gemdeps io.path
+ end
+
+ res = rs.resolve
+ assert_equal 2, res.size
+
+ names = res.map { |s| s.full_name }.sort
+
+ assert_equal ["a-1", "b-2"], names
+ end
+
def test_sorted_requests
a = util_spec "a", "2", "b" => ">= 2"
b = util_spec "b", "2", "c" => ">= 2"
diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb
index cb43121ddd..61fb682001 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -207,5 +207,15 @@ class TestGemSource < Gem::TestCase
assert_equal(-1, remote. <=>(no_uri), 'remote <=> no_uri')
end
+ def test_update_cache_eh
+ assert @source.update_cache?
+ end
+
+ def test_update_cache_eh_home_nonexistent
+ FileUtils.rmdir Gem.user_home
+
+ refute @source.update_cache?
+ end
+
end
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index 8be10a30b9..9e9a8e4d69 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -52,6 +52,24 @@ class TestGemSpecFetcher < Gem::TestCase
['x', Gem::Version.new(1), 'ruby']]
end
+ def test_initialize_unwritable_home_dir
+ FileUtils.rmdir Gem.user_home
+
+ assert Gem::SpecFetcher.new
+ end
+
+ def test_initialize_unwritable_home_dir
+ skip 'chmod not supported' if Gem.win_platform?
+
+ FileUtils.chmod 0000, Gem.user_home
+
+ begin
+ assert Gem::SpecFetcher.new
+ ensure
+ FileUtils.chmod 0755, Gem.user_home
+ end
+ end
+
def test_spec_for_dependency_all
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 0fd4a2e224..d893a7191e 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -1659,12 +1659,11 @@ dependencies: []
@ext.require_path = 'lib'
- lib = Pathname File.join @ext.gem_dir, 'lib'
+ ext_install_dir = Pathname(@ext.extension_install_dir)
+ full_gem_path = Pathname(@ext.full_gem_path)
+ relative_install_dir = ext_install_dir.relative_path_from full_gem_path
- ext_install_dir =
- Pathname(@ext.extension_install_dir).relative_path_from lib
-
- assert_equal ['lib', ext_install_dir.to_s], @ext.require_paths
+ assert_equal ['lib', relative_install_dir.to_s], @ext.require_paths
ensure
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
end
diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb
index e315e2c01a..8f9cadbcf3 100644
--- a/test/rubygems/test_gem_stub_specification.rb
+++ b/test/rubygems/test_gem_stub_specification.rb
@@ -17,6 +17,7 @@ class TestStubSpecification < Gem::TestCase
assert_equal Gem::Version.new("0.0.1"), @foo.version
assert_equal Gem::Platform.new("mswin32"), @foo.platform
assert_equal ["lib", "lib/f oo/ext"], @foo.require_paths
+ assert @foo.stubbed?
end
def test_initialize_extension
@@ -24,17 +25,16 @@ class TestStubSpecification < Gem::TestCase
gem_dir = File.join stub.gems_dir, stub.full_name
- lib = Pathname File.join gem_dir, 'lib'
+ ext_install_dir = Pathname(stub.extension_install_dir)
+ full_gem_path = Pathname(stub.full_gem_path)
+ relative_install_dir = ext_install_dir.relative_path_from full_gem_path
+ relative_install_dir = relative_install_dir.to_s
- ext_install_dir =
- Pathname(stub.extension_install_dir).relative_path_from lib
- ext_install_dir = ext_install_dir.to_s
-
- assert_equal 'stub_e', stub.name
- assert_equal v(2), stub.version
- assert_equal Gem::Platform::RUBY, stub.platform
- assert_equal ['lib', ext_install_dir], stub.require_paths
- assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
+ assert_equal 'stub_e', stub.name
+ assert_equal v(2), stub.version
+ assert_equal Gem::Platform::RUBY, stub.platform
+ assert_equal ['lib', relative_install_dir], stub.require_paths
+ assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
end
def test_initialize_missing_stubline
@@ -43,6 +43,7 @@ class TestStubSpecification < Gem::TestCase
assert_equal Gem::Version.new("0.0.2"), stub.version
assert_equal Gem::Platform.new("ruby"), stub.platform
assert_equal ["lib"], stub.require_paths
+ assert !stub.stubbed?
end
def test_contains_requirable_file_eh