rubygems-update 2.0.0.preview2.2 → 2.0.0.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

@@ -9,10 +9,60 @@ class TestGemCommandsCheckCommand < Gem::TestCase
9
9
  @cmd = Gem::Commands::CheckCommand.new
10
10
  end
11
11
 
12
+ def gem name
13
+ spec = quick_gem name do |gem|
14
+ gem.files = %W[lib/#{name}.rb Rakefile]
15
+ end
16
+
17
+ write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
18
+ write_file File.join(*%W[gems #{spec.full_name} Rakefile])
19
+
20
+ spec
21
+ end
22
+
12
23
  def test_initialize
13
24
  assert_equal "check", @cmd.command
14
25
  assert_equal "gem check", @cmd.program_name
15
26
  assert_match(/Check/, @cmd.summary)
16
27
  end
17
28
 
29
+ def test_handle_options
30
+ @cmd.handle_options %w[--no-alien --no-gems --doctor --dry-run]
31
+
32
+ assert @cmd.options[:doctor]
33
+ refute @cmd.options[:alien]
34
+ assert @cmd.options[:dry_run]
35
+ refute @cmd.options[:gems]
36
+ end
37
+
38
+ def test_handle_options_defaults
39
+ @cmd.handle_options []
40
+
41
+ assert @cmd.options[:alien]
42
+ assert @cmd.options[:gems]
43
+ refute @cmd.options[:doctor]
44
+ refute @cmd.options[:dry_run]
45
+ end
46
+
47
+ def test_doctor
48
+ gem 'a'
49
+ b = gem 'b'
50
+
51
+ FileUtils.rm b.spec_file
52
+
53
+ assert_path_exists b.gem_dir
54
+ refute_path_exists b.spec_file
55
+
56
+ Gem.use_paths @gemhome
57
+
58
+ capture_io do
59
+ use_ui @ui do
60
+ @cmd.doctor
61
+ end
62
+ end
63
+
64
+ refute_path_exists b.gem_dir
65
+ refute_path_exists b.spec_file
66
+ end
67
+
18
68
  end
@@ -23,6 +23,21 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
23
23
  refute_path_exists @a_1.gem_dir
24
24
  end
25
25
 
26
+ def test_execute_all_dependencies
27
+ @b_1 = quick_spec 'b', 1 do |s| s.add_dependency 'a', '1' end
28
+ @b_2 = quick_spec 'b', 2 do |s| s.add_dependency 'a', '2' end
29
+
30
+ install_gem @b_1
31
+ install_gem @b_2
32
+
33
+ @cmd.options[:args] = []
34
+
35
+ @cmd.execute
36
+
37
+ refute_path_exists @a_1.gem_dir
38
+ refute_path_exists @b_1.gem_dir
39
+ end
40
+
26
41
  def test_execute_all
27
42
  gemhome2 = File.join @tempdir, 'gemhome2'
28
43
 
@@ -1,14 +1,6 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/commands/push_command'
3
3
 
4
- module Gem
5
- class << self; remove_method :latest_rubygems_version; end
6
-
7
- def self.latest_rubygems_version
8
- Gem::Version.new Gem::VERSION
9
- end
10
- end
11
-
12
4
  class TestGemCommandsPushCommand < Gem::TestCase
13
5
 
14
6
  def setup
@@ -33,6 +25,23 @@ class TestGemCommandsPushCommand < Gem::TestCase
33
25
  Gem::RemoteFetcher.fetcher = @fetcher
34
26
 
35
27
  @cmd = Gem::Commands::PushCommand.new
28
+
29
+ class << Gem
30
+ alias_method :orig_latest_rubygems_version, :latest_rubygems_version
31
+
32
+ def latest_rubygems_version
33
+ Gem.rubygems_version
34
+ end
35
+ end
36
+ end
37
+
38
+ def teardown
39
+ super
40
+
41
+ class << Gem
42
+ remove_method :latest_rubygems_version
43
+ alias_method :latest_rubygems_version, :orig_latest_rubygems_version
44
+ end
36
45
  end
37
46
 
38
47
  def send_battery
@@ -106,7 +106,6 @@ pl (1 i386-linux)
106
106
  @a2.summary = 'This is a lot of text. ' * 4
107
107
  @a2.authors = ['Abraham Lincoln', 'Hirohito']
108
108
  @a2.homepage = 'http://a.example.com/'
109
- @a2.rubyforge_project = 'rubygems'
110
109
 
111
110
  util_clear_gems
112
111
  util_setup_spec_fetcher @a1, @a2, @pl1
@@ -123,7 +122,6 @@ pl (1 i386-linux)
123
122
 
124
123
  a (2)
125
124
  Authors: Abraham Lincoln, Hirohito
126
- Rubyforge: http://rubyforge.org/projects/rubygems
127
125
  Homepage: http://a.example.com/
128
126
 
129
127
  This is a lot of text. This is a lot of text. This is a lot of text.
@@ -147,7 +145,6 @@ pl (1)
147
145
  @a2.summary = 'This is a lot of text. ' * 4
148
146
  @a2.authors = ['Abraham Lincoln', 'Hirohito']
149
147
  @a2.homepage = 'http://a.example.com/'
150
- @a2.rubyforge_project = 'rubygems'
151
148
  @a2.platform = 'universal-darwin'
152
149
 
153
150
  util_clear_gems
@@ -168,7 +165,6 @@ a (2, 1)
168
165
  1: x86-linux
169
166
  2: universal-darwin
170
167
  Authors: Abraham Lincoln, Hirohito
171
- Rubyforge: http://rubyforge.org/projects/rubygems
172
168
  Homepage: http://a.example.com/
173
169
 
174
170
  This is a lot of text. This is a lot of text. This is a lot of text.
@@ -355,7 +351,6 @@ pl (1 i386-linux)
355
351
  @a2.summary = 'This is a lot of text. ' * 4
356
352
  @a2.authors = ['Abraham Lincoln', 'Hirohito']
357
353
  @a2.homepage = 'http://a.example.com/'
358
- @a2.rubyforge_project = 'rubygems'
359
354
  @a2.platform = 'universal-darwin'
360
355
 
361
356
  util_clear_gems
@@ -380,7 +375,6 @@ a (2, 1)
380
375
  1: x86-linux
381
376
  2: universal-darwin
382
377
  Authors: Abraham Lincoln, Hirohito
383
- Rubyforge: http://rubyforge.org/projects/rubygems
384
378
  Homepage: http://a.example.com/
385
379
  Installed at -
386
380
  -
@@ -400,5 +394,41 @@ pl \(1\)
400
394
  assert_match expected, @ui.output
401
395
  end
402
396
 
397
+ def test_execute_default_details
398
+ default_gem_dir = Gem::Specification.default_specifications_dir
399
+ @a1.loaded_from =
400
+ File.join default_gem_dir, @a1.spec_name
401
+
402
+ @cmd.handle_options %w[-l -d]
403
+
404
+ use_ui @ui do
405
+ @cmd.execute
406
+ end
407
+
408
+ expected = <<-EOF
409
+
410
+ *** LOCAL GEMS ***
411
+
412
+ a (3.a, 2, 1)
413
+ Author: A User
414
+ Homepage: http://example.com
415
+ Installed at (3.a): #{@gemhome}
416
+ (2): #{@gemhome}
417
+ (1, default): #{@a1.base_dir}
418
+
419
+ this is a summary
420
+
421
+ pl \(1\)
422
+ Platform: i386-linux
423
+ Author: A User
424
+ Homepage: http://example.com
425
+ Installed at: #{@gemhome}
426
+
427
+ this is a summary
428
+ EOF
429
+
430
+ assert_equal expected, @ui.output
431
+ end
432
+
403
433
  end
404
434
 
@@ -175,23 +175,5 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
175
175
  assert Gem::Specification.find_all_by_name('x').length == 0
176
176
  end
177
177
 
178
- def test_execute_default_gem
179
- default_gem_spec = new_default_spec("default", "2.0.0.0",
180
- nil, "default/gem.rb")
181
- install_default_specs(default_gem_spec)
182
-
183
- ui = Gem::MockGemUi.new
184
-
185
- @cmd.options[:args] = %w[default]
186
- @cmd.options[:executables] = true
187
-
188
- use_ui ui do
189
- e = assert_raises Gem::InstallError do
190
- @cmd.execute
191
- end
192
- assert_equal "gem \"default\" cannot be uninstalled because it is a default gem",
193
- e.message
194
- end
195
- end
196
178
  end
197
179
 
@@ -0,0 +1,168 @@
1
+ require 'rubygems/test_case'
2
+ require 'rubygems/doctor'
3
+
4
+ class TestGemDoctor < Gem::TestCase
5
+
6
+ def gem name
7
+ spec = quick_gem name do |gem|
8
+ gem.files = %W[lib/#{name}.rb Rakefile]
9
+ end
10
+
11
+ write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
12
+ write_file File.join(*%W[gems #{spec.full_name} Rakefile])
13
+
14
+ spec
15
+ end
16
+
17
+ def test_doctor
18
+ a = gem 'a'
19
+ b = gem 'b'
20
+ c = gem 'c'
21
+
22
+ Gem.use_paths @userhome, @gemhome
23
+
24
+ FileUtils.rm b.spec_file
25
+
26
+ open c.spec_file, 'w' do |io|
27
+ io.write 'this will raise an exception when evaluated.'
28
+ end
29
+
30
+ assert_path_exists File.join(a.gem_dir, 'Rakefile')
31
+ assert_path_exists File.join(a.gem_dir, 'lib', 'a.rb')
32
+
33
+ assert_path_exists b.gem_dir
34
+ refute_path_exists b.spec_file
35
+
36
+ assert_path_exists c.gem_dir
37
+ assert_path_exists c.spec_file
38
+
39
+ doctor = Gem::Doctor.new @gemhome
40
+
41
+ capture_io do
42
+ use_ui @ui do
43
+ doctor.doctor
44
+ end
45
+ end
46
+
47
+ assert_path_exists File.join(a.gem_dir, 'Rakefile')
48
+ assert_path_exists File.join(a.gem_dir, 'lib', 'a.rb')
49
+
50
+ refute_path_exists b.gem_dir
51
+ refute_path_exists b.spec_file
52
+
53
+ refute_path_exists c.gem_dir
54
+ refute_path_exists c.spec_file
55
+
56
+ expected = <<-OUTPUT
57
+ Checking #{@gemhome}
58
+ Removed file specifications/c-2.gemspec
59
+ Removed directory gems/b-2
60
+ Removed directory gems/c-2
61
+
62
+ OUTPUT
63
+
64
+ assert_equal expected, @ui.output
65
+
66
+ assert_equal Gem.dir, @userhome
67
+ assert_equal Gem.path, [@gemhome, @userhome]
68
+ end
69
+
70
+ def test_doctor_dry_run
71
+ a = gem 'a'
72
+ b = gem 'b'
73
+ c = gem 'c'
74
+
75
+ Gem.use_paths @userhome, @gemhome
76
+
77
+ FileUtils.rm b.spec_file
78
+
79
+ open c.spec_file, 'w' do |io|
80
+ io.write 'this will raise an exception when evaluated.'
81
+ end
82
+
83
+ assert_path_exists File.join(a.gem_dir, 'Rakefile')
84
+ assert_path_exists File.join(a.gem_dir, 'lib', 'a.rb')
85
+
86
+ assert_path_exists b.gem_dir
87
+ refute_path_exists b.spec_file
88
+
89
+ assert_path_exists c.gem_dir
90
+ assert_path_exists c.spec_file
91
+
92
+ doctor = Gem::Doctor.new @gemhome, true
93
+
94
+ capture_io do
95
+ use_ui @ui do
96
+ doctor.doctor
97
+ end
98
+ end
99
+
100
+ assert_path_exists File.join(a.gem_dir, 'Rakefile')
101
+ assert_path_exists File.join(a.gem_dir, 'lib', 'a.rb')
102
+
103
+ assert_path_exists b.gem_dir
104
+ refute_path_exists b.spec_file
105
+
106
+ assert_path_exists c.gem_dir
107
+ assert_path_exists c.spec_file
108
+
109
+ expected = <<-OUTPUT
110
+ Checking #{@gemhome}
111
+ Extra file specifications/c-2.gemspec
112
+ Extra directory gems/b-2
113
+ Extra directory gems/c-2
114
+
115
+ OUTPUT
116
+
117
+ assert_equal expected, @ui.output
118
+
119
+ assert_equal Gem.dir, @userhome
120
+ assert_equal Gem.path, [@gemhome, @userhome]
121
+ end
122
+
123
+ def test_doctor_non_gem_home
124
+ other_dir = File.join @tempdir, 'other', 'dir'
125
+
126
+ FileUtils.mkdir_p other_dir
127
+
128
+ doctor = Gem::Doctor.new @tempdir
129
+
130
+ capture_io do
131
+ use_ui @ui do
132
+ doctor.doctor
133
+ end
134
+ end
135
+
136
+ assert_path_exists other_dir
137
+
138
+ expected = <<-OUTPUT
139
+ Checking #{@tempdir}
140
+ This directory does not appear to be a RubyGems repository, skipping
141
+
142
+ OUTPUT
143
+
144
+ assert_equal expected, @ui.output
145
+ end
146
+
147
+ def test_doctor_child_missing
148
+ doctor = Gem::Doctor.new @gemhome
149
+
150
+ doctor.doctor_child 'missing', ''
151
+
152
+ assert true # count
153
+ end
154
+
155
+ def test_gem_repository_eh
156
+ doctor = Gem::Doctor.new @gemhome
157
+
158
+ refute doctor.gem_repository?, 'no gems installed'
159
+
160
+ quick_spec 'a'
161
+
162
+ doctor = Gem::Doctor.new @gemhome
163
+
164
+ assert doctor.gem_repository?, 'gems installed'
165
+ end
166
+
167
+ end
168
+
@@ -24,8 +24,8 @@ cmake_minimum_required(VERSION 2.8)
24
24
  install (FILES test.txt DESTINATION bin)
25
25
  eo_cmake
26
26
  end
27
- File.open File.join(@ext, 'test.txt'), 'w' do |testfile|
28
- end
27
+
28
+ FileUtils.touch File.join(@ext, 'test.txt')
29
29
 
30
30
  output = []
31
31
 
@@ -33,12 +33,14 @@ install (FILES test.txt DESTINATION bin)
33
33
  Gem::Ext::CmakeBuilder.build nil, nil, @dest_path, output
34
34
  end
35
35
 
36
- assert_equal "cmake . -DCMAKE_INSTALL_PREFIX=#{@dest_path}", output.shift
37
- assert_match(/#{@ext}/, output.shift)
38
- assert_equal make_command, output.shift
39
- assert_equal "", output.shift.gsub(/^make\[1\]: (?:Entering|Leaving) directory .*\n/,"")
40
- assert_equal make_command + " install", output.shift
41
- assert_match(/test\.txt/, output.shift)
36
+ output = output.join "\n"
37
+
38
+ assert_match \
39
+ %r%^cmake \. -DCMAKE_INSTALL_PREFIX=#{Regexp.escape @dest_path}%, output
40
+ assert_match %r%#{Regexp.escape @ext}%, output
41
+ assert_match %r%^#{Regexp.escape make_command}$%, output
42
+ assert_match %r%^#{Regexp.escape make_command} install$%, output
43
+ assert_match %r%test\.txt%, output
42
44
  end
43
45
 
44
46
  def test_self_build_fail
@@ -50,6 +52,8 @@ install (FILES test.txt DESTINATION bin)
50
52
  end
51
53
  end
52
54
 
55
+ output = output.join "\n"
56
+
53
57
  shell_error_msg = %r{(CMake Error: .*)}
54
58
  sh_prefix_cmake = "cmake . -DCMAKE_INSTALL_PREFIX="
55
59
 
@@ -61,9 +65,8 @@ install (FILES test.txt DESTINATION bin)
61
65
 
62
66
  assert_match expected, error.message
63
67
 
64
- assert_equal "#{sh_prefix_cmake}#{@dest_path}", output.shift
65
- assert_match %r(#{shell_error_msg}), output.shift
66
- assert_equal true, output.empty?
68
+ assert_match %r%^#{sh_prefix_cmake}#{Regexp.escape @dest_path}%, output
69
+ assert_match %r%#{shell_error_msg}%, output
67
70
  end
68
71
 
69
72
  def test_self_build_has_makefile
@@ -72,12 +75,15 @@ install (FILES test.txt DESTINATION bin)
72
75
  end
73
76
 
74
77
  output = []
78
+
75
79
  Dir.chdir @ext do
76
80
  Gem::Ext::CmakeBuilder.build nil, nil, @dest_path, output
77
81
  end
78
82
 
79
- assert_equal make_command, output[0]
80
- assert_equal "#{make_command} install", output[2]
83
+ output = output.join "\n"
84
+
85
+ assert_match %r%^#{make_command}%, output
86
+ assert_match %r%^#{make_command} install%, output
81
87
  end
82
88
 
83
89
  end