rubygems-update 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (104) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +5 -1
  3. data/History.txt +101 -4
  4. data/LICENSE.txt +42 -37
  5. data/MIT.txt +20 -0
  6. data/Manifest.txt +5 -4
  7. data/Rakefile +6 -7
  8. data/lib/rubygems.rb +175 -278
  9. data/lib/rubygems/builder.rb +7 -6
  10. data/lib/rubygems/command_manager.rb +16 -2
  11. data/lib/rubygems/commands/build_command.rb +13 -11
  12. data/lib/rubygems/commands/cert_command.rb +1 -1
  13. data/lib/rubygems/commands/cleanup_command.rb +10 -19
  14. data/lib/rubygems/commands/contents_command.rb +5 -5
  15. data/lib/rubygems/commands/dependency_command.rb +17 -40
  16. data/lib/rubygems/commands/fetch_command.rb +1 -1
  17. data/lib/rubygems/commands/install_command.rb +2 -1
  18. data/lib/rubygems/commands/lock_command.rb +4 -4
  19. data/lib/rubygems/commands/outdated_command.rb +18 -6
  20. data/lib/rubygems/commands/pristine_command.rb +25 -15
  21. data/lib/rubygems/commands/query_command.rb +9 -6
  22. data/lib/rubygems/commands/setup_command.rb +1 -1
  23. data/lib/rubygems/commands/specification_command.rb +8 -23
  24. data/lib/rubygems/commands/stale_command.rb +2 -1
  25. data/lib/rubygems/commands/unpack_command.rb +7 -5
  26. data/lib/rubygems/commands/update_command.rb +2 -4
  27. data/lib/rubygems/commands/which_command.rb +5 -9
  28. data/lib/rubygems/config_file.rb +9 -7
  29. data/lib/rubygems/custom_require.rb +6 -4
  30. data/lib/rubygems/defaults.rb +30 -14
  31. data/lib/rubygems/dependency.rb +44 -1
  32. data/lib/rubygems/dependency_installer.rb +37 -41
  33. data/lib/rubygems/dependency_list.rb +20 -9
  34. data/lib/rubygems/deprecate.rb +3 -3
  35. data/lib/rubygems/doc_manager.rb +10 -11
  36. data/lib/rubygems/ext/rake_builder.rb +1 -1
  37. data/lib/rubygems/gem_path_searcher.rb +19 -4
  38. data/lib/rubygems/gem_runner.rb +1 -1
  39. data/lib/rubygems/indexer.rb +117 -123
  40. data/lib/rubygems/installer.rb +101 -94
  41. data/lib/rubygems/installer_test_case.rb +28 -30
  42. data/lib/rubygems/local_remote_options.rb +1 -1
  43. data/lib/rubygems/mock_gem_ui.rb +10 -3
  44. data/lib/rubygems/package.rb +0 -26
  45. data/lib/rubygems/package/tar_input.rb +5 -6
  46. data/lib/rubygems/package_task.rb +1 -1
  47. data/lib/rubygems/path_support.rb +72 -0
  48. data/lib/rubygems/platform.rb +12 -2
  49. data/lib/rubygems/remote_fetcher.rb +7 -6
  50. data/lib/rubygems/requirement.rb +3 -0
  51. data/lib/rubygems/security.rb +1 -1
  52. data/lib/rubygems/server.rb +67 -67
  53. data/lib/rubygems/source_index.rb +58 -29
  54. data/lib/rubygems/spec_fetcher.rb +5 -1
  55. data/lib/rubygems/specification.rb +1422 -877
  56. data/lib/rubygems/test_case.rb +114 -64
  57. data/lib/rubygems/test_utilities.rb +4 -3
  58. data/lib/rubygems/text.rb +1 -1
  59. data/lib/rubygems/uninstaller.rb +37 -44
  60. data/test/rubygems/test_gem.rb +131 -102
  61. data/test/rubygems/test_gem_builder.rb +18 -1
  62. data/test/rubygems/test_gem_command_manager.rb +2 -0
  63. data/test/rubygems/test_gem_commands_build_command.rb +31 -3
  64. data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
  65. data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
  66. data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
  67. data/test/rubygems/test_gem_commands_help_command.rb +58 -0
  68. data/test/rubygems/test_gem_commands_install_command.rb +25 -24
  69. data/test/rubygems/test_gem_commands_list_command.rb +1 -4
  70. data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
  71. data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
  72. data/test/rubygems/test_gem_commands_push_command.rb +1 -1
  73. data/test/rubygems/test_gem_commands_query_command.rb +15 -82
  74. data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
  75. data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
  76. data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
  77. data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
  78. data/test/rubygems/test_gem_commands_update_command.rb +19 -23
  79. data/test/rubygems/test_gem_commands_which_command.rb +7 -4
  80. data/test/rubygems/test_gem_dependency.rb +14 -8
  81. data/test/rubygems/test_gem_dependency_installer.rb +87 -33
  82. data/test/rubygems/test_gem_dependency_list.rb +7 -3
  83. data/test/rubygems/test_gem_doc_manager.rb +3 -3
  84. data/test/rubygems/test_gem_format.rb +1 -1
  85. data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
  86. data/test/rubygems/test_gem_indexer.rb +48 -47
  87. data/test/rubygems/test_gem_install_update_options.rb +6 -5
  88. data/test/rubygems/test_gem_installer.rb +61 -37
  89. data/test/rubygems/test_gem_path_support.rb +58 -0
  90. data/test/rubygems/test_gem_platform.rb +5 -5
  91. data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
  92. data/test/rubygems/test_gem_server.rb +23 -15
  93. data/test/rubygems/test_gem_source_index.rb +165 -127
  94. data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
  95. data/test/rubygems/test_gem_specification.rb +104 -74
  96. data/test/rubygems/test_gem_text.rb +15 -0
  97. data/test/rubygems/test_gem_uninstaller.rb +15 -26
  98. data/test/rubygems/test_kernel.rb +1 -2
  99. metadata +64 -14
  100. metadata.gz.sig +0 -0
  101. data/GPL.txt +0 -340
  102. data/pkgs/sources/lib/sources.rb +0 -3
  103. data/pkgs/sources/sources.gemspec +0 -14
  104. data/test/rubygems/functional.rb +0 -92
