summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-04-27 21:37:03 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 14:13:29 +0900
commit5400811db94361ba20e2e2467a77b75355c232e9 (patch)
treeafd79e33eae4fa7b7aabae8ce7050fc0da05f54c
parent74867e2dc1b68ca7831876991c6f34c6309e018d (diff)
[rubygems/rubygems] Refactor dummy file creation
https://github.com/rubygems/rubygems/commit/665099fe53
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3092
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb90
1 files changed, 26 insertions, 64 deletions
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 140e75d684..bab2707ef5 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -20,39 +20,17 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd = Gem::Commands::SetupCommand.new
@cmd.options[:prefix] = @install_dir
- FileUtils.mkdir_p 'bin'
- FileUtils.mkdir_p 'lib/rubygems/ssl_certs/rubygems.org'
-
- File.open 'bin/gem', 'w' do |io|
- io.puts '# gem'
- end
-
- File.open 'lib/rubygems.rb', 'w' do |io|
- io.puts '# rubygems.rb'
- end
-
- File.open 'lib/rubygems/test_case.rb', 'w' do |io|
- io.puts '# test_case.rb'
- end
-
- File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io|
- io.puts '# foo.pem'
- end
-
- FileUtils.mkdir_p 'bundler/exe'
- FileUtils.mkdir_p 'bundler/lib/bundler'
-
- File.open 'bundler/exe/bundle', 'w' do |io|
- io.puts '# bundle'
- end
-
- File.open 'bundler/lib/bundler.rb', 'w' do |io|
- io.puts '# bundler.rb'
- end
-
- File.open 'bundler/lib/bundler/b.rb', 'w' do |io|
- io.puts '# b.rb'
- end
+ filelist = %w[
+ bin/gem
+ lib/rubygems.rb
+ lib/rubygems/test_case.rb
+ lib/rubygems/ssl_certs/rubygems.org/foo.pem
+ bundler/exe/bundle
+ bundler/lib/bundler.rb
+ bundler/lib/bundler/b.rb
+ ]
+
+ create_dummy_files(filelist)
gemspec = Gem::Specification.new
gemspec.author = "Us"
@@ -276,42 +254,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
old_format_rb = File.join lib_rubygems, 'format.rb'
old_bundler_c_rb = File.join lib_bundler, 'c.rb'
- FileUtils.mkdir_p lib_rubygems_defaults
- FileUtils.mkdir_p lib_bundler
+ files_that_go = [old_builder_rb, old_format_rb, old_bundler_c_rb]
+ files_that_stay = [securerandom_rb, engine_defaults_rb, os_defaults_rb]
- File.open securerandom_rb, 'w' do |io|
- io.puts '# securerandom.rb'
- end
-
- File.open old_builder_rb, 'w' do |io|
- io.puts '# builder.rb'
- end
-
- File.open old_format_rb, 'w' do |io|
- io.puts '# format.rb'
- end
-
- File.open old_bundler_c_rb, 'w' do |io|
- io.puts '# c.rb'
- end
-
- File.open engine_defaults_rb, 'w' do |io|
- io.puts '# jruby.rb'
- end
-
- File.open os_defaults_rb, 'w' do |io|
- io.puts '# operating_system.rb'
- end
+ create_dummy_files(files_that_go + files_that_stay)
@cmd.remove_old_lib_files lib
- refute_path_exists old_builder_rb
- refute_path_exists old_format_rb
- refute_path_exists old_bundler_c_rb
+ files_that_go.each {|file| refute_path_exists file }
- assert_path_exists securerandom_rb
- assert_path_exists engine_defaults_rb
- assert_path_exists os_defaults_rb
+ files_that_stay.each {|file| assert_path_exists file }
end
def test_show_release_notes
@@ -365,6 +317,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
private
+ def create_dummy_files(list)
+ list.each do |file|
+ FileUtils.mkdir_p File.dirname(file)
+
+ File.open file, 'w' do |io|
+ io.puts "# #{File.basename(file)}"
+ end
+ end
+ end
+
def gem_install(name)
gem = util_spec name do |s|
s.executables = [name]