summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_source_index.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_source_index.rb')
-rw-r--r--test/rubygems/test_gem_source_index.rb87
1 files changed, 14 insertions, 73 deletions
diff --git a/test/rubygems/test_gem_source_index.rb b/test/rubygems/test_gem_source_index.rb
index 40dfeb95c1..95ea94451d 100644
--- a/test/rubygems/test_gem_source_index.rb
+++ b/test/rubygems/test_gem_source_index.rb
@@ -1,13 +1,13 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/source_index'
require 'rubygems/config_file'
-class Gem::SourceIndex
- public :fetcher, :fetch_bulk_index, :fetch_quick_index,
- :find_missing, :gems, :remove_extra,
- :update_with_missing, :unzip
-end
-
class TestGemSourceIndex < RubyGemTestCase
def setup
@@ -116,19 +116,14 @@ end
fp.write 'raise Exception, "epic fail"'
end
- use_ui @ui do
+ out, err = capture_io do
assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
end
- assert_equal '', @ui.output
-
- expected = <<-EOF
-WARNING: #<Exception: epic fail>
-raise Exception, "epic fail"
-WARNING: Invalid .gemspec format in '#{spec_file}'
- EOF
+ assert_equal '', out
- assert_equal expected, @ui.error
+ expected = "Invalid gemspec in [#{spec_file}]: epic fail\n"
+ assert_equal expected, err
end
def test_self_load_specification_interrupt
@@ -163,14 +158,13 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
fp.write '1 +'
end
- use_ui @ui do
+ out, err = capture_io do
assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
end
- assert_equal '', @ui.output
+ assert_equal '', out
- assert_match(/syntax error/, @ui.error)
- assert_match(/1 \+/, @ui.error)
+ assert_match(/syntax error/, err)
end
def test_self_load_specification_system_exit
@@ -198,23 +192,6 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
# TODO
end
- def test_fetcher
- assert_equal @fetcher, @source_index.fetcher
- end
-
- def test_find_missing
- missing = @source_index.find_missing [@b2.full_name]
- assert_equal [@b2.full_name], missing
- end
-
- def test_find_missing_none_missing
- missing = @source_index.find_missing [
- @a1.full_name, @a2.full_name, @c1_2.full_name
- ]
-
- assert_equal [], missing
- end
-
def test_find_name
assert_equal [@a1, @a2, @a3a], @source_index.find_name('a')
assert_equal [@a2], @source_index.find_name('a', '= 2')
@@ -359,27 +336,6 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
assert_equal 'source index not created from disk', e.message
end
- def test_remove_extra
- @source_index.add_spec @a1
- @source_index.add_spec @a2
- @source_index.add_spec @pl1
-
- @source_index.remove_extra [@a1.full_name, @pl1.full_name]
-
- assert_equal [@a1.full_name],
- @source_index.gems.map { |n,s| n }.sort
- end
-
- def test_remove_extra_no_changes
- gems = [@a1.full_name, @a2.full_name]
- @source_index.add_spec @a1
- @source_index.add_spec @a2
-
- @source_index.remove_extra gems
-
- assert_equal gems, @source_index.gems.map { |n,s| n }.sort
- end
-
def test_remove_spec
deleted = @source_index.remove_spec 'a-1'
@@ -442,20 +398,5 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
assert_match(/^[a-f0-9]{64}$/, sig)
end
- def test_unzip
- input = "x\234+\316\317MU(I\255(\001\000\021\350\003\232"
- assert_equal 'some text', @source_index.unzip(input)
- end
-
- def util_setup_bulk_fetch(compressed)
- source_index = @source_index.dump
-
- if compressed then
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}.Z"] = util_zip source_index
- else
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = source_index
- end
- end
-
end