@@ -19,12 +19,12 @@ class TestGemCommandsStaleCommand < Gem::TestCase
19
19
  end
20
20
 
21
21
  files.each do |file|
22
- filename = bar_baz.full_gem_path + "/#{file}"
23
- FileUtils.mkdir_p(File.dirname(filename))
22
+ filename = File.join(bar_baz.full_gem_path, file)
23
+ FileUtils.mkdir_p File.dirname filename
24
24
  FileUtils.touch(filename, :mtime => Time.now)
25
25
 
26
- filename = foo_bar.full_gem_path + "/#{file}"
27
- FileUtils.mkdir_p(File.dirname(filename))
26
+ filename = File.join(foo_bar.full_gem_path, file)
27
+ FileUtils.mkdir_p File.dirname filename
28
28
  FileUtils.touch(filename, :mtime => Time.now - 86400)
29
29
  end
30
30
 
@@ -15,38 +15,38 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
15
15
  util_make_gems
16
16
 
17
17
  assert_equal(
18
- @cmd.find_in_cache(@a1.file_name),
19
- Gem.cache_gem(@a1.file_name, @gemhome),
18
+ @cmd.find_in_cache(File.basename @a1.cache_file),
19
+ @a1.cache_file,
20
20
  'found a-1.gem in the cache'
21
21
  )
22
22
  end
23
23
 
24
24
  def test_get_path
25
- util_make_gems
26
25
  util_setup_fake_fetcher
26
+ util_clear_gems
27
27
  util_setup_spec_fetcher @a1
28
-
28
+
29
29
  a1_data = nil
30
30
 
31
- open Gem.cache_gem(@a1.file_name, @gemhome), 'rb' do |fp|
31
+ open @a1.cache_file, 'rb' do |fp|
32
32
  a1_data = fp.read
33
33
  end
34
34
 
35
35
  Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-1.gem'] =
36
36
  a1_data
37
-
37
+
38
38
  dep = Gem::Dependency.new(@a1.name, @a1.version)
39
39
  assert_equal(
40
- @cmd.get_path(dep),
41
- Gem.cache_gem(@a1.file_name, @gemhome),
40
+ @cmd.get_path(dep),
41
+ @a1.cache_file,
42
42
  'fetches a-1 and returns the cache path'
43
43
  )
44
44
 
45
- FileUtils.rm Gem.cache_gem(@a1.file_name, @gemhome)
45
+ FileUtils.rm @a1.cache_file
46
46
 
47
47
  assert_equal(
48
- @cmd.get_path(dep),
49
- Gem.cache_gem(@a1.file_name, @gemhome),
48
+ @cmd.get_path(dep),
49
+ @a1.cache_file,
50
50
  'when removed from cache, refetches a-1'
51
51
  )
