diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2022-07-17 08:08:51 +0000 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-07-22 12:07:23 +0900 |
commit | d7ffd3fea402239b16833cc434404a7af82d44f3 (patch) | |
tree | 9794942135111c36e6b6bce69e070ca556b89028 /test/rubygems/test_gem_commands_setup_command.rb | |
parent | 388c4e1076ac5a58d5008abc8e0a8d017698875a (diff) | |
download | ruby-d7ffd3fea402239b16833cc434404a7af82d44f3.tar.gz |
RubyGems: Enable Style/StringLiterals cop
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
Diffstat (limited to 'test/rubygems/test_gem_commands_setup_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_setup_command.rb | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index aa5feb9074..1c0963ee96 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/setup_command' +require_relative "helper" +require "rubygems/commands/setup_command" class TestGemCommandsSetupCommand < Gem::TestCase - bundler_gemspec = File.expand_path('../../bundler/lib/bundler/version.rb', __dir__) + bundler_gemspec = File.expand_path("../../bundler/lib/bundler/version.rb", __dir__) if File.exist?(bundler_gemspec) BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1] else @@ -42,11 +42,11 @@ class TestGemCommandsSetupCommand < Gem::TestCase gemspec.bindir = "exe" gemspec.executables = ["bundle", "bundler"] - File.open 'bundler/bundler.gemspec', 'w' do |io| + File.open "bundler/bundler.gemspec", "w" do |io| io.puts gemspec.to_ruby end - File.open(File.join(Gem.default_specifications_dir, "bundler-1.15.4.gemspec"), 'w') do |io| + File.open(File.join(Gem.default_specifications_dir, "bundler-1.15.4.gemspec"), "w") do |io| gemspec.version = "1.15.4" io.puts gemspec.to_ruby end @@ -61,9 +61,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_execute_regenerate_binstubs - gem_bin_path = gem_install 'a' + gem_bin_path = gem_install "a" write_file gem_bin_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end @cmd.options[:document] = [] @@ -73,9 +73,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_execute_no_regenerate_binstubs - gem_bin_path = gem_install 'a' + gem_bin_path = gem_install "a" write_file gem_bin_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end @cmd.options[:document] = [] @@ -86,9 +86,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_execute_regenerate_plugins - gem_plugin_path = gem_install_with_plugin 'a' + gem_plugin_path = gem_install_with_plugin "a" write_file gem_plugin_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end @cmd.options[:document] = [] @@ -98,9 +98,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_execute_no_regenerate_plugins - gem_plugin_path = gem_install_with_plugin 'a' + gem_plugin_path = gem_install_with_plugin "a" write_file gem_plugin_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end @cmd.options[:document] = [] @@ -111,7 +111,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_execute_regenerate_plugins_creates_plugins_dir_if_not_there - gem_plugin_path = gem_install_with_plugin 'a' + gem_plugin_path = gem_install_with_plugin "a" # Simulate gem installed with an older rubygems without a plugins layout FileUtils.rm_rf Gem.plugindir @@ -138,16 +138,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_env_shebang_flag - gem_bin_path = gem_install 'a' + gem_bin_path = gem_install "a" write_file gem_bin_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end @cmd.options[:document] = [] @cmd.options[:env_shebang] = true @cmd.execute - ruby_exec = sprintf Gem.default_exec_format, 'ruby' + ruby_exec = sprintf Gem.default_exec_format, "ruby" bin_env = win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " " assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_gem_bin_path) @@ -159,42 +159,42 @@ class TestGemCommandsSetupCommand < Gem::TestCase def test_destdir_flag_does_not_try_to_write_to_the_default_gem_home FileUtils.chmod "-w", File.join(@gemhome, "plugins") - destdir = File.join(@tempdir, 'foo') + destdir = File.join(@tempdir, "foo") @cmd.options[:destdir] = destdir @cmd.execute bundler_spec.executables.each do |e| - assert_path_exist prepend_destdir(destdir, File.join(@gemhome, 'gems', bundler_spec.full_name, bundler_spec.bindir, e)) + assert_path_exist prepend_destdir(destdir, File.join(@gemhome, "gems", bundler_spec.full_name, bundler_spec.bindir, e)) end end def test_files_in assert_equal %w[rubygems.rb rubygems/requirement.rb rubygems/ssl_certs/rubygems.org/foo.pem], - @cmd.files_in('lib').sort + @cmd.files_in("lib").sort end def test_install_lib @cmd.extend FileUtils - Dir.mktmpdir 'lib' do |dir| + Dir.mktmpdir "lib" do |dir| @cmd.install_lib dir - assert_path_exist File.join(dir, 'rubygems.rb') - assert_path_exist File.join(dir, 'rubygems/ssl_certs/rubygems.org/foo.pem') + assert_path_exist File.join(dir, "rubygems.rb") + assert_path_exist File.join(dir, "rubygems/ssl_certs/rubygems.org/foo.pem") - assert_path_exist File.join(dir, 'bundler.rb') - assert_path_exist File.join(dir, 'bundler/b.rb') + assert_path_exist File.join(dir, "bundler.rb") + assert_path_exist File.join(dir, "bundler/b.rb") - assert_path_exist File.join(dir, 'bundler/templates/.circleci/config.yml') - assert_path_exist File.join(dir, 'bundler/templates/.travis.yml') + assert_path_exist File.join(dir, "bundler/templates/.circleci/config.yml") + assert_path_exist File.join(dir, "bundler/templates/.travis.yml") end end def test_install_default_bundler_gem @cmd.extend FileUtils - bin_dir = File.join(@gemhome, 'bin') + bin_dir = File.join(@gemhome, "bin") @cmd.install_default_bundler_gem bin_dir default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec") @@ -226,11 +226,11 @@ class TestGemCommandsSetupCommand < Gem::TestCase def test_install_default_bundler_gem_with_default_gems_not_installed_at_default_dir @cmd.extend FileUtils - gemhome2 = File.join(@tempdir, 'gemhome2') + gemhome2 = File.join(@tempdir, "gemhome2") Gem.instance_variable_set(:@default_dir, gemhome2) FileUtils.mkdir_p gemhome2 - bin_dir = File.join(gemhome2, 'bin') + bin_dir = File.join(gemhome2, "bin") @cmd.install_default_bundler_gem bin_dir @@ -242,12 +242,12 @@ class TestGemCommandsSetupCommand < Gem::TestCase def test_install_default_bundler_gem_with_force_flag @cmd.extend FileUtils - bin_dir = File.join(@gemhome, 'bin') - bundle_bin = File.join(bin_dir, 'bundle') + bin_dir = File.join(@gemhome, "bin") + bundle_bin = File.join(bin_dir, "bundle") write_file bundle_bin do |f| - f.puts '#!/usr/bin/ruby' - f.puts '' + f.puts "#!/usr/bin/ruby" + f.puts "" f.puts 'echo "hello"' end @@ -272,8 +272,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase FileUtils.chmod "-w", @gemhome - destdir = File.join(@tempdir, 'foo') - bin_dir = File.join(destdir, 'bin') + destdir = File.join(@tempdir, "foo") + bin_dir = File.join(destdir, "bin") @cmd.options[:destdir] = destdir @@ -288,7 +288,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase assert_path_exist prepend_destdir(destdir, new_bundler_specification_path) bundler_spec.executables.each do |e| - assert_path_exist prepend_destdir(destdir, File.join(@gemhome, 'gems', bundler_spec.full_name, bundler_spec.bindir, e)) + assert_path_exist prepend_destdir(destdir, File.join(@gemhome, "gems", bundler_spec.full_name, bundler_spec.bindir, e)) end ensure FileUtils.chmod "+w", @gemhome @@ -297,8 +297,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase def test_install_default_bundler_gem_with_destdir_and_prefix_flags @cmd.extend FileUtils - destdir = File.join(@tempdir, 'foo') - bin_dir = File.join(destdir, 'bin') + destdir = File.join(@tempdir, "foo") + bin_dir = File.join(destdir, "bin") @cmd.options[:destdir] = destdir @cmd.options[:prefix] = "/" @@ -306,28 +306,28 @@ class TestGemCommandsSetupCommand < Gem::TestCase @cmd.install_default_bundler_gem bin_dir bundler_spec.executables.each do |e| - assert_path_exist File.join destdir, 'gems', bundler_spec.full_name, bundler_spec.bindir, e + assert_path_exist File.join destdir, "gems", bundler_spec.full_name, bundler_spec.bindir, e end end def test_remove_old_lib_files lib = RbConfig::CONFIG["sitelibdir"] - lib_rubygems = File.join lib, 'rubygems' - lib_bundler = File.join lib, 'bundler' - lib_rubygems_defaults = File.join lib_rubygems, 'defaults' - lib_bundler_templates = File.join lib_bundler, 'templates' + lib_rubygems = File.join lib, "rubygems" + lib_bundler = File.join lib, "bundler" + lib_rubygems_defaults = File.join lib_rubygems, "defaults" + lib_bundler_templates = File.join lib_bundler, "templates" - securerandom_rb = File.join lib, 'securerandom.rb' + securerandom_rb = File.join lib, "securerandom.rb" - engine_defaults_rb = File.join lib_rubygems_defaults, 'jruby.rb' - os_defaults_rb = File.join lib_rubygems_defaults, 'operating_system.rb' + engine_defaults_rb = File.join lib_rubygems_defaults, "jruby.rb" + os_defaults_rb = File.join lib_rubygems_defaults, "operating_system.rb" - old_gauntlet_rubygems_rb = File.join lib, 'gauntlet_rubygems.rb' + old_gauntlet_rubygems_rb = File.join lib, "gauntlet_rubygems.rb" - old_builder_rb = File.join lib_rubygems, 'builder.rb' - old_format_rb = File.join lib_rubygems, 'format.rb' - old_bundler_c_rb = File.join lib_bundler, 'c.rb' - old_bundler_ci = File.join lib_bundler_templates, '.lecacy_ci', 'config.yml' + old_builder_rb = File.join lib_rubygems, "builder.rb" + old_format_rb = File.join lib_rubygems, "format.rb" + old_bundler_c_rb = File.join lib_bundler, "c.rb" + old_bundler_ci = File.join lib_bundler_templates, ".lecacy_ci", "config.yml" files_that_go = [old_gauntlet_rubygems_rb, old_builder_rb, old_format_rb, old_bundler_c_rb, old_bundler_ci] files_that_stay = [securerandom_rb, engine_defaults_rb, os_defaults_rb] @@ -342,15 +342,15 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def test_remove_old_man_files - man = File.join RbConfig::CONFIG['mandir'], 'man' + man = File.join RbConfig::CONFIG["mandir"], "man" - ruby_1 = File.join man, 'man1', 'ruby.1' - bundle_b_1 = File.join man, 'man1', 'bundle-b.1' - bundle_b_1_ronn = File.join man, 'man1', 'bundle-b.1.ronn' - bundle_b_1_txt = File.join man, 'man1', 'bundle-b.1.txt' - gemfile_5 = File.join man, 'man5', 'gemfile.5' - gemfile_5_ronn = File.join man, 'man5', 'gemfile.5.ronn' - gemfile_5_txt = File.join man, 'man5', 'gemfile.5.txt' + ruby_1 = File.join man, "man1", "ruby.1" + bundle_b_1 = File.join man, "man1", "bundle-b.1" + bundle_b_1_ronn = File.join man, "man1", "bundle-b.1.ronn" + bundle_b_1_txt = File.join man, "man1", "bundle-b.1.txt" + gemfile_5 = File.join man, "man5", "gemfile.5" + gemfile_5_ronn = File.join man, "man5", "gemfile.5.ronn" + gemfile_5_txt = File.join man, "man5", "gemfile.5.txt" files_that_go = [bundle_b_1, bundle_b_1_txt, bundle_b_1_ronn, gemfile_5, gemfile_5_txt, gemfile_5_ronn] files_that_stay = [ruby_1] @@ -368,9 +368,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase @default_external = @ui.outs.external_encoding @ui.outs.set_encoding Encoding::US_ASCII - @cmd.options[:previous_version] = Gem::Version.new '2.0.2' + @cmd.options[:previous_version] = Gem::Version.new "2.0.2" - File.open 'CHANGELOG.md', 'w' do |io| + File.open "CHANGELOG.md", "w" do |io| io.puts <<-HISTORY_TXT # #{Gem::VERSION} / 2013-03-26 @@ -417,7 +417,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase list.each do |file| FileUtils.mkdir_p File.dirname(file) - File.open file, 'w' do |io| + File.open file, "w" do |io| io.puts "# #{File.basename(file)}" end end @@ -428,18 +428,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase s.executables = [name] s.files = %W[bin/#{name}] end - write_file File.join @tempdir, 'bin', name do |f| - f.puts '#!/usr/bin/ruby' + write_file File.join @tempdir, "bin", name do |f| + f.puts "#!/usr/bin/ruby" end install_gem gem - File.join @gemhome, 'bin', name + File.join @gemhome, "bin", name end def gem_install_with_plugin(name) gem = util_spec name do |s| s.files = %W[lib/rubygems_plugin.rb] end - write_file File.join @tempdir, 'lib', 'rubygems_plugin.rb' do |f| + write_file File.join @tempdir, "lib", "rubygems_plugin.rb" do |f| f.puts "require '#{gem.plugins.first}'" end install_gem gem @@ -448,15 +448,15 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def default_gem_bin_path - File.join RbConfig::CONFIG['bindir'], 'gem' + File.join RbConfig::CONFIG["bindir"], "gem" end def default_bundle_bin_path - File.join RbConfig::CONFIG['bindir'], 'bundle' + File.join RbConfig::CONFIG["bindir"], "bundle" end def default_bundler_bin_path - File.join RbConfig::CONFIG['bindir'], 'bundler' + File.join RbConfig::CONFIG["bindir"], "bundler" end def previous_bundler_specification_path @@ -476,6 +476,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase end def prepend_destdir(destdir, path) - File.join(destdir, path.gsub(/^[a-zA-Z]:/, '')) + File.join(destdir, path.gsub(/^[a-zA-Z]:/, "")) end end unless Gem.java_platform? |