aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/test_case.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r--lib/rubygems/test_case.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 3ffc608a1c..aebc36bc6c 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# TODO: $SAFE = 1
begin
@@ -542,7 +542,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
# Enables pretty-print for all tests
def mu_pp(obj)
- s = ''
+ s = String.new
s = PP.pp obj, s
s = s.force_encoding(Encoding.default_external) if defined? Encoding
s.chomp
@@ -1307,12 +1307,22 @@ Also, a list:
def vendor_gem name = 'a', version = 1
directory = File.join 'vendor', name
+ FileUtils.mkdir_p directory
+
+ save_gemspec name, version, directory
+ end
+
+ ##
+ # create_gemspec creates gem specification in given +direcotry+ or '.'
+ # for the given +name+ and +version+.
+ #
+ # Yields the +specification+ to the block, if given
+
+ def save_gemspec name = 'a', version = 1, directory = '.'
vendor_spec = Gem::Specification.new name, version do |specification|
yield specification if block_given?
end
- FileUtils.mkdir_p directory
-
open File.join(directory, "#{name}.gemspec"), 'w' do |io|
io.write vendor_spec.to_ruby
end
@@ -1483,3 +1493,4 @@ tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
pid = $$
END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
Gem.clear_paths
+