52
52
  end
@@ -67,16 +67,14 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
67
67
  end
68
68
 
69
69
  def test_execute_gem_path
70
- util_make_gems
71
- util_setup_spec_fetcher
72
70
  util_setup_fake_fetcher
71
+ util_setup_spec_fetcher
73
72
 
74
73
  Gem.clear_paths
75
74
 
76
75
  gemhome2 = File.join @tempdir, 'gemhome2'
77
76
 
78
- Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
79
- Gem.send :set_home, gemhome2
77
+ Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 }
80
78
 
81
79
  @cmd.options[:args] = %w[a]
82
80
 
@@ -90,15 +88,14 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
90
88
  end
91
89
 
92
90
  def test_execute_gem_path_missing
93
- util_make_gems
91
+ util_setup_fake_fetcher
94
92
  util_setup_spec_fetcher
95
93
 
96
94
  Gem.clear_paths
97
95
 
98
96
  gemhome2 = File.join @tempdir, 'gemhome2'
99
97
 
100
- Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
101
- Gem.send :set_home, gemhome2
98
+ Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 }
102
99
 
103
100
  @cmd.options[:args] = %w[z]
104
101
 
@@ -117,7 +114,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
117
114
  util_clear_gems
118
115
 
119
116
  a2_data = nil
120
- open Gem.cache_gem(@a2.file_name, @gemhome), 'rb' do |fp|
117
+ open @a2.cache_file, 'rb' do |fp|
121
118
  a2_data = fp.read
122
119
  end
123
120
 
@@ -153,9 +150,11 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
153
150
  end
154
151
 
155
152
  def test_execute_sudo
153
+ skip 'Cannot perform this test on windows (chmod)' if win_platform?
154
+
156
155
  util_make_gems
157
156
 
158
- File.chmod 0555, @gemhome
157
+ FileUtils.chmod 0555, @gemhome
159
158
 
160
159
  @cmd.options[:args] = %w[b]
161
160
 
@@ -167,7 +166,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
167
166
 
168
167
  assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
169
168
  ensure
170
- File.chmod 0755, @gemhome
169
+ FileUtils.chmod 0755, @gemhome
171
170
  end
172
171
 
173
172
  def test_execute_with_target_option
@@ -18,15 +18,15 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
18
18
  @cmd.options[:generate_ri] = false
19
19
 
20
20
  util_setup_fake_fetcher
21
-
22
- @a1_path = Gem.cache_gem(@a1.file_name, @gemhome)
23
- @a2_path = Gem.cache_gem(@a2.file_name, @gemhome)
24
-
21
+ util_clear_gems
25
22
  util_setup_spec_fetcher @a1, @a2
26
23
 
27
- @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
24
+ @a1_path = @a1.cache_file
25
+ @a2_path = @a2.cache_file
26
+
27
+ @fetcher.data["#{@gem_repo}gems/#{File.basename @a1_path}"] =
28
28
  read_binary @a1_path
29
- @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
29
+ @fetcher.data["#{@gem_repo}gems/#{File.basename @a2_path}"] =
30
30
  read_binary @a2_path
31
31
  end
32
32
 
@@ -75,18 +75,19 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
75
75
 
76
76
  def util_add_to_fetcher *specs
77
77
  specs.each do |spec|
78
- gem_file = Gem.cache_gem(spec.file_name, @gemhome)
78
+ gem_file = spec.cache_file
79
+ file_name = File.basename gem_file
79
80
 
80
- @fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
81
+ @fetcher.data["http://gems.example.com/gems/#{file_name}"] =
81
82
  Gem.read_binary gem_file
82
83
  end
83
84
  end
84
85
 
85
86
  def test_execute_system
87
+ util_clear_gems
86
88
  util_setup_rubygem9
87
89
  util_setup_spec_fetcher @rubygem9
88
90
  util_add_to_fetcher @rubygem9
89
- util_clear_gems
90
91
 
91
92
  @cmd.options[:args] = []
92
93
  @cmd.options[:system] = true
@@ -107,10 +108,10 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
107
108
  end
108
109
 
109
110
  def test_execute_system_at_latest
111
+ util_clear_gems
110
112
  util_setup_rubygem_current
111
113
  util_setup_spec_fetcher @rubygem_current
112
114
  util_add_to_fetcher @rubygem_current
113
- util_clear_gems
114
115
 
115
116
  @cmd.options[:args] = []
