summaryrefslogtreecommitdiff
path: root/lib/rubygems/test_utilities.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/test_utilities.rb')
-rw-r--r--lib/rubygems/test_utilities.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index e8709b9be3..8b23d3236e 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -34,16 +34,20 @@ class Gem::FakeFetcher
path = path.to_s
@paths << path
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
- data = @data[path]
- if data.nil? then
- raise Gem::RemoteFetcher::FetchError.new('no data', path)
+ unless @data.key? path then
+ raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
end
+ data = @data[path]
+
if data.respond_to?(:call) then
data.call
else
- data = Gem.gunzip data if path.to_s =~ /gz$/ unless data.empty?
+ if path.to_s =~ /gz$/ and not data.nil? and not data.empty? then
+ data = Gem.gunzip data
+ end
+
data
end
end
@@ -51,13 +55,15 @@ class Gem::FakeFetcher
def fetch_size(path)
path = path.to_s
@paths << path
+
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
- data = @data[path]
- if data.nil? then
- raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", nil)
+ unless @data.key? path then
+ raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
end
+ data = @data[path]
+
data.respond_to?(:call) ? data.call : data.length
end