Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for updating rubygems when we're at the latest version

  • Loading branch information...
commit 8ee290f58fe2cde95666598f224a41b4b6f2b998 1 parent 7f3dcee
Eric Hodel drbrain authored lsegal committed
4 lib/rubygems/commands/update_command.rb
View
@@ -158,8 +158,8 @@ def update_rubygems
Gem.source_index.refresh!
- update_gems = Gem.source_index.find_name 'slimgems', requirement
- version = update_gems.last.version
+ installed_gems = Gem.source_index.find_name 'slimgems', requirement
+ version = installed_gems.last.version
args = []
args << '--prefix' << Gem.prefix if Gem.prefix
52 test/test_gem_commands_update_command.rb
View
@@ -56,27 +56,31 @@ def util_setup_rubygem version
gem
end
+ def util_setup_rubygem8
+ @rubygem8 = util_setup_rubygem 8
+ end
+
def util_setup_rubygem9
@rubygem9 = util_setup_rubygem 9
-
- rubygems9_file = File.join @gemhome, 'cache', @rubygem9.file_name
-
- @fetcher.data['http://gems.example.com/gems/rubygems-update-9.gem'] =
- Gem.read_binary rubygems9_file
end
- def util_setup_rubygem8
- @rubygem8 = util_setup_rubygem 8
+ def util_setup_rubygem_current
+ @rubygem_current = util_setup_rubygem Gem::VERSION
+ end
- rubygems8_file = File.join @gemhome, 'cache', @rubygem8.file_name
+ def util_add_to_fetcher *specs
+ specs.each do |spec|
+ gem_file = File.join @gemhome, 'cache', spec.file_name
- @fetcher.data['http://gems.example.com/gems/rubygems-update-8.gem'] =
- Gem.read_binary rubygems8_file
+ @fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
+ Gem.read_binary gem_file
+ end
end
def test_execute_system
util_setup_rubygem9
util_setup_spec_fetcher @rubygem9
+ util_add_to_fetcher @rubygem9
util_clear_gems
@cmd.options[:args] = []
@@ -97,10 +101,33 @@ def test_execute_system
assert_empty out
end
+ def test_execute_system_at_latest
+ util_setup_rubygem_current
+ util_setup_spec_fetcher @rubygem_current
+ util_add_to_fetcher @rubygem_current
+ util_clear_gems
+
+ @cmd.options[:args] = []
+ @cmd.options[:system] = true
+ @cmd.options[:generate_rdoc] = false
+ @cmd.options[:generate_ri] = false
+
+ assert_raises Gem::SystemExitException do
+ use_ui @ui do
+ @cmd.execute
+ end
+ end
+
+ out = @ui.output.split "\n"
+ assert_equal 'Nothing to update, at latest version', out.shift
+ assert_empty out
+ end
+
def test_execute_system_multiple
util_setup_rubygem9
util_setup_rubygem8
util_setup_spec_fetcher @rubygem8, @rubygem9
+ util_add_to_fetcher @rubygem8, @rubygem9
util_clear_gems
@cmd.options[:args] = []
@@ -126,6 +153,7 @@ def test_execute_system_specific
util_setup_rubygem9
util_setup_rubygem8
util_setup_spec_fetcher @rubygem8, @rubygem9
+ util_add_to_fetcher @rubygem8, @rubygem9
@cmd.options[:args] = []
@cmd.options[:system] = "8"
@@ -146,10 +174,6 @@ def test_execute_system_specific
end
def test_execute_system_with_gems
- util_setup_rubygem9
- util_setup_spec_fetcher @rubygem9
- util_clear_gems
-
@cmd.options[:args] = %w[gem]
@cmd.options[:system] = true
@cmd.options[:generate_rdoc] = false
Please sign in to comment.
Something went wrong with that request. Please try again.