116
117
  @cmd.options[:system] = true
@@ -129,11 +130,11 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
129
130
  end
130
131
 
131
132
  def test_execute_system_multiple
133
+ util_clear_gems
132
134
  util_setup_rubygem9
133
135
  util_setup_rubygem8
134
136
  util_setup_spec_fetcher @rubygem8, @rubygem9
135
137
  util_add_to_fetcher @rubygem8, @rubygem9
136
- util_clear_gems
137
138
 
138
139
  @cmd.options[:args] = []
139
140
  @cmd.options[:system] = true
@@ -237,16 +238,11 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
237
238
  @a2.add_dependency 'c', '2'
238
239
  @a2.add_dependency 'b', '2'
239
240
 
240
- @b2_path = Gem.cache_gem(@b2.file_name, @gemhome)
241
- @c1_2_path = Gem.cache_gem(@c1_2.file_name, @gemhome)
242
- @c2_path = Gem.cache_gem(@c2.file_name, @gemhome)
241
+ @b2_path = @b2.cache_file
242
+ @c1_2_path = @c1_2.cache_file
243
+ @c2_path = @c2.cache_file
243
244
 
244
- @source_index = Gem::SourceIndex.new
245
- @source_index.add_spec @a1
246
- @source_index.add_spec @a2
247
- @source_index.add_spec @b2
248
- @source_index.add_spec @c1_2
249
- @source_index.add_spec @c2
245
+ install_specs @a1, @a2, @b2, @c1_2, @c2
250
246
 
251
247
  util_build_gem @a1
252
248
  util_build_gem @a2
@@ -255,16 +251,16 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
255
251
  @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path
256
252
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path
257
253
  @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path
258
- @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] =
259
- read_binary @c1_2_path
254
+ @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] = read_binary @c1_2_path
260
255
  @fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path
261
256
 
262
257
  util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
263
- util_clear_gems
264
258
 
265
259
  Gem::Installer.new(@c1_2_path).install
266
260
  Gem::Installer.new(@a1_path).install
267
261
 
262
+ Gem::Specification.reset
263
+
268
264
  @cmd.options[:args] = []
269
265
 
270
266
  use_ui @ui do
@@ -5,6 +5,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase
5
5
 
6
6
  def setup
7
7
  super
8
+ Gem::Specification.reset
8
9
  @cmd = Gem::Commands::WhichCommand.new
9
10
  end
10
11
 
@@ -22,6 +23,8 @@ class TestGemCommandsWhichCommand < Gem::TestCase
22
23
  end
23
24
 
24
25
  def test_execute_one_missing
26
+ # TODO: this test fails in isolation
27
+
25
28
  util_foo_bar
26
29
 
27
30
  @cmd.handle_options %w[foo_bar missing]
@@ -31,7 +34,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase
31
34
  end
32
35
 
33
36
  assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
34
- assert_match %r%Can't find ruby library file or shared library missing\n%,
37
+ assert_match %r%Can.t find ruby library file or shared library missing\n%,
35
38
  @ui.error
36
39
  end
37
40
 
@@ -45,7 +48,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase
45
48
  end
46
49
 
47
50
  assert_equal '', @ui.output
48
- assert_match %r%Can't find ruby library file or shared library missing\n%,
51
+ assert_match %r%Can.t find ruby library file or shared library missing\n%,
49
52
  @ui.error
50
53
  end
51
54
 
@@ -56,8 +59,8 @@ class TestGemCommandsWhichCommand < Gem::TestCase
56
59
  end
57
60
 
58
61
  files.each do |file|
59
- filename = @foo_bar.full_gem_path + "/#{file}"
60
- FileUtils.mkdir_p File.dirname(filename)
62
+ filename = File.join(@foo_bar.full_gem_path, file)
63
+ FileUtils.mkdir_p File.dirname filename
61
64
  FileUtils.touch filename
62
65
  end
63
66
  end
@@ -61,16 +61,20 @@ class TestGemDependency < Gem::TestCase
61
61
  assert_match d, d, "match self"
62
62
  assert_match dep("a", ">= 0"), d, "match version exact"
63
63
  assert_match dep("a", ">= 0"), dep("a", "1"), "match version"
64
- assert_match dep(/a/, ">= 0"), d, "match simple regexp"
65
- assert_match dep(/a|b/, ">= 0"), d, "match scary regexp"
66
-
67
- refute_match dep(/a/), dep("b")
68
64
  refute_match dep("a"), Object.new
65
+
66
+ Deprecate.skip_during do
67
+ assert_match dep(/a/, ">= 0"), d, "match simple regexp"
68
+ assert_match dep(/a|b/, ">= 0"), d, "match scary regexp"
69
+ refute_match dep(/a/), dep("b")
70
+ end
69
71
  end
70
72
 
71
73
  def test_equals_tilde_escape
72
74
  refute_match dep("a|b"), dep("a", "1")
73
- assert_match dep(/a|b/), dep("a", "1")
75
+ Deprecate.skip_during do
76
+ assert_match dep(/a|b/), dep("a", "1")
77
+ end
74
78
  end
75
79
 
76
80
  def test_equals_tilde_object
@@ -84,9 +88,11 @@ class TestGemDependency < Gem::TestCase
84
88
  def test_equals_tilde_spec
85
89
  assert_match dep("a", ">= 0"), spec("a", "0")
86
90
  assert_match dep("a", "1"), spec("a", "1")
87
- assert_match dep(/a/, ">= 0"), spec("a", "0")
88
- assert_match dep(/a|b/, ">= 0"), spec("b", "0")
89
- refute_match dep(/a/, ">= 0"), spec("b", "0")
91
+ Deprecate.skip_during do
92
+ assert_match dep(/a/, ">= 0"), spec("a", "0")
93
+ assert_match dep(/a|b/, ">= 0"), spec("b", "0")
94
+ refute_match dep(/a/, ">= 0"), spec("b", "0")
95
+ end
90
96
  end
91
97
 
92
98
  def test_hash
@@ -8,10 +8,14 @@ class TestGemDependencyInstaller < Gem::TestCase
8
8
  super
9
9
 
10
10
  @gems_dir = File.join @tempdir, 'gems'
11
- @cache_dir = Gem.cache_dir(@gemhome)
11
+ @cache_dir = File.join @gemhome, 'cache'
12
12
 
13
13
  FileUtils.mkdir @gems_dir
14
14
 
15
+ Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
16
+ end
17
+
18
+ def util_setup_gems
15
19
  @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
16
20
  @a1_pre, @a1_pre_gem = util_gem 'a', '1.a'
17
21
  @b1, @b1_gem = util_gem 'b', '1' do |s|
@@ -19,12 +23,13 @@ class TestGemDependencyInstaller < Gem::TestCase
19
23
  s.add_development_dependency 'aa'
20
24
  end
21
25
 
22
- Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
23
-
26
+ util_clear_gems
24
27
  util_reset_gems
25
28
  end
26
29
 
27
30
  def test_install
31
+ util_setup_gems
32
+
28
33
  FileUtils.mv @a1_gem, @tempdir
29
34
  inst = nil
30
35
 
@@ -33,15 +38,13 @@ class TestGemDependencyInstaller < Gem::TestCase
33
38
  inst.install 'a'
34
39
  end
35
40
 
36
- si = Gem::SourceIndex.new
37
- si.add_spec @a1
38
-
39
- assert_equal Gem.source_index, si
40
-
41
+ assert_equal %w[a-1], Gem::Specification.map(&:full_name)
41
42
  assert_equal [@a1], inst.installed_gems
42
43
  end
43
44
 
44
45
  def test_install_all_dependencies
46
+ util_setup_gems
47
+
45
48
  _, e1_gem = util_gem 'e', '1' do |s|
46
49
  s.add_dependency 'b'
47
50
  end
@@ -67,6 +70,8 @@ class TestGemDependencyInstaller < Gem::TestCase
67
70
  end
68
71
 
69
72
  def test_install_cache_dir
73
+ util_setup_gems
74
+
70
75
  FileUtils.mv @a1_gem, @tempdir
71
76
  FileUtils.mv @b1_gem, @tempdir
72
77
  inst = nil
@@ -78,15 +83,18 @@ class TestGemDependencyInstaller < Gem::TestCase
78
83
 
79
84
  assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
80
85
 
81
- assert Gem.cache_gem(@a1.file_name, @gemhome)
82
- assert Gem.cache_gem(@b1.file_name, @gemhome)
86
+ assert File.exist? File.join(@gemhome, "cache", @a1.file_name)
87
+ assert File.exist? File.join(@gemhome, "cache", @b1.file_name)
83
88
  end
84
89
 
85
90
  def test_install_dependencies_satisfied
91
+ util_setup_gems
92
+
86
93
  a2, a2_gem = util_gem 'a', '2'
87
94
 
88
95
  FileUtils.rm_rf File.join(@gemhome, 'gems')
89
- Gem.source_index.refresh!
96
+
97
+ Gem::Specification.reset
90
98
 
91
99
  FileUtils.mv @a1_gem, @tempdir
92
100
  FileUtils.mv a2_gem, @tempdir # not in index
@@ -105,14 +113,13 @@ class TestGemDependencyInstaller < Gem::TestCase
105
113
  inst.install 'b'
106
114
  end
107
115
 
108
- installed = Gem.source_index.map { |n,s| s.full_name }
109
-
110
- assert_equal %w[a-2 b-1], installed.sort
111
-
116
+ assert_equal %w[a-2 b-1], Gem::Specification.map(&:full_name)
112
117
  assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
113
118
  end
114
119
 
115
120
  def test_install_dependency
121
+ util_setup_gems
122
+
116
123
  FileUtils.mv @a1_gem, @tempdir
117
124
  FileUtils.mv @b1_gem, @tempdir
118
125
  inst = nil
@@ -126,6 +133,8 @@ class TestGemDependencyInstaller < Gem::TestCase
126
133
  end
127
134
 
128
135
  def test_install_dependency_development
136
+ util_setup_gems
137
+
129
138
  @aa1, @aa1_gem = util_gem 'aa', '1'
130
139
 
131
140
  util_reset_gems
@@ -144,6 +153,8 @@ class TestGemDependencyInstaller < Gem::TestCase
144
153
  end
145
154
 
146
155
  def test_install_dependency_existing
156
+ util_setup_gems
157
+
147
158
  Gem::Installer.new(@a1_gem).install
148
159
  FileUtils.mv @a1_gem, @tempdir
149
160
  FileUtils.mv @b1_gem, @tempdir
@@ -176,6 +187,8 @@ class TestGemDependencyInstaller < Gem::TestCase
176
187
  end
177
188
 
178
189
  def test_install_local
190
+ util_setup_gems
191
+
179
192
  FileUtils.mv @a1_gem, @tempdir
180
193
  inst = nil
181
194
 
@@ -188,6 +201,8 @@ class TestGemDependencyInstaller < Gem::TestCase
188
201
  end
189
202
 
190
203
  def test_install_local_dependency
204
+ util_setup_gems
205
+
191
206
  FileUtils.mv @a1_gem, @tempdir
192
207
  FileUtils.mv @b1_gem, @tempdir
193
208
 
@@ -202,6 +217,8 @@ class TestGemDependencyInstaller < Gem::TestCase
202
217
  end
203
218
 
204
219
  def test_install_local_dependency_installed
220
+ util_setup_gems
221
+
205
222
  FileUtils.mv @a1_gem, @tempdir
206
223
  FileUtils.mv @b1_gem, @tempdir
207
224
 
@@ -218,6 +235,8 @@ class TestGemDependencyInstaller < Gem::TestCase
218
235
  end
219
236
 
220
237
  def test_install_local_subdir
238
+ util_setup_gems
239
+
221
240
  inst = nil
222
241
 
223
242
  Dir.chdir @tempdir do
@@ -229,6 +248,8 @@ class TestGemDependencyInstaller < Gem::TestCase
229
248
  end
230
249
 
231
250
  def test_install_env_shebang
251
+ util_setup_gems
252
+
232
253
  FileUtils.mv @a1_gem, @tempdir
233
254
  inst = nil
234
255
 
@@ -244,6 +265,8 @@ class TestGemDependencyInstaller < Gem::TestCase
244
265
  end
245
266
 
246
267
  def test_install_force
268
+ util_setup_gems
269
+
247
270
  FileUtils.mv @b1_gem, @tempdir
248
271
  si = util_setup_spec_fetcher @b1
249
272
  @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
@@ -258,6 +281,8 @@ class TestGemDependencyInstaller < Gem::TestCase
258
281
  end
259
282
 
260
283
  def test_install_ignore_dependencies
284
+ util_setup_gems
285
+
261
286
  FileUtils.mv @b1_gem, @tempdir
262
287
  inst = nil
263
288
 
@@ -270,6 +295,8 @@ class TestGemDependencyInstaller < Gem::TestCase
270
295
  end
271
296
 
272
297
  def test_install_install_dir
298
+ util_setup_gems
299
+
273
300
  FileUtils.mv @a1_gem, @tempdir
274
301
  gemhome2 = File.join @tempdir, 'gemhome2'
275
302
  Dir.mkdir gemhome2
@@ -283,10 +310,12 @@ class TestGemDependencyInstaller < Gem::TestCase
283
310
  assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
284
311
 
285
312
  assert File.exist?(File.join(gemhome2, 'specifications', @a1.spec_name))
286
- assert File.exist?(Gem.cache_gem(@a1.file_name, gemhome2))
313
+ assert File.exist?(File.join(gemhome2, 'cache', @a1.file_name))
287
314
  end
288
315
 
289
316
  def test_install_domain_both
317
+ util_setup_gems
318
+
290
319
  a1_data = nil
291
320
  File.open @a1_gem, 'rb' do |fp|
292
321
  a1_data = fp.read
@@ -305,14 +334,13 @@ class TestGemDependencyInstaller < Gem::TestCase
305
334
  assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
306
335
  a1, b1 = inst.installed_gems
307
336
 
308
- a1_expected = File.join(@gemhome, 'specifications', a1.spec_name)
309
- b1_expected = File.join(@gemhome, 'specifications', b1.spec_name)
310
-
311
- assert_equal a1_expected, a1.loaded_from
312
- assert_equal b1_expected, b1.loaded_from
337
+ assert_equal a1.spec_file, a1.loaded_from
338
+ assert_equal b1.spec_file, b1.loaded_from
313
339
  end
314
340
 
315
341
  def test_install_domain_both_no_network
342
+ util_setup_gems
343
+
316
344
  @fetcher.data["http://gems.example.com/gems/Marshal.#{@marshal_version}"] =
317
345
  proc do
318
346
  raise Gem::RemoteFetcher::FetchError
@@ -331,12 +359,11 @@ class TestGemDependencyInstaller < Gem::TestCase
331
359
  end
332
360
 
333
361
  def test_install_domain_local
362
+ util_setup_gems
363
+
334
364
  FileUtils.mv @b1_gem, @tempdir
335
365
  inst = nil
336
366
 
337
- Gem.source_index.remove_spec @a1.full_name
338
- Gem.source_index.remove_spec @a1_pre.full_name
339
-
340
367
  Dir.chdir @tempdir do
341
368
  e = assert_raises Gem::DependencyError do
342
369
  inst = Gem::DependencyInstaller.new :domain => :local
@@ -351,6 +378,8 @@ class TestGemDependencyInstaller < Gem::TestCase
351
378
  end
352
379
 
353
380
  def test_install_domain_remote
381
+ util_setup_gems
382
+
354
383
  a1_data = nil
355
384
  File.open @a1_gem, 'rb' do |fp|
356
385
  a1_data = fp.read
@@ -365,6 +394,8 @@ class TestGemDependencyInstaller < Gem::TestCase
365
394
  end
366
395
 
367
396
  def test_install_dual_repository
397
+ util_setup_gems
398
+
368
399
  FileUtils.mv @a1_gem, @tempdir
369
400
  FileUtils.mv @b1_gem, @tempdir
370
401
  inst = nil
@@ -389,6 +420,8 @@ class TestGemDependencyInstaller < Gem::TestCase
389
420
  end
390
421
 
391
422
  def test_install_reinstall
423
+ util_setup_gems
424
+
392
425
  Gem::Installer.new(@a1_gem).install
393
426
  FileUtils.mv @a1_gem, @tempdir
394
427
  inst = nil
@@ -398,15 +431,13 @@ class TestGemDependencyInstaller < Gem::TestCase
398
431
  inst.install 'a'
399
432
  end
400
433
 
401
- si = Gem::SourceIndex.new
402
- si.add_spec @a1
403
-
404
- assert_equal Gem.source_index, si
405
-
406
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
434
+ assert_equal %w[a-1], Gem::Specification.map(&:full_name)
435
+ assert_equal %w[a-1], inst.installed_gems.map(&:full_name)
407
436
  end
408
437
 
409
438
  def test_install_remote
439
+ util_setup_gems
440
+
410
441
  a1_data = nil
411
442
  File.open @a1_gem, 'rb' do |fp|
412
443
  a1_data = fp.read
@@ -424,6 +455,8 @@ class TestGemDependencyInstaller < Gem::TestCase
424
455
  end
425
456
 
426
457
  def test_install_remote_dep
458
+ util_setup_gems
459
+
427
460
  a1_data = nil
428
461
  File.open @a1_gem, 'rb' do |fp|
429
462
  a1_data = fp.read
@@ -442,6 +475,8 @@ class TestGemDependencyInstaller < Gem::TestCase
442
475
  end
443
476
 
444
477
  def test_install_remote_platform_newer
478
+ util_setup_gems
479
+
445
480
  a2_o, a2_o_gem = util_gem 'a', '2' do |s|
446
481
  s.platform = Gem::Platform.new %w[cpu other_platform 1]
447
482
  end
@@ -471,6 +506,8 @@ class TestGemDependencyInstaller < Gem::TestCase
471
506
 
472
507
  if defined? OpenSSL then
473
508
  def test_install_security_policy
509
+ util_setup_gems
510
+
474
511
  data = File.open(@a1_gem, 'rb') { |f| f.read }
475
512
  @fetcher.data['http://gems.example.com/gems/a-1.gem'] = data
476
513
 
@@ -493,6 +530,8 @@ class TestGemDependencyInstaller < Gem::TestCase
493
530
  # Wrappers don't work on mswin
494
531
  unless win_platform? then
495
532
  def test_install_no_wrappers
533
+ util_setup_gems
534
+
496
535
  @fetcher.data['http://gems.example.com/gems/a-1.gem'] = read_binary(@a1_gem)
497
536
 
498
537
  inst = Gem::DependencyInstaller.new :wrappers => false
@@ -535,14 +574,19 @@ class TestGemDependencyInstaller < Gem::TestCase
535
574
  end
536
575
 
537
576
  def test_find_gems_gems_with_sources
577
+ util_setup_gems
578
+
538
579
  inst = Gem::DependencyInstaller.new
539
580
  dep = Gem::Dependency.new 'b', '>= 0'
540
581
 
541
- assert_equal [[@b1, @gem_repo]],
542
- inst.find_gems_with_sources(dep)
582
+ Gem::Specification.reset
583
+
584
+ assert_equal [[@b1, @gem_repo]], inst.find_gems_with_sources(dep)
543
585
  end
544
586
 
545
587
  def test_find_gems_with_sources_local
588
+ util_setup_gems
589
+
546
590
  FileUtils.mv @a1_gem, @tempdir
547
591
  inst = Gem::DependencyInstaller.new
548
592
  dep = Gem::Dependency.new 'a', '>= 0'
@@ -564,6 +608,8 @@ class TestGemDependencyInstaller < Gem::TestCase
564
608
  end
565
609
 
566
610
  def test_find_gems_with_sources_prerelease
611
+ util_setup_gems
612
+
567
613
  installer = Gem::DependencyInstaller.new
568
614
 
569
615
  dependency = Gem::Dependency.new('a', Gem::Requirement.default)
@@ -584,8 +630,8 @@ class TestGemDependencyInstaller < Gem::TestCase
584
630
 
585
631
  def assert_resolve expected, *specs
586
632
  util_clear_gems
587
-
588
633
  util_setup_spec_fetcher(*specs)
634
+ Gem::Specification.reset
589
635
 
590
636
  inst = Gem::DependencyInstaller.new
591
637
  inst.find_spec_by_name_and_version specs.first.name
@@ -599,6 +645,7 @@ class TestGemDependencyInstaller < Gem::TestCase
599
645
  util_clear_gems
600
646
 
601
647
  util_setup_spec_fetcher(*specs)
648
+ Gem::Specification.reset
602
649
 
603
650
  spec = specs.first
604
651
 
@@ -611,6 +658,9 @@ class TestGemDependencyInstaller < Gem::TestCase
611
658
  end
612
659
 
613
660
  def test_gather_dependencies
661
+ util_setup_gems
662
+ util_reset_gems
663
+
614
664
  inst = Gem::DependencyInstaller.new
615
665
  inst.find_spec_by_name_and_version 'b'
616
666
  inst.gather_dependencies
@@ -723,6 +773,7 @@ class TestGemDependencyInstaller < Gem::TestCase
723
773
  end
724
774
 
725
775
  def test_gather_dependencies_prerelease
776
+ util_setup_gems
726
777
  util_setup_c1_pre
727
778
 
728
779
  assert_resolve_pre %w[a-1.a b-1 c-1.a], @c1_pre, @a1_pre, @b1
@@ -780,6 +831,9 @@ class TestGemDependencyInstaller < Gem::TestCase
780
831
  end
781
832
 
782
833
  def util_reset_gems
834
+ @a1 ||= nil
835
+ @b1 ||= nil
836
+ @a1_pre ||= nil
783
837
  @c1_pre ||= nil
784
838
  @d1 ||= nil
785
839
  @d2 ||= nil