diff --git a/.rubocop.yml b/.rubocop.yml index a6823aca5e47..c1e49d032c81 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -163,6 +163,9 @@ Style/BlockDelimiters: Style/PercentLiteralDelimiters: Enabled: true +Style/StringLiterals: + EnforcedStyle: double_quotes + # Having these make it easier to *not* forget to add one when adding a new # value and you can simply copy the previous line. Style/TrailingCommaInArrayLiteral: diff --git a/Rakefile b/Rakefile index 93149496d751..c4911bf33c5c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ RakeFileUtils.verbose_flag = false -require 'rubygems' -require 'rubygems/package_task' +require "rubygems" +require "rubygems/package_task" require "rake/testtask" desc "Setup Rubygems dev environment" @@ -55,32 +55,32 @@ end Rake::TestTask.new do |t| t.ruby_opts = %w[-w] - t.ruby_opts << '-rdevkit' if RbConfig::CONFIG['host_os'].include?('mingw') + t.ruby_opts << "-rdevkit" if RbConfig::CONFIG["host_os"].include?("mingw") t.libs << "test" t.libs << "bundler/lib" - t.test_files = FileList['test/**/test_*.rb'] + t.test_files = FileList["test/**/test_*.rb"] end -namespace 'test' do - desc 'Run each test isolatedly by specifying the relative test file path' - task 'isolated' do - FileList['test/**/test_*.rb'].each do |file| - sh Gem.ruby, '-Ilib:test:bundler/lib', file +namespace "test" do + desc "Run each test isolatedly by specifying the relative test file path" + task "isolated" do + FileList["test/**/test_*.rb"].each do |file| + sh Gem.ruby, "-Ilib:test:bundler/lib", file end end end task :default => :test -spec = Gem::Specification.load('rubygems-update.gemspec') +spec = Gem::Specification.load("rubygems-update.gemspec") v = spec.version -require 'rdoc/task' +require "rdoc/task" -RDoc::Task.new :rdoc => 'docs', :clobber_rdoc => 'clobber_docs' do |doc| - doc.main = 'README.md' +RDoc::Task.new :rdoc => "docs", :clobber_rdoc => "clobber_docs" do |doc| + doc.main = "README.md" doc.title = "RubyGems #{v} API Documentation" rdoc_files = Rake::FileList.new %w[lib bundler/lib] @@ -91,7 +91,7 @@ RDoc::Task.new :rdoc => 'docs', :clobber_rdoc => 'clobber_docs' do |doc| doc.rdoc_files = rdoc_files - doc.rdoc_dir = 'doc' + doc.rdoc_dir = "doc" end # No big deal if Automatiek is not available. This might be just because @@ -218,12 +218,12 @@ Gem::PackageTask.new(spec) {} Rake::Task["package"].enhance ["pkg/rubygems-#{v}.tgz", "pkg/rubygems-#{v}.zip"] file "pkg/rubygems-#{v}" => "pkg/rubygems-update-#{v}" do |t| - require 'find' + require "find" dest_root = File.expand_path t.name cd t.source do - Find.find '.' do |file| + Find.find "." do |file| dest = File.expand_path file, dest_root if File.directory? file @@ -237,7 +237,7 @@ file "pkg/rubygems-#{v}" => "pkg/rubygems-update-#{v}" do |t| end file "pkg/rubygems-#{v}.zip" => "pkg/rubygems-#{v}" do - cd 'pkg' do + cd "pkg" do if Gem.win_platform? sh "7z a rubygems-#{v}.zip rubygems-#{v}" else @@ -247,8 +247,8 @@ file "pkg/rubygems-#{v}.zip" => "pkg/rubygems-#{v}" do end file "pkg/rubygems-#{v}.tgz" => "pkg/rubygems-#{v}" do - cd 'pkg' do - if Gem.win_platform? && RUBY_VERSION < '2.4' + cd "pkg" do + if Gem.win_platform? && RUBY_VERSION < "2.4" sh "7z a -ttar rubygems-#{v}.tar rubygems-#{v}" sh "7z a -tgzip rubygems-#{v}.tgz rubygems-#{v}.tar" else @@ -275,59 +275,59 @@ desc "Upload release to S3" task :upload_to_s3 do require "aws-sdk-s3" - s3 = Aws::S3::Resource.new(region:'us-west-2') + s3 = Aws::S3::Resource.new(region:"us-west-2") %w[zip tgz].each do |ext| - obj = s3.bucket('oregon.production.s3.rubygems.org').object("rubygems/rubygems-#{v}.#{ext}") - obj.upload_file("pkg/rubygems-#{v}.#{ext}", acl: 'public-read') + obj = s3.bucket("oregon.production.s3.rubygems.org").object("rubygems/rubygems-#{v}.#{ext}") + obj.upload_file("pkg/rubygems-#{v}.#{ext}", acl: "public-read") end end desc "Upload release to rubygems.org" task :upload => %w[upload_to_github upload_to_s3] -directory '../guides.rubygems.org' do - sh 'git', 'clone', - 'https://github.com/rubygems/guides.git', - '../guides.rubygems.org' +directory "../guides.rubygems.org" do + sh "git", "clone", + "https://github.com/rubygems/guides.git", + "../guides.rubygems.org" end -namespace 'guides' do - task 'pull' => %w[../guides.rubygems.org] do - chdir '../guides.rubygems.org' do - sh 'git', 'pull' +namespace "guides" do + task "pull" => %w[../guides.rubygems.org] do + chdir "../guides.rubygems.org" do + sh "git", "pull" end end - task 'update' => %w[../guides.rubygems.org] do - lib_dir = File.join Dir.pwd, 'lib' + task "update" => %w[../guides.rubygems.org] do + lib_dir = File.join Dir.pwd, "lib" - chdir '../guides.rubygems.org' do - ruby '-I', lib_dir, '-S', 'rake', 'command_guide' - ruby '-I', lib_dir, '-S', 'rake', 'spec_guide' + chdir "../guides.rubygems.org" do + ruby "-I", lib_dir, "-S", "rake", "command_guide" + ruby "-I", lib_dir, "-S", "rake", "spec_guide" end end - task 'commit' => %w[../guides.rubygems.org] do - chdir '../guides.rubygems.org' do + task "commit" => %w[../guides.rubygems.org] do + chdir "../guides.rubygems.org" do begin - sh 'git', 'diff', '--quiet' + sh "git", "diff", "--quiet" rescue - sh 'git', 'commit', 'command-reference.md', 'specification-reference.md', - '-m', "Rebuild for RubyGems #{v}" + sh "git", "commit", "command-reference.md", "specification-reference.md", + "-m", "Rebuild for RubyGems #{v}" end end end - task 'push' => %w[../guides.rubygems.org] do - chdir '../guides.rubygems.org' do - sh 'git', 'push' + task "push" => %w[../guides.rubygems.org] do + chdir "../guides.rubygems.org" do + sh "git", "push" end end - desc 'Updates and publishes the guides for the just-released RubyGems' - task 'publish' + desc "Updates and publishes the guides for the just-released RubyGems" + task "publish" - task 'publish' => %w[ + task "publish" => %w[ guides:pull guides:update guides:commit @@ -335,20 +335,20 @@ namespace 'guides' do ] end -directory '../blog.rubygems.org' do - sh 'git', 'clone', - 'https://github.com/rubygems/rubygems.github.io.git', - '../blog.rubygems.org' +directory "../blog.rubygems.org" do + sh "git", "clone", + "https://github.com/rubygems/rubygems.github.io.git", + "../blog.rubygems.org" end -namespace 'blog' do - date = Time.now.strftime '%Y-%m-%d' +namespace "blog" do + date = Time.now.strftime "%Y-%m-%d" post_page = "_posts/#{date}-#{v}-released.md" - checksums = '' + checksums = "" - task 'checksums' => 'package' do - require 'net/http' - Dir['pkg/*{tgz,zip,gem}'].each do |file| + task "checksums" => "package" do + require "net/http" + Dir["pkg/*{tgz,zip,gem}"].each do |file| digest = OpenSSL::Digest::SHA256.file(file).hexdigest basename = File.basename(file) @@ -372,26 +372,26 @@ namespace 'blog' do end end - task 'pull' => %w[../blog.rubygems.org] do - chdir '../blog.rubygems.org' do - sh 'git', 'pull' + task "pull" => %w[../blog.rubygems.org] do + chdir "../blog.rubygems.org" do + sh "git", "pull" end end - path = File.join '../blog.rubygems.org', post_page + path = File.join "../blog.rubygems.org", post_page - task 'update' => [path] + task "update" => [path] - file path => 'checksums' do + file path => "checksums" do name = `git config --get user.name`.strip email = `git config --get user.email`.strip require_relative "util/changelog" history = Changelog.for_rubygems(v.to_s) - require 'tempfile' + require "tempfile" - Tempfile.open 'blog_post' do |io| + Tempfile.open "blog_post" do |io| io.write <<-ANNOUNCEMENT --- title: #{v} Released @@ -420,28 +420,28 @@ SHA256 Checksums: io.flush - sh(ENV['EDITOR'] || 'vim', io.path) + sh(ENV["EDITOR"] || "vim", io.path) FileUtils.cp io.path, path end end - task 'commit' => %w[../blog.rubygems.org] do - chdir '../blog.rubygems.org' do - sh 'git', 'add', post_page - sh 'git', 'commit', post_page, - '-m', "Added #{v} release announcement" + task "commit" => %w[../blog.rubygems.org] do + chdir "../blog.rubygems.org" do + sh "git", "add", post_page + sh "git", "commit", post_page, + "-m", "Added #{v} release announcement" end end - task 'push' => %w[../blog.rubygems.org] do - chdir '../blog.rubygems.org' do - sh 'git', 'push' + task "push" => %w[../blog.rubygems.org] do + chdir "../blog.rubygems.org" do + sh "git", "push" end end - desc 'Updates and publishes the blog for the just-released RubyGems' - task 'publish' => %w[ + desc "Updates and publishes the blog for the just-released RubyGems" + task "publish" => %w[ blog:pull blog:update blog:commit @@ -471,7 +471,7 @@ end desc "Update the manifest to reflect what's on disk" task :update_manifest do - File.open('Manifest.txt', 'w') {|f| f.puts(Rubygems::ProjectFiles.all) } + File.open("Manifest.txt", "w") {|f| f.puts(Rubygems::ProjectFiles.all) } end desc "Check the manifest is up to date" @@ -488,12 +488,12 @@ end namespace :bundler do task :build_metadata do - chdir('bundler') { sh "rake build_metadata" } + chdir("bundler") { sh "rake build_metadata" } end namespace :build_metadata do task :clean do - chdir('bundler') { sh "rake build_metadata:clean" } + chdir("bundler") { sh "rake build_metadata:clean" } end end end diff --git a/bin/gem b/bin/gem index 133774ff114f..88534ce8f278 100755 --- a/bin/gem +++ b/bin/gem @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require 'rubygems' -require 'rubygems/gem_runner' +require "rubygems" +require "rubygems/gem_runner" args = ARGV.clone diff --git a/bin/update_rubygems b/bin/update_rubygems index 96fde7bce4bf..86f74f8f6825 100755 --- a/bin/update_rubygems +++ b/bin/update_rubygems @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require 'rubygems' +require "rubygems" -if ARGV.include? '-h' or ARGV.include? '--help' +if ARGV.include? "-h" or ARGV.include? "--help" $stderr.puts "rubygems_update [options]" $stderr.puts $stderr.puts "This will install the latest version of RubyGems." @@ -17,7 +17,7 @@ if ARGV.include? '-h' or ARGV.include? '--help' end unless ARGV.grep(/--version=([\d\.]*)/).empty? - exec Gem.ruby, '-S', $PROGRAM_NAME, "_#{$1}_" + exec Gem.ruby, "-S", $PROGRAM_NAME, "_#{$1}_" end update_dir = $LOAD_PATH.find {|dir| dir =~ /rubygems-update/ } @@ -32,5 +32,5 @@ else update_dir = File.dirname(update_dir) Dir.chdir update_dir ENV["GEM_PREV_VER"] = Gem::VERSION - abort unless system(Gem.ruby, 'setup.rb', *ARGV) + abort unless system(Gem.ruby, "setup.rb", *ARGV) end diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 13c23cda03f5..e59cd26870b3 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -5,18 +5,18 @@ # See LICENSE.txt for permissions. #++ -require 'rbconfig' +require "rbconfig" module Gem VERSION = "3.4.0.dev".freeze end # Must be first since it unloads the prelude from 1.9.2 -require_relative 'rubygems/compatibility' +require_relative "rubygems/compatibility" -require_relative 'rubygems/defaults' -require_relative 'rubygems/deprecate' -require_relative 'rubygems/errors' +require_relative "rubygems/defaults" +require_relative "rubygems/deprecate" +require_relative "rubygems/errors" ## # RubyGems is the Ruby standard for publishing and managing third party @@ -117,11 +117,11 @@ module Gem # Taint support is deprecated in Ruby 2.7. # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)", # to avoid deprecation warnings in Ruby 2.7. - UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc {} + UNTAINT = RUBY_VERSION < "2.7" ? :untaint.to_sym : proc {} # When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" || - (RUBY_ENGINE == "ruby" && RUBY_VERSION >= '3.0') + (RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.0") ## # An Array of Regexps that match windows Ruby platforms. @@ -293,14 +293,14 @@ def self.activate_bin_path(name, exec_name = nil, *requirements) # :nodoc: # The mode needed to read a file as straight binary. def self.binary_mode - 'rb' + "rb" end ## # The path where gem executables are to be installed. def self.bindir(install_dir=Gem.dir) - return File.join install_dir, 'bin' unless + return File.join install_dir, "bin" unless install_dir.to_s == Gem.default_dir.to_s Gem.default_bindir end @@ -309,7 +309,7 @@ def self.bindir(install_dir=Gem.dir) # The path were rubygems plugins are to be installed. def self.plugindir(install_dir=Gem.dir) - File.join install_dir, 'plugins' + File.join install_dir, "plugins" end ## @@ -353,7 +353,7 @@ def self.datadir(gem_name) # A Zlib::Deflate.deflate wrapper def self.deflate(data) - require 'zlib' + require "zlib" Zlib::Deflate.deflate data end @@ -375,7 +375,7 @@ def self.paths=(env) target = {} env.each_pair do |k,v| case k - when 'GEM_HOME', 'GEM_PATH', 'GEM_SPEC_CACHE' + when "GEM_HOME", "GEM_PATH", "GEM_SPEC_CACHE" case v when nil, String target[k] = v @@ -450,7 +450,7 @@ def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc: subdir = File.join dir, name next if File.exist? subdir - require 'fileutils' + require "fileutils" begin FileUtils.mkdir_p subdir, **options @@ -466,7 +466,7 @@ def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc: # distinction as extensions cannot be shared between the two. def self.extension_api_version # :nodoc: - if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] + if "no" == RbConfig::CONFIG["ENABLE_SHARED"] "#{ruby_api_version}-static" else ruby_api_version @@ -576,7 +576,7 @@ def self.load_path_insert_index return i if path.instance_variable_defined?(:@gem_prelude_index) end - index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir'] + index = $LOAD_PATH.index RbConfig::CONFIG["sitelibdir"] index || 0 end @@ -607,10 +607,10 @@ def self.add_to_load_path(*paths) def self.load_yaml return if @yaml_loaded - require 'psych' - require_relative 'rubygems/psych_tree' + require "psych" + require_relative "rubygems/psych_tree" - require_relative 'rubygems/safe_yaml' + require_relative "rubygems/safe_yaml" @yaml_loaded = true end @@ -741,9 +741,9 @@ def self.pre_uninstall(&hook) def self.prefix prefix = File.dirname RUBYGEMS_DIR - if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and - prefix != File.expand_path(RbConfig::CONFIG['libdir']) and - 'lib' == File.basename(RUBYGEMS_DIR) + if prefix != File.expand_path(RbConfig::CONFIG["sitelibdir"]) and + prefix != File.expand_path(RbConfig::CONFIG["libdir"]) and + "lib" == File.basename(RUBYGEMS_DIR) prefix end end @@ -759,11 +759,11 @@ def self.refresh # Safely read a file in binary mode on all platforms. def self.read_binary(path) - open_file(path, 'rb+') do |io| + open_file(path, "rb+") do |io| io.read end rescue Errno::EACCES, Errno::EROFS - open_file(path, 'rb') do |io| + open_file(path, "rb") do |io| io.read end end @@ -771,7 +771,7 @@ def self.read_binary(path) ## # Safely write a file in binary mode on all platforms. def self.write_binary(path, data) - open_file(path, 'wb') do |io| + open_file(path, "wb") do |io| io.write data end end @@ -816,13 +816,13 @@ def self.ruby # Returns a String containing the API compatibility version of Ruby def self.ruby_api_version - @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup + @ruby_api_version ||= RbConfig::CONFIG["ruby_version"].dup end def self.env_requirement(gem_name) @env_requirements_by_name ||= {} @env_requirements_by_name[gem_name] ||= begin - req = ENV["GEM_REQUIREMENT_#{gem_name.upcase}"] || '>= 0'.freeze + req = ENV["GEM_REQUIREMENT_#{gem_name.upcase}"] || ">= 0".freeze Gem::Requirement.create(req) end end @@ -845,7 +845,7 @@ def self.latest_spec_for(name) # Returns the latest release version of RubyGems. def self.latest_rubygems_version - latest_version_for('rubygems-update') or + latest_version_for("rubygems-update") or raise "Can't find 'rubygems-update' in any repo. Check `gem source list`." end @@ -940,8 +940,8 @@ def self.plugin_suffix_regexp # Suffixes for require-able paths. def self.suffixes - @suffixes ||= ['', - '.rb', + @suffixes ||= ["", + ".rb", *%w[DLEXT DLEXT2].map do |key| val = RbConfig::CONFIG[key] next unless val and not val.empty? @@ -970,7 +970,7 @@ def self.time(msg, width = 0, display = Gem.configuration.verbose) # Lazily loads DefaultUserInteraction and returns the default UI. def self.ui - require_relative 'rubygems/user_interaction' + require_relative "rubygems/user_interaction" Gem::DefaultUserInteraction.ui end @@ -992,7 +992,7 @@ def self.use_paths(home, *paths) def self.win_platform? if @@win_platform.nil? - ruby_platform = RbConfig::CONFIG['host_os'] + ruby_platform = RbConfig::CONFIG["host_os"] @@win_platform = !!WIN_PATTERNS.find {|r| ruby_platform =~ r } end @@ -1071,7 +1071,7 @@ def self.load_env_plugins def self.use_gemdeps(path = nil) raise_exception = path - path ||= ENV['RUBYGEMS_GEMDEPS'] + path ||= ENV["RUBYGEMS_GEMDEPS"] return unless path path = path.dup @@ -1096,7 +1096,7 @@ def self.use_gemdeps(path = nil) end ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path) - require_relative 'rubygems/user_interaction' + require_relative "rubygems/user_interaction" require "bundler" begin Gem::DefaultUserInteraction.use_ui(ui) do @@ -1293,34 +1293,34 @@ def default_gem_load_paths MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/".freeze - autoload :BundlerVersionFinder, File.expand_path('rubygems/bundler_version_finder', __dir__) - autoload :ConfigFile, File.expand_path('rubygems/config_file', __dir__) - autoload :Dependency, File.expand_path('rubygems/dependency', __dir__) - autoload :DependencyList, File.expand_path('rubygems/dependency_list', __dir__) - autoload :Installer, File.expand_path('rubygems/installer', __dir__) - autoload :Licenses, File.expand_path('rubygems/util/licenses', __dir__) - autoload :NameTuple, File.expand_path('rubygems/name_tuple', __dir__) - autoload :PathSupport, File.expand_path('rubygems/path_support', __dir__) - autoload :RequestSet, File.expand_path('rubygems/request_set', __dir__) - autoload :Requirement, File.expand_path('rubygems/requirement', __dir__) - autoload :Resolver, File.expand_path('rubygems/resolver', __dir__) - autoload :Source, File.expand_path('rubygems/source', __dir__) - autoload :SourceList, File.expand_path('rubygems/source_list', __dir__) - autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__) - autoload :SpecificationPolicy, File.expand_path('rubygems/specification_policy', __dir__) - autoload :Util, File.expand_path('rubygems/util', __dir__) - autoload :Version, File.expand_path('rubygems/version', __dir__) + autoload :BundlerVersionFinder, File.expand_path("rubygems/bundler_version_finder", __dir__) + autoload :ConfigFile, File.expand_path("rubygems/config_file", __dir__) + autoload :Dependency, File.expand_path("rubygems/dependency", __dir__) + autoload :DependencyList, File.expand_path("rubygems/dependency_list", __dir__) + autoload :Installer, File.expand_path("rubygems/installer", __dir__) + autoload :Licenses, File.expand_path("rubygems/util/licenses", __dir__) + autoload :NameTuple, File.expand_path("rubygems/name_tuple", __dir__) + autoload :PathSupport, File.expand_path("rubygems/path_support", __dir__) + autoload :RequestSet, File.expand_path("rubygems/request_set", __dir__) + autoload :Requirement, File.expand_path("rubygems/requirement", __dir__) + autoload :Resolver, File.expand_path("rubygems/resolver", __dir__) + autoload :Source, File.expand_path("rubygems/source", __dir__) + autoload :SourceList, File.expand_path("rubygems/source_list", __dir__) + autoload :SpecFetcher, File.expand_path("rubygems/spec_fetcher", __dir__) + autoload :SpecificationPolicy, File.expand_path("rubygems/specification_policy", __dir__) + autoload :Util, File.expand_path("rubygems/util", __dir__) + autoload :Version, File.expand_path("rubygems/version", __dir__) end -require_relative 'rubygems/exceptions' -require_relative 'rubygems/specification' +require_relative "rubygems/exceptions" +require_relative "rubygems/specification" # REFACTOR: This should be pulled out into some kind of hacks file. begin ## # Defaults the operating system (or packager) wants to provide for RubyGems. - require 'rubygems/defaults/operating_system' + require "rubygems/defaults/operating_system" rescue LoadError # Ignored rescue StandardError => e @@ -1345,6 +1345,6 @@ def default_gem_load_paths # Loads the default specs. Gem::Specification.load_defaults -require_relative 'rubygems/core_ext/kernel_gem' -require_relative 'rubygems/core_ext/kernel_require' -require_relative 'rubygems/core_ext/kernel_warn' +require_relative "rubygems/core_ext/kernel_gem" +require_relative "rubygems/core_ext/kernel_require" +require_relative "rubygems/core_ext/kernel_warn" diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index b3b63b51aae5..526a5069c242 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -47,7 +47,7 @@ class << self # directory. def gem_build_complete_path # :nodoc: - File.join extension_dir, 'gem.build_complete' + File.join extension_dir, "gem.build_complete" end ## @@ -103,7 +103,7 @@ def extension_dir def extensions_dir Gem.default_ext_dir_for(base_dir) || - File.join(base_dir, 'extensions', Gem::Platform.local.to_s, + File.join(base_dir, "extensions", Gem::Platform.local.to_s, Gem.extension_api_version) end diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index f74cb419f9c4..9fc3360fa13c 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require_relative 'optparse' -require_relative 'requirement' -require_relative 'user_interaction' +require_relative "optparse" +require_relative "requirement" +require_relative "user_interaction" ## # Base class for all Gem commands. When creating a new gem command, define @@ -76,7 +76,7 @@ def self.extra_args=(value) when Array @extra_args = value when String - @extra_args = value.split(' ') + @extra_args = value.split(" ") end end @@ -556,7 +556,7 @@ def create_option_parser def configure_options(header, option_list) return if option_list.nil? or option_list.empty? - header = header.to_s.empty? ? '' : "#{header} " + header = header.to_s.empty? ? "" : "#{header} " @parser.separator " #{header}Options:" option_list.each do |args, handler| @@ -565,7 +565,7 @@ def configure_options(header, option_list) end end - @parser.separator '' + @parser.separator "" end ## @@ -578,13 +578,13 @@ def wrap(text, width) # :doc: # ---------------------------------------------------------------- # Add the options common to all commands. - add_common_option('-h', '--help', - 'Get help on this command') do |value, options| + add_common_option("-h", "--help", + "Get help on this command") do |value, options| options[:help] = true end - add_common_option('-V', '--[no-]verbose', - 'Set the verbose level of output') do |value, options| + add_common_option("-V", "--[no-]verbose", + "Set the verbose level of output") do |value, options| # Set us to "really verbose" so the progress meter works if Gem.configuration.verbose and value Gem.configuration.verbose = 1 @@ -593,7 +593,7 @@ def wrap(text, width) # :doc: end end - add_common_option('-q', '--quiet', 'Silence command progress meter') do |value, options| + add_common_option("-q", "--quiet", "Silence command progress meter") do |value, options| Gem.configuration.verbose = false end @@ -606,20 +606,20 @@ def wrap(text, width) # :doc: # commands. Both options are actually handled before the other # options get parsed. - add_common_option('--config-file FILE', - 'Use this config file instead of default') do + add_common_option("--config-file FILE", + "Use this config file instead of default") do end - add_common_option('--backtrace', - 'Show stack backtrace on errors') do + add_common_option("--backtrace", + "Show stack backtrace on errors") do end - add_common_option('--debug', - 'Turn on Ruby debugging') do + add_common_option("--debug", + "Turn on Ruby debugging") do end - add_common_option('--norc', - 'Avoid loading any .gemrc file') do + add_common_option("--norc", + "Avoid loading any .gemrc file") do end # :stopdoc: diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb index e421f89884c9..9d49138ae71a 100644 --- a/lib/rubygems/command_manager.rb +++ b/lib/rubygems/command_manager.rb @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require_relative 'command' -require_relative 'user_interaction' -require_relative 'text' +require_relative "command" +require_relative "user_interaction" +require_relative "text" ## # The command manager registers and installs all the individual sub-commands @@ -73,9 +73,9 @@ class Gem::CommandManager ].freeze ALIAS_COMMANDS = { - 'i' => 'install', - 'login' => 'signin', - 'logout' => 'signout', + "i" => "install", + "login" => "signin", + "logout" => "signout", }.freeze ## @@ -104,7 +104,7 @@ def self.reset # Register all the subcommands supported by the gem command. def initialize - require 'timeout' + require "timeout" @commands = {} BUILTIN_COMMANDS.each do |name| @@ -169,10 +169,10 @@ def process_args(args, build_args=nil) end case args.first - when '-h', '--help' then + when "-h", "--help" then say Gem::Command::HELP terminate_interaction 0 - when '-v', '--version' then + when "-v", "--version" then say Gem::VERSION terminate_interaction 0 when /^-/ then diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb index 6d1a057dfa73..accbd7e97d90 100644 --- a/lib/rubygems/commands/build_command.rb +++ b/lib/rubygems/commands/build_command.rb @@ -1,29 +1,29 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../package' -require_relative '../version_option' +require_relative "../command" +require_relative "../package" +require_relative "../version_option" class Gem::Commands::BuildCommand < Gem::Command include Gem::VersionOption def initialize - super 'build', 'Build a gem from a gemspec' + super "build", "Build a gem from a gemspec" add_platform_option - add_option '--force', 'skip validation of the spec' do |value, options| + add_option "--force", "skip validation of the spec" do |value, options| options[:force] = true end - add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options| + add_option "--strict", "consider warnings as errors when validating the spec" do |value, options| options[:strict] = true end - add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options| + add_option "-o", "--output FILE", "output gem with the given filename" do |value, options| options[:output] = value end - add_option '-C PATH', 'Run as if gem build was started in instead of the current working directory.' do |value, options| + add_option "-C PATH", "Run as if gem build was started in instead of the current working directory." do |value, options| options[:build_path] = value end end diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index b59564d57594..56bf5ce6891b 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -1,69 +1,69 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../security' +require_relative "../command" +require_relative "../security" class Gem::Commands::CertCommand < Gem::Command def initialize - super 'cert', 'Manage RubyGems certificates and signing settings', + super "cert", "Manage RubyGems certificates and signing settings", :add => [], :remove => [], :list => [], :build => [], :sign => [] - add_option('-a', '--add CERT', - 'Add a trusted certificate.') do |cert_file, options| + add_option("-a", "--add CERT", + "Add a trusted certificate.") do |cert_file, options| options[:add] << open_cert(cert_file) end - add_option('-l', '--list [FILTER]', - 'List trusted certificates where the', - 'subject contains FILTER') do |filter, options| - filter ||= '' + add_option("-l", "--list [FILTER]", + "List trusted certificates where the", + "subject contains FILTER") do |filter, options| + filter ||= "" options[:list] << filter end - add_option('-r', '--remove FILTER', - 'Remove trusted certificates where the', - 'subject contains FILTER') do |filter, options| + add_option("-r", "--remove FILTER", + "Remove trusted certificates where the", + "subject contains FILTER") do |filter, options| options[:remove] << filter end - add_option('-b', '--build EMAIL_ADDR', - 'Build private key and self-signed', - 'certificate for EMAIL_ADDR') do |email_address, options| + add_option("-b", "--build EMAIL_ADDR", + "Build private key and self-signed", + "certificate for EMAIL_ADDR") do |email_address, options| options[:build] << email_address end - add_option('-C', '--certificate CERT', - 'Signing certificate for --sign') do |cert_file, options| + add_option("-C", "--certificate CERT", + "Signing certificate for --sign") do |cert_file, options| options[:issuer_cert] = open_cert(cert_file) options[:issuer_cert_file] = cert_file end - add_option('-K', '--private-key KEY', - 'Key for --sign or --build') do |key_file, options| + add_option("-K", "--private-key KEY", + "Key for --sign or --build") do |key_file, options| options[:key] = open_private_key(key_file) end - add_option('-A', '--key-algorithm ALGORITHM', - 'Select which key algorithm to use for --build') do |algorithm, options| + add_option("-A", "--key-algorithm ALGORITHM", + "Select which key algorithm to use for --build") do |algorithm, options| options[:key_algorithm] = algorithm end - add_option('-s', '--sign CERT', - 'Signs CERT with the key from -K', - 'and the certificate from -C') do |cert_file, options| + add_option("-s", "--sign CERT", + "Signs CERT with the key from -K", + "and the certificate from -C") do |cert_file, options| raise Gem::OptionParser::InvalidArgument, "#{cert_file}: does not exist" unless File.file? cert_file options[:sign] << cert_file end - add_option('-d', '--days NUMBER_OF_DAYS', - 'Days before the certificate expires') do |days, options| + add_option("-d", "--days NUMBER_OF_DAYS", + "Days before the certificate expires") do |days, options| options[:expiration_length_days] = days.to_i end - add_option('-R', '--re-sign', - 'Re-signs the certificate from -C with the key from -K') do |resign, options| + add_option("-R", "--re-sign", + "Re-signs the certificate from -C with the key from -K") do |resign, options| options[:resign] = resign end end @@ -93,7 +93,7 @@ def open_cert(certificate_file) def open_private_key(key_file) check_openssl - passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] + passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"] key = OpenSSL::PKey.read File.read(key_file), passphrase raise Gem::OptionParser::InvalidArgument, "#{key_file}: private key not found" unless key.private? @@ -166,10 +166,10 @@ def build_cert(email, key) # :nodoc: def build_key # :nodoc: return options[:key] if options[:key] - passphrase = ask_for_password 'Passphrase for your Private Key:' + passphrase = ask_for_password "Passphrase for your Private Key:" say "\n" - passphrase_confirmation = ask_for_password 'Please repeat the passphrase for your Private Key:' + passphrase_confirmation = ask_for_password "Please repeat the passphrase for your Private Key:" say "\n" raise Gem::CommandLineError, @@ -260,7 +260,7 @@ def load_default_cert def load_default_key key_file = File.join Gem.default_key_path key = File.read key_file - passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] + passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"] options[:key] = OpenSSL::PKey.read key, passphrase rescue Errno::ENOENT diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb index 3b6b97ae3bf5..4d1f8782b1d1 100644 --- a/lib/rubygems/commands/check_command.rb +++ b/lib/rubygems/commands/check_command.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../version_option' -require_relative '../validator' -require_relative '../doctor' +require_relative "../command" +require_relative "../version_option" +require_relative "../validator" +require_relative "../doctor" class Gem::Commands::CheckCommand < Gem::Command include Gem::VersionOption def initialize - super 'check', 'Check a gem repository for added or missing files', + super "check", "Check a gem repository for added or missing files", :alien => true, :doctor => false, :dry_run => false, :gems => true - add_option('-a', '--[no-]alien', + add_option("-a", "--[no-]alien", 'Report "unmanaged" or rogue files in the', - 'gem repository') do |value, options| + "gem repository") do |value, options| options[:alien] = value end - add_option('--[no-]doctor', - 'Clean up uninstalled gems and broken', - 'specifications') do |value, options| + add_option("--[no-]doctor", + "Clean up uninstalled gems and broken", + "specifications") do |value, options| options[:doctor] = value end - add_option('--[no-]dry-run', - 'Do not remove files, only report what', - 'would be removed') do |value, options| + add_option("--[no-]dry-run", + "Do not remove files, only report what", + "would be removed") do |value, options| options[:dry_run] = value end - add_option('--[no-]gems', - 'Check installed gems for problems') do |value, options| + add_option("--[no-]gems", + "Check installed gems for problems") do |value, options| options[:gems] = value end - add_version_option 'check' + add_version_option "check" end def check_gems - say 'Checking gems...' + say "Checking gems..." say gems = get_all_gem_names rescue [] @@ -57,7 +57,7 @@ def check_gems end def doctor - say 'Checking for files from uninstalled gems...' + say "Checking for files from uninstalled gems..." say Gem.path.each do |gem_repo| @@ -72,11 +72,11 @@ def execute end def arguments # :nodoc: - 'GEMNAME name of gem to check' + "GEMNAME name of gem to check" end def defaults_str # :nodoc: - '--gems --alien' + "--gems --alien" end def description # :nodoc: diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb index dc181e4de044..7f143999eb50 100644 --- a/lib/rubygems/commands/cleanup_command.rb +++ b/lib/rubygems/commands/cleanup_command.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../dependency_list' -require_relative '../uninstaller' +require_relative "../command" +require_relative "../dependency_list" +require_relative "../uninstaller" class Gem::Commands::CleanupCommand < Gem::Command def initialize - super 'cleanup', - 'Clean up old versions of installed gems', + super "cleanup", + "Clean up old versions of installed gems", :force => false, :install_dir => Gem.dir, :check_dev => true - add_option('-n', '-d', '--dry-run', - 'Do not uninstall gems') do |value, options| + add_option("-n", "-d", "--dry-run", + "Do not uninstall gems") do |value, options| options[:dryrun] = true end - add_option(:Deprecated, '--dryrun', - 'Do not uninstall gems') do |value, options| + add_option(:Deprecated, "--dryrun", + "Do not uninstall gems") do |value, options| options[:dryrun] = true end - deprecate_option('--dryrun', extra_msg: 'Use --dry-run instead') + deprecate_option("--dryrun", extra_msg: "Use --dry-run instead") - add_option('-D', '--[no-]check-development', - 'Check development dependencies while uninstalling', - '(default: true)') do |value, options| + add_option("-D", "--[no-]check-development", + "Check development dependencies while uninstalling", + "(default: true)") do |value, options| options[:check_dev] = value end - add_option('--[no-]user-install', - 'Cleanup in user\'s home directory instead', - 'of GEM_HOME.') do |value, options| + add_option("--[no-]user-install", + "Cleanup in user's home directory instead", + "of GEM_HOME.") do |value, options| options[:user_install] = value end diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 716022c45823..3dd0b16265fc 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -1,39 +1,39 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../version_option' +require_relative "../command" +require_relative "../version_option" class Gem::Commands::ContentsCommand < Gem::Command include Gem::VersionOption def initialize - super 'contents', 'Display the contents of the installed gems', + super "contents", "Display the contents of the installed gems", :specdirs => [], :lib_only => false, :prefix => true, :show_install_dir => false add_version_option - add_option('--all', + add_option("--all", "Contents for all gems") do |all, options| options[:all] = all end - add_option('-s', '--spec-dir a,b,c', Array, + add_option("-s", "--spec-dir a,b,c", Array, "Search for gems under specific paths") do |spec_dirs, options| options[:specdirs] = spec_dirs end - add_option('-l', '--[no-]lib-only', + add_option("-l", "--[no-]lib-only", "Only return files in the Gem's lib_dirs") do |lib_only, options| options[:lib_only] = lib_only end - add_option('--[no-]prefix', + add_option("--[no-]prefix", "Don't include installed path prefix") do |prefix, options| options[:prefix] = prefix end - add_option('--[no-]show-install-dir', - 'Show only the gem install dir') do |show, options| + add_option("--[no-]show-install-dir", + "Show only the gem install dir") do |show, options| options[:show_install_dir] = show end @@ -105,11 +105,11 @@ def files_in_default_gem(spec) case file when /\A#{spec.bindir}\// # $' is POSTMATCH - [RbConfig::CONFIG['bindir'], $'] + [RbConfig::CONFIG["bindir"], $'] when /\.so\z/ - [RbConfig::CONFIG['archdir'], file] + [RbConfig::CONFIG["archdir"], file] else - [RbConfig::CONFIG['rubylibdir'], file] + [RbConfig::CONFIG["rubylibdir"], file] end end end diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb index d2fed022fe18..c9ddc9af0a8c 100644 --- a/lib/rubygems/commands/dependency_command.rb +++ b/lib/rubygems/commands/dependency_command.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../version_option' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../version_option" class Gem::Commands::DependencyCommand < Gem::Command include Gem::LocalRemoteOptions include Gem::VersionOption def initialize - super 'dependency', - 'Show the dependencies of an installed gem', + super "dependency", + "Show the dependencies of an installed gem", :version => Gem::Requirement.default, :domain => :local add_version_option add_platform_option add_prerelease_option - add_option('-R', '--[no-]reverse-dependencies', - 'Include reverse dependencies in the output') do + add_option("-R", "--[no-]reverse-dependencies", + "Include reverse dependencies in the output") do |value, options| options[:reverse_dependencies] = value end - add_option('-p', '--pipe', + add_option("-p", "--pipe", "Pipe Format (name --version ver)") do |value, options| options[:pipe_format] = value end @@ -134,7 +134,7 @@ def execute def ensure_local_only_reverse_dependencies # :nodoc: if options[:reverse_dependencies] and remote? and not local? - alert_error 'Only reverse dependencies for local gems are supported.' + alert_error "Only reverse dependencies for local gems are supported." terminate_interaction 1 end end @@ -142,7 +142,7 @@ def ensure_local_only_reverse_dependencies # :nodoc: def ensure_specs(specs) # :nodoc: return unless specs.empty? - patterns = options[:args].join ',' + patterns = options[:args].join "," say "No gems found matching #{patterns} (#{options[:version]})" if Gem.configuration.verbose @@ -151,10 +151,10 @@ def ensure_specs(specs) # :nodoc: def print_dependencies(spec, level = 0) # :nodoc: response = String.new - response << ' ' * level + "Gem #{spec.full_name}\n" + response << " " * level + "Gem #{spec.full_name}\n" unless spec.dependencies.empty? spec.dependencies.sort_by {|dep| dep.name }.each do |dep| - response << ' ' * level + " #{dep}\n" + response << " " * level + " #{dep}\n" end end response diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index b6b3d3812caf..d95e1d0dbb23 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" class Gem::Commands::EnvironmentCommand < Gem::Command def initialize - super 'environment', 'Display information about the RubyGems environment' + super "environment", "Display information about the RubyGems environment" end def arguments # :nodoc: @@ -16,7 +16,7 @@ def arguments # :nodoc: platform display the supported gem platforms display everything EOF - return args.gsub(/^\s+/, '') + return args.gsub(/^\s+/, "") end def description # :nodoc: @@ -141,7 +141,7 @@ def show_environment # :nodoc: out << " - GEM CONFIGURATION:\n" Gem.configuration.each do |name, value| - value = value.gsub(/./, '*') if name == 'gemcutter_key' + value = value.gsub(/./, "*") if name == "gemcutter_key" out << " - #{name.inspect} => #{value.inspect}\n" end @@ -152,7 +152,7 @@ def show_environment # :nodoc: out << " - SHELL PATH:\n" - shell_path = ENV['PATH'].split(File::PATH_SEPARATOR) + shell_path = ENV["PATH"].split(File::PATH_SEPARATOR) add_path out, shell_path out diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb index c8ecb0d48c4e..582563ba8105 100644 --- a/lib/rubygems/commands/fetch_command.rb +++ b/lib/rubygems/commands/fetch_command.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../version_option' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../version_option" class Gem::Commands::FetchCommand < Gem::Command include Gem::LocalRemoteOptions @@ -13,7 +13,7 @@ def initialize :version => Gem::Requirement.default, } - super 'fetch', 'Download a gem and place it in the current directory', defaults + super "fetch", "Download a gem and place it in the current directory", defaults add_bulk_threshold_option add_proxy_option @@ -24,13 +24,13 @@ def initialize add_platform_option add_prerelease_option - add_option '--[no-]suggestions', 'Suggest alternates when gems are not found' do |value, options| + add_option "--[no-]suggestions", "Suggest alternates when gems are not found" do |value, options| options[:suggest_alternate] = value end end def arguments # :nodoc: - 'GEMNAME name of gem to download' + "GEMNAME name of gem to download" end def defaults_str # :nodoc: diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb index 87200dab91db..8bb24c9ce3e2 100644 --- a/lib/rubygems/commands/generate_index_command.rb +++ b/lib/rubygems/commands/generate_index_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../indexer' +require_relative "../command" +require_relative "../indexer" ## # Generates a index files for use as a gem server. @@ -9,27 +9,27 @@ class Gem::Commands::GenerateIndexCommand < Gem::Command def initialize - super 'generate_index', - 'Generates the index files for a gem server directory', - :directory => '.', :build_modern => true + super "generate_index", + "Generates the index files for a gem server directory", + :directory => ".", :build_modern => true - add_option '-d', '--directory=DIRNAME', - 'repository base dir containing gems subdir' do |dir, options| + add_option "-d", "--directory=DIRNAME", + "repository base dir containing gems subdir" do |dir, options| options[:directory] = File.expand_path dir end - add_option '--[no-]modern', - 'Generate indexes for RubyGems', - '(always true)' do |value, options| + add_option "--[no-]modern", + "Generate indexes for RubyGems", + "(always true)" do |value, options| options[:build_modern] = value end - deprecate_option('--modern', version: '4.0', extra_msg: 'Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.') - deprecate_option('--no-modern', version: '4.0', extra_msg: 'The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.') + deprecate_option("--modern", version: "4.0", extra_msg: "Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.") + deprecate_option("--no-modern", version: "4.0", extra_msg: "The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.") - add_option '--update', - 'Update modern indexes with gems added', - 'since the last update' do |value, options| + add_option "--update", + "Update modern indexes with gems added", + "since the last update" do |value, options| options[:update] = value end end diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb index 7f3383c9f300..8bfb4458ff1c 100644 --- a/lib/rubygems/commands/help_command.rb +++ b/lib/rubygems/commands/help_command.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" class Gem::Commands::HelpCommand < Gem::Command # :stopdoc: @@ -280,7 +280,7 @@ class Gem::Commands::HelpCommand < Gem::Command # :startdoc: def initialize - super 'help', "Provide help on the 'gem' command" + super "help", "Provide help on the 'gem' command" @command_manager = Gem::CommandManager.instance end @@ -326,7 +326,7 @@ def show_commands # :nodoc: desc_width = @command_manager.command_names.map {|n| n.size }.max + 4 summary_width = 80 - margin_width - desc_width - wrap_indent = ' ' * (margin_width + desc_width) + wrap_indent = " " * (margin_width + desc_width) format = "#{' ' * margin_width}%-#{desc_width}s%s" @command_manager.command_names.each do |cmd_name| diff --git a/lib/rubygems/commands/info_command.rb b/lib/rubygems/commands/info_command.rb index 3f2dd4ae0bda..ced7751ff557 100644 --- a/lib/rubygems/commands/info_command.rb +++ b/lib/rubygems/commands/info_command.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../query_utils' +require_relative "../command" +require_relative "../query_utils" class Gem::Commands::InfoCommand < Gem::Command include Gem::QueryUtils @@ -13,7 +13,7 @@ def initialize add_query_options - remove_option('-d') + remove_option("-d") defaults[:details] = true defaults[:exact] = true diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 87563accb07e..690f90c2e425 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../install_update_options' -require_relative '../dependency_installer' -require_relative '../local_remote_options' -require_relative '../validator' -require_relative '../version_option' +require_relative "../command" +require_relative "../install_update_options" +require_relative "../dependency_installer" +require_relative "../local_remote_options" +require_relative "../validator" +require_relative "../version_option" ## # Gem installer command line tool @@ -29,7 +29,7 @@ def initialize defaults.merge!(install_update_options) - super 'install', 'Install a gem into the local repository', defaults + super "install", "Install a gem into the local repository", defaults add_install_update_options add_local_remote_options @@ -157,7 +157,7 @@ def execute @installed_specs = [] - ENV.delete 'GEM_PATH' if options[:install_dir].nil? + ENV.delete "GEM_PATH" if options[:install_dir].nil? check_install_dir check_version @@ -172,7 +172,7 @@ def execute end def install_from_gemdeps # :nodoc: - require_relative '../request_set' + require_relative "../request_set" rs = Gem::RequestSet.new specs = rs.install_from_gemdeps options do |req, inst| @@ -247,11 +247,11 @@ def install_gems # :nodoc: def load_hooks # :nodoc: if options[:install_as_default] - require_relative '../install_default_message' + require_relative "../install_default_message" else - require_relative '../install_message' + require_relative "../install_message" end - require_relative '../rdoc' + require_relative "../rdoc" end def show_install_errors(errors) # :nodoc: @@ -270,7 +270,7 @@ def show_install_errors(errors) # :nodoc: def show_installed # :nodoc: return if @installed_specs.empty? - gems = @installed_specs.length == 1 ? 'gem' : 'gems' + gems = @installed_specs.length == 1 ? "gem" : "gems" say "#{@installed_specs.length} #{gems} installed" end end diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb index 010d968f9cd5..011873b99cdc 100644 --- a/lib/rubygems/commands/list_command.rb +++ b/lib/rubygems/commands/list_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../query_utils' +require_relative "../command" +require_relative "../query_utils" ## # Searches for gems starting with the supplied argument. @@ -9,7 +9,7 @@ class Gem::Commands::ListCommand < Gem::Command include Gem::QueryUtils def initialize - super 'list', 'Display local gems whose name matches REGEXP', + super "list", "Display local gems whose name matches REGEXP", :domain => :local, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb index cb6229a2cbc8..da636492c9a3 100644 --- a/lib/rubygems/commands/lock_command.rb +++ b/lib/rubygems/commands/lock_command.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" class Gem::Commands::LockCommand < Gem::Command def initialize - super 'lock', 'Generate a lockdown list of gems', + super "lock", "Generate a lockdown list of gems", :strict => false - add_option '-s', '--[no-]strict', - 'fail if unable to satisfy a dependency' do |strict, options| + add_option "-s", "--[no-]strict", + "fail if unable to satisfy a dependency" do |strict, options| options[:strict] = strict end end diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb index 7daa47e2f0ad..b633cd3d81e5 100644 --- a/lib/rubygems/commands/mirror_command.rb +++ b/lib/rubygems/commands/mirror_command.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" unless defined? Gem::Commands::MirrorCommand class Gem::Commands::MirrorCommand < Gem::Command def initialize - super('mirror', 'Mirror all gem files (requires rubygems-mirror)') + super("mirror", "Mirror all gem files (requires rubygems-mirror)") begin - Gem::Specification.find_by_name('rubygems-mirror').activate + Gem::Specification.find_by_name("rubygems-mirror").activate rescue Gem::LoadError # no-op end diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb index 1e616fd68f3f..d5283f72dd0f 100644 --- a/lib/rubygems/commands/open_command.rb +++ b/lib/rubygems/commands/open_command.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../version_option' +require_relative "../command" +require_relative "../version_option" class Gem::Commands::OpenCommand < Gem::Command include Gem::VersionOption def initialize - super 'open', 'Open gem sources in editor' + super "open", "Open gem sources in editor" - add_option('-e', '--editor COMMAND', String, + add_option("-e", "--editor COMMAND", String, "Prepends COMMAND to gem path. Could be used to specify editor.") do |command, options| options[:editor] = command || get_env_editor end - add_option('-v', '--version VERSION', String, + add_option("-v", "--version VERSION", String, "Opens specific gem version") do |version| options[:version] = version end @@ -40,10 +40,10 @@ def usage # :nodoc: end def get_env_editor - ENV['GEM_EDITOR'] || - ENV['VISUAL'] || - ENV['EDITOR'] || - 'vi' + ENV["GEM_EDITOR"] || + ENV["VISUAL"] || + ENV["EDITOR"] || + "vi" end def execute diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb index 162d3383201d..1785194389c5 100644 --- a/lib/rubygems/commands/outdated_command.rb +++ b/lib/rubygems/commands/outdated_command.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../spec_fetcher' -require_relative '../version_option' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../spec_fetcher" +require_relative "../version_option" class Gem::Commands::OutdatedCommand < Gem::Command include Gem::LocalRemoteOptions include Gem::VersionOption def initialize - super 'outdated', 'Display all gems that need updates' + super "outdated", "Display all gems that need updates" add_local_remote_options add_platform_option diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 42b0d7913515..4a0f7aa3e46f 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../gemcutter_utilities' -require_relative '../text' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../gemcutter_utilities" +require_relative "../text" class Gem::Commands::OwnerCommand < Gem::Command include Gem::Text @@ -34,23 +34,23 @@ def usage # :nodoc: end def initialize - super 'owner', 'Manage gem owners of a gem on the push server' + super "owner", "Manage gem owners of a gem on the push server" add_proxy_option add_key_option add_otp_option defaults.merge! :add => [], :remove => [] - add_option '-a', '--add NEW_OWNER', 'Add an owner by user identifier' do |value, options| + add_option "-a", "--add NEW_OWNER", "Add an owner by user identifier" do |value, options| options[:add] << value end - add_option '-r', '--remove OLD_OWNER', 'Remove an owner by user identifier' do |value, options| + add_option "-r", "--remove OLD_OWNER", "Remove an owner by user identifier" do |value, options| options[:remove] << value end - add_option '-h', '--host HOST', - 'Use another gemcutter-compatible host', - ' (e.g. https://rubygems.org)' do |value, options| + add_option "-h", "--host HOST", + "Use another gemcutter-compatible host", + " (e.g. https://rubygems.org)" do |value, options| options[:host] = value end end @@ -108,7 +108,7 @@ def manage_owners(method, name, owners) def send_owner_request(method, name, owner) rubygems_api_request method, "api/v1/gems/#{name}/owners", scope: get_owner_scope(method: method) do |request| - request.set_form_data 'email' => owner + request.set_form_data "email" => owner request.add_field "Authorization", api_key end end diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index 030c1bffcea0..d4dadf0736e2 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -1,67 +1,67 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../package' -require_relative '../installer' -require_relative '../version_option' +require_relative "../command" +require_relative "../package" +require_relative "../installer" +require_relative "../version_option" class Gem::Commands::PristineCommand < Gem::Command include Gem::VersionOption def initialize - super 'pristine', - 'Restores installed gems to pristine condition from files located in the gem cache', + super "pristine", + "Restores installed gems to pristine condition from files located in the gem cache", :version => Gem::Requirement.default, :extensions => true, :extensions_set => false, :all => false - add_option('--all', - 'Restore all installed gems to pristine', - 'condition') do |value, options| + add_option("--all", + "Restore all installed gems to pristine", + "condition") do |value, options| options[:all] = value end - add_option('--skip=gem_name', - 'used on --all, skip if name == gem_name') do |value, options| + add_option("--skip=gem_name", + "used on --all, skip if name == gem_name") do |value, options| options[:skip] ||= [] options[:skip] << value end - add_option('--[no-]extensions', - 'Restore gems with extensions', - 'in addition to regular gems') do |value, options| + add_option("--[no-]extensions", + "Restore gems with extensions", + "in addition to regular gems") do |value, options| options[:extensions_set] = true options[:extensions] = value end - add_option('--only-executables', - 'Only restore executables') do |value, options| + add_option("--only-executables", + "Only restore executables") do |value, options| options[:only_executables] = value end - add_option('--only-plugins', - 'Only restore plugins') do |value, options| + add_option("--only-plugins", + "Only restore plugins") do |value, options| options[:only_plugins] = value end - add_option('-E', '--[no-]env-shebang', - 'Rewrite executables with a shebang', - 'of /usr/bin/env') do |value, options| + add_option("-E", "--[no-]env-shebang", + "Rewrite executables with a shebang", + "of /usr/bin/env") do |value, options| options[:env_shebang] = value end - add_option('-i', '--install-dir DIR', - 'Gem repository to get binstubs and plugins installed') do |value, options| + add_option("-i", "--install-dir DIR", + "Gem repository to get binstubs and plugins installed") do |value, options| options[:install_dir] = File.expand_path(value) end - add_option('-n', '--bindir DIR', - 'Directory where executables are', - 'located') do |value, options| + add_option("-n", "--bindir DIR", + "Directory where executables are", + "located") do |value, options| options[:bin_dir] = File.expand_path(value) end - add_version_option('restore to', 'pristine condition') + add_version_option("restore to", "pristine condition") end def arguments # :nodoc: @@ -69,7 +69,7 @@ def arguments # :nodoc: end def defaults_str # :nodoc: - '--extensions' + "--extensions" end def description # :nodoc: @@ -143,7 +143,7 @@ def execute gem = spec.cache_file unless File.exist? gem or options[:only_executables] or options[:only_plugins] - require_relative '../remote_fetcher' + require_relative "../remote_fetcher" say "Cached gem for #{spec.full_name} not found, attempting to fetch..." @@ -163,8 +163,8 @@ def execute if options.include? :env_shebang options[:env_shebang] else - install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install'] - install_defaults.to_s['--env-shebang'] + install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS["install"] + install_defaults.to_s["--env-shebang"] end bin_dir = options[:bin_dir] if options[:bin_dir] diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 4d0d5a9f4b54..46b65f4e15e9 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../gemcutter_utilities' -require_relative '../package' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../gemcutter_utilities" +require_relative "../package" class Gem::Commands::PushCommand < Gem::Command include Gem::LocalRemoteOptions @@ -29,7 +29,7 @@ def usage # :nodoc: end def initialize - super 'push', 'Push a gem up to the gem server', :host => self.host + super "push", "Push a gem up to the gem server", :host => self.host @user_defined_host = false @@ -37,9 +37,9 @@ def initialize add_key_option add_otp_option - add_option('--host HOST', - 'Push to another gemcutter-compatible host', - ' (e.g. https://rubygems.org)') do |value, options| + add_option("--host HOST", + "Push to another gemcutter-compatible host", + " (e.g. https://rubygems.org)") do |value, options| options[:host] = value @user_defined_host = true end diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index 442c4b19bb40..c6315acf8cc9 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../query_utils' -require_relative '../deprecate' +require_relative "../command" +require_relative "../query_utils" +require_relative "../deprecate" class Gem::Commands::QueryCommand < Gem::Command extend Gem::Deprecate @@ -17,15 +17,15 @@ def deprecation_warning alert_warning message unless Gem::Deprecate.skip end - def initialize(name = 'query', - summary = 'Query gem information in local or remote repositories') + def initialize(name = "query", + summary = "Query gem information in local or remote repositories") super name, summary, :domain => :local, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default - add_option('-n', '--name-matches REGEXP', - 'Name of gem(s) to query on matches the', - 'provided REGEXP') do |value, options| + add_option("-n", "--name-matches REGEXP", + "Name of gem(s) to query on matches the", + "provided REGEXP") do |value, options| options[:name] = /#{value}/i end diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb index 7c5d6212f5b5..17ad6f836bea 100644 --- a/lib/rubygems/commands/rdoc_command.rb +++ b/lib/rubygems/commands/rdoc_command.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../version_option' -require_relative '../rdoc' -require 'fileutils' +require_relative "../command" +require_relative "../version_option" +require_relative "../rdoc" +require "fileutils" class Gem::Commands::RdocCommand < Gem::Command include Gem::VersionOption def initialize - super 'rdoc', 'Generates RDoc for pre-installed gems', + super "rdoc", "Generates RDoc for pre-installed gems", :version => Gem::Requirement.default, :include_rdoc => false, :include_ri => true, :overwrite => false - add_option('--all', - 'Generate RDoc/RI documentation for all', - 'installed gems') do |value, options| + add_option("--all", + "Generate RDoc/RI documentation for all", + "installed gems") do |value, options| options[:all] = value end - add_option('--[no-]rdoc', - 'Generate RDoc HTML') do |value, options| + add_option("--[no-]rdoc", + "Generate RDoc HTML") do |value, options| options[:include_rdoc] = value end - add_option('--[no-]ri', - 'Generate RI data') do |value, options| + add_option("--[no-]ri", + "Generate RI data") do |value, options| options[:include_ri] = value end - add_option('--[no-]overwrite', - 'Overwrite installed documents') do |value, options| + add_option("--[no-]overwrite", + "Overwrite installed documents") do |value, options| options[:overwrite] = value end @@ -69,7 +69,7 @@ def execute end if specs.empty? - alert_error 'No matching gems found' + alert_error "No matching gems found" terminate_interaction 1 end @@ -79,8 +79,8 @@ def execute doc.force = options[:overwrite] if options[:overwrite] - FileUtils.rm_rf File.join(spec.doc_dir, 'ri') - FileUtils.rm_rf File.join(spec.doc_dir, 'rdoc') + FileUtils.rm_rf File.join(spec.doc_dir, "ri") + FileUtils.rm_rf File.join(spec.doc_dir, "rdoc") end begin diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb index 75d99986f918..3f8f7e13f23e 100644 --- a/lib/rubygems/commands/search_command.rb +++ b/lib/rubygems/commands/search_command.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../query_utils' +require_relative "../command" +require_relative "../query_utils" class Gem::Commands::SearchCommand < Gem::Command include Gem::QueryUtils def initialize - super 'search', 'Display remote gems whose name matches REGEXP', + super "search", "Display remote gems whose name matches REGEXP", :domain => :remote, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb index f8cad3b5db71..56be07c79d4a 100644 --- a/lib/rubygems/commands/server_command.rb +++ b/lib/rubygems/commands/server_command.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" unless defined? Gem::Commands::ServerCommand class Gem::Commands::ServerCommand < Gem::Command def initialize - super('server', 'Starts up a web server that hosts the RDoc (requires rubygems-server)') + super("server", "Starts up a web server that hosts the RDoc (requires rubygems-server)") begin - Gem::Specification.find_by_name('rubygems-server').activate + Gem::Specification.find_by_name("rubygems-server").activate rescue Gem::LoadError # no-op end diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index db2fefa65ebc..1ed889a7134b 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" ## # Installs RubyGems itself. This command is ordinarily only available from a @@ -12,47 +12,47 @@ class Gem::Commands::SetupCommand < Gem::Command ENV_PATHS = %w[/usr/bin/env /bin/env].freeze def initialize - super 'setup', 'Install RubyGems', + super "setup", "Install RubyGems", :format_executable => false, :document => %w[ri], :force => true, - :site_or_vendor => 'sitelibdir', - :destdir => '', :prefix => '', :previous_version => '', + :site_or_vendor => "sitelibdir", + :destdir => "", :prefix => "", :previous_version => "", :regenerate_binstubs => true, :regenerate_plugins => true - add_option '--previous-version=VERSION', - 'Previous version of RubyGems', - 'Used for changelog processing' do |version, options| + add_option "--previous-version=VERSION", + "Previous version of RubyGems", + "Used for changelog processing" do |version, options| options[:previous_version] = version end - add_option '--prefix=PREFIX', - 'Prefix path for installing RubyGems', - 'Will not affect gem repository location' do |prefix, options| + add_option "--prefix=PREFIX", + "Prefix path for installing RubyGems", + "Will not affect gem repository location" do |prefix, options| options[:prefix] = File.expand_path prefix end - add_option '--destdir=DESTDIR', - 'Root directory to install RubyGems into', - 'Mainly used for packaging RubyGems' do |destdir, options| + add_option "--destdir=DESTDIR", + "Root directory to install RubyGems into", + "Mainly used for packaging RubyGems" do |destdir, options| options[:destdir] = File.expand_path destdir end - add_option '--[no-]vendor', - 'Install into vendorlibdir not sitelibdir' do |vendor, options| - options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir' + add_option "--[no-]vendor", + "Install into vendorlibdir not sitelibdir" do |vendor, options| + options[:site_or_vendor] = vendor ? "vendorlibdir" : "sitelibdir" end - add_option '--[no-]format-executable', - 'Makes `gem` match ruby', - 'If Ruby is ruby18, gem will be gem18' do |value, options| + add_option "--[no-]format-executable", + "Makes `gem` match ruby", + "If Ruby is ruby18, gem will be gem18" do |value, options| options[:format_executable] = value end - add_option '--[no-]document [TYPES]', Array, - 'Generate documentation for RubyGems', - 'List the documentation types you wish to', - 'generate. For example: rdoc,ri' do |value, options| + add_option "--[no-]document [TYPES]", Array, + "Generate documentation for RubyGems", + "List the documentation types you wish to", + "generate. For example: rdoc,ri" do |value, options| options[:document] = case value when nil then %w[rdoc ri] when false then [] @@ -60,46 +60,46 @@ def initialize end end - add_option '--[no-]rdoc', - 'Generate RDoc documentation for RubyGems' do |value, options| + add_option "--[no-]rdoc", + "Generate RDoc documentation for RubyGems" do |value, options| if value - options[:document] << 'rdoc' + options[:document] << "rdoc" else - options[:document].delete 'rdoc' + options[:document].delete "rdoc" end options[:document].uniq! end - add_option '--[no-]ri', - 'Generate RI documentation for RubyGems' do |value, options| + add_option "--[no-]ri", + "Generate RI documentation for RubyGems" do |value, options| if value - options[:document] << 'ri' + options[:document] << "ri" else - options[:document].delete 'ri' + options[:document].delete "ri" end options[:document].uniq! end - add_option '--[no-]regenerate-binstubs', - 'Regenerate gem binstubs' do |value, options| + add_option "--[no-]regenerate-binstubs", + "Regenerate gem binstubs" do |value, options| options[:regenerate_binstubs] = value end - add_option '--[no-]regenerate-plugins', - 'Regenerate gem plugins' do |value, options| + add_option "--[no-]regenerate-plugins", + "Regenerate gem plugins" do |value, options| options[:regenerate_plugins] = value end - add_option '-f', '--[no-]force', - 'Forcefully overwrite binstubs' do |value, options| + add_option "-f", "--[no-]force", + "Forcefully overwrite binstubs" do |value, options| options[:force] = value end - add_option('-E', '--[no-]env-shebang', - 'Rewrite executables with a shebang', - 'of /usr/bin/env') do |value, options| + add_option("-E", "--[no-]env-shebang", + "Rewrite executables with a shebang", + "of /usr/bin/env") do |value, options| options[:env_shebang] = value end @@ -107,7 +107,7 @@ def initialize end def check_ruby_version - required_version = Gem::Requirement.new '>= 2.3.0' + required_version = Gem::Requirement.new ">= 2.3.0" unless required_version.satisfied_by? Gem.ruby_version alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}" @@ -149,7 +149,7 @@ def execute check_ruby_version - require 'fileutils' + require "fileutils" if Gem.configuration.really_verbose extend FileUtils::Verbose else @@ -194,7 +194,7 @@ def execute end if options[:previous_version].empty? - options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, '0') + options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, "0") end options[:previous_version] = Gem::Version.new(options[:previous_version]) @@ -216,7 +216,7 @@ def execute end if documentation_success - if options[:document].include? 'rdoc' + if options[:document].include? "rdoc" say "Rdoc documentation was installed. You may now invoke:" say " gem server" say "and then peruse beautifully formatted documentation for your gems" @@ -227,7 +227,7 @@ def execute say end - if options[:document].include? 'ri' + if options[:document].include? "ri" say "Ruby Interactive (ri) documentation was installed. ri is kind of like man " say "pages for Ruby libraries. You may access it like this:" say " ri Classname" @@ -244,14 +244,14 @@ def execute def install_executables(bin_dir) prog_mode = options[:prog_mode] || 0755 - executables = { 'gem' => 'bin' } + executables = { "gem" => "bin" } executables.each do |tool, path| say "Installing #{tool} executable" if @verbose Dir.chdir path do bin_file = "gem" - require 'tmpdir' + require "tmpdir" dest_file = target_bin_path(bin_dir, bin_file) bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}" @@ -260,7 +260,7 @@ def install_executables(bin_dir) bin = File.readlines bin_file bin[0] = shebang - File.open bin_tmp_file, 'w' do |fp| + File.open bin_tmp_file, "w" do |fp| fp.puts bin.join end @@ -275,7 +275,7 @@ def install_executables(bin_dir) begin bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat" - File.open bin_cmd_file, 'w' do |file| + File.open bin_cmd_file, "w" do |file| file.puts <<-TEXT @ECHO OFF IF NOT "%~f0" == "~f0" GOTO :WinNT @@ -296,7 +296,7 @@ def install_executables(bin_dir) def shebang if options[:env_shebang] - ruby_name = RbConfig::CONFIG['ruby_install_name'] + ruby_name = RbConfig::CONFIG["ruby_install_name"] @env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path } "#!#{@env_path} #{ruby_name}\n" else @@ -305,8 +305,8 @@ def shebang end def install_lib(lib_dir) - libs = { 'RubyGems' => 'lib' } - libs['Bundler'] = 'bundler/lib' + libs = { "RubyGems" => "lib" } + libs["Bundler"] = "bundler/lib" libs.each do |tool, path| say "Installing #{tool}" if @verbose @@ -319,7 +319,7 @@ def install_lib(lib_dir) end def install_rdoc - gem_doc_dir = File.join Gem.dir, 'doc' + gem_doc_dir = File.join Gem.dir, "doc" rubygems_name = "rubygems-#{Gem::VERSION}" rubygems_doc_dir = File.join gem_doc_dir, rubygems_name @@ -333,19 +333,19 @@ def install_rdoc (not File.exist? rubygems_doc_dir or File.writable? rubygems_doc_dir) say "Removing old RubyGems RDoc and ri" if @verbose - Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir| + Dir[File.join(Gem.dir, "doc", "rubygems-[0-9]*")].each do |dir| rm_rf dir end - require_relative '../rdoc' + require_relative "../rdoc" - fake_spec = Gem::Specification.new 'rubygems', Gem::VERSION + fake_spec = Gem::Specification.new "rubygems", Gem::VERSION def fake_spec.full_gem_path - File.expand_path '../../..', __dir__ + File.expand_path "../../..", __dir__ end - generate_ri = options[:document].include? 'ri' - generate_rdoc = options[:document].include? 'rdoc' + generate_ri = options[:document].include? "ri" + generate_rdoc = options[:document].include? "rdoc" rdoc = Gem::RDoc.new fake_spec, generate_rdoc, generate_ri rdoc.generate @@ -397,7 +397,7 @@ def install_default_bundler_gem(bin_dir) cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e) end - require_relative '../installer' + require_relative "../installer" Dir.chdir("bundler") do built_gem = Gem::Package.build(bundler_spec) @@ -439,10 +439,10 @@ def generate_default_man_dir prefix = options[:prefix] if prefix.empty? - man_dir = RbConfig::CONFIG['mandir'] + man_dir = RbConfig::CONFIG["mandir"] return unless man_dir else - man_dir = File.join prefix, 'man' + man_dir = File.join prefix, "man" end prepend_destdir_if_present(man_dir) @@ -454,10 +454,10 @@ def generate_default_dirs if prefix.empty? lib_dir = RbConfig::CONFIG[site_or_vendor] - bin_dir = RbConfig::CONFIG['bindir'] + bin_dir = RbConfig::CONFIG["bindir"] else - lib_dir = File.join prefix, 'lib' - bin_dir = File.join prefix, 'bin' + lib_dir = File.join prefix, "lib" + bin_dir = File.join prefix, "bin" end [prepend_destdir_if_present(lib_dir), prepend_destdir_if_present(bin_dir)] @@ -465,19 +465,19 @@ def generate_default_dirs def files_in(dir) Dir.chdir dir do - Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH). + Dir.glob(File.join("**", "*"), File::FNM_DOTMATCH). select {|f| !File.directory?(f) } end end def remove_old_bin_files(bin_dir) old_bin_files = { - 'gem_mirror' => 'gem mirror', - 'gem_server' => 'gem server', - 'gemlock' => 'gem lock', - 'gemri' => 'ri', - 'gemwhich' => 'gem which', - 'index_gem_repository.rb' => 'gem generate_index', + "gem_mirror" => "gem mirror", + "gem_server" => "gem server", + "gemlock" => "gem lock", + "gemri" => "ri", + "gemwhich" => "gem which", + "index_gem_repository.rb" => "gem generate_index", } old_bin_files.each do |old_bin_file, new_name| @@ -486,7 +486,7 @@ def remove_old_bin_files(bin_dir) deprecation_message = "`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead." - File.open old_bin_path, 'w' do |fp| + File.open old_bin_path, "w" do |fp| fp.write <<-EOF #!#{Gem.ruby} @@ -496,15 +496,15 @@ def remove_old_bin_files(bin_dir) next unless Gem.win_platform? - File.open "#{old_bin_path}.bat", 'w' do |fp| + File.open "#{old_bin_path}.bat", "w" do |fp| fp.puts %(@ECHO.#{deprecation_message}) end end end def remove_old_lib_files(lib_dir) - lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' } - lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler' + lib_dirs = { File.join(lib_dir, "rubygems") => "lib/rubygems" } + lib_dirs[File.join(lib_dir, "bundler")] = "bundler/lib/bundler" lib_dirs.each do |old_lib_dir, new_lib_dir| lib_files = files_in(new_lib_dir) @@ -512,11 +512,11 @@ def remove_old_lib_files(lib_dir) to_remove = old_lib_files - lib_files - gauntlet_rubygems = File.join(lib_dir, 'gauntlet_rubygems.rb') + gauntlet_rubygems = File.join(lib_dir, "gauntlet_rubygems.rb") to_remove << gauntlet_rubygems if File.exist? gauntlet_rubygems to_remove.delete_if do |file| - file.start_with? 'defaults' + file.start_with? "defaults" end remove_file_list(to_remove, old_lib_dir) @@ -542,7 +542,7 @@ def remove_old_man_files(old_man_dir) end def show_release_notes - release_notes = File.join Dir.pwd, 'CHANGELOG.md' + release_notes = File.join Dir.pwd, "CHANGELOG.md" release_notes = if File.exist? release_notes @@ -573,10 +573,10 @@ def show_release_notes end def uninstall_old_gemcutter - require_relative '../uninstaller' + require_relative "../uninstaller" - ui = Gem::Uninstaller.new('gemcutter', :all => true, :ignore => true, - :version => '< 0.4') + ui = Gem::Uninstaller.new("gemcutter", :all => true, :ignore => true, + :version => "< 0.4") ui.uninstall rescue Gem::InstallError end @@ -625,7 +625,7 @@ def prepend_destdir_if_present(path) destdir = options[:destdir] return path if destdir.empty? - File.join(options[:destdir], path.gsub(/^[a-zA-Z]:/, '')) + File.join(options[:destdir], path.gsub(/^[a-zA-Z]:/, "")) end def install_file_list(files, dest_dir) diff --git a/lib/rubygems/commands/signin_command.rb b/lib/rubygems/commands/signin_command.rb index 23bb2f937fc8..2660eee4f327 100644 --- a/lib/rubygems/commands/signin_command.rb +++ b/lib/rubygems/commands/signin_command.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../gemcutter_utilities' +require_relative "../command" +require_relative "../gemcutter_utilities" class Gem::Commands::SigninCommand < Gem::Command include Gem::GemcutterUtilities def initialize - super 'signin', 'Sign in to any gemcutter-compatible host. '\ - 'It defaults to https://rubygems.org' + super "signin", "Sign in to any gemcutter-compatible host. "\ + "It defaults to https://rubygems.org" - add_option('--host HOST', 'Push to another gemcutter-compatible host') do |value, options| + add_option("--host HOST", "Push to another gemcutter-compatible host") do |value, options| options[:host] = value end @@ -17,10 +17,10 @@ def initialize end def description # :nodoc: - 'The signin command executes host sign in for a push server (the default is'\ - ' https://rubygems.org). The host can be provided with the host flag or can'\ - ' be inferred from the provided gem. Host resolution matches the resolution'\ - ' strategy for the push command.' + "The signin command executes host sign in for a push server (the default is"\ + " https://rubygems.org). The host can be provided with the host flag or can"\ + " be inferred from the provided gem. Host resolution matches the resolution"\ + " strategy for the push command." end def usage # :nodoc: diff --git a/lib/rubygems/commands/signout_command.rb b/lib/rubygems/commands/signout_command.rb index c9485e0c1b44..fa688ea3f8a6 100644 --- a/lib/rubygems/commands/signout_command.rb +++ b/lib/rubygems/commands/signout_command.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" class Gem::Commands::SignoutCommand < Gem::Command def initialize - super 'signout', 'Sign out from all the current sessions.' + super "signout", "Sign out from all the current sessions." end def description # :nodoc: - 'The `signout` command is used to sign out from all current sessions,'\ - ' allowing you to sign in using a different set of credentials.' + "The `signout` command is used to sign out from all current sessions,"\ + " allowing you to sign in using a different set of credentials." end def usage # :nodoc: @@ -19,13 +19,13 @@ def execute credentials_path = Gem.configuration.credentials_path if !File.exist?(credentials_path) - alert_error 'You are not currently signed in.' + alert_error "You are not currently signed in." elsif !File.writable?(credentials_path) alert_error "File '#{Gem.configuration.credentials_path}' is read-only."\ - ' Please make sure it is writable.' + " Please make sure it is writable." else Gem.configuration.unset_api_key! - say 'You have successfully signed out from all sessions.' + say "You have successfully signed out from all sessions." end end end diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb index 884d9445c9bd..a5f2d022c6b2 100644 --- a/lib/rubygems/commands/sources_command.rb +++ b/lib/rubygems/commands/sources_command.rb @@ -1,40 +1,40 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../remote_fetcher' -require_relative '../spec_fetcher' -require_relative '../local_remote_options' +require_relative "../command" +require_relative "../remote_fetcher" +require_relative "../spec_fetcher" +require_relative "../local_remote_options" class Gem::Commands::SourcesCommand < Gem::Command include Gem::LocalRemoteOptions def initialize - require 'fileutils' + require "fileutils" - super 'sources', - 'Manage the sources and cache file RubyGems uses to search for gems' + super "sources", + "Manage the sources and cache file RubyGems uses to search for gems" - add_option '-a', '--add SOURCE_URI', 'Add source' do |value, options| + add_option "-a", "--add SOURCE_URI", "Add source" do |value, options| options[:add] = value end - add_option '-l', '--list', 'List sources' do |value, options| + add_option "-l", "--list", "List sources" do |value, options| options[:list] = value end - add_option '-r', '--remove SOURCE_URI', 'Remove source' do |value, options| + add_option "-r", "--remove SOURCE_URI", "Remove source" do |value, options| options[:remove] = value end - add_option '-c', '--clear-all', - 'Remove all sources (clear the cache)' do |value, options| + add_option "-c", "--clear-all", + "Remove all sources (clear the cache)" do |value, options| options[:clear_all] = value end - add_option '-u', '--update', 'Update source cache' do |value, options| + add_option "-u", "--update", "Update source cache" do |value, options| options[:update] = value end - add_option '-f', '--[no-]force', "Do not show any confirmation prompts and behave as if 'yes' was always answered" do |value, options| + add_option "-f", "--[no-]force", "Do not show any confirmation prompts and behave as if 'yes' was always answered" do |value, options| options[:force] = value end @@ -82,8 +82,8 @@ def check_typo_squatting(source) def check_rubygems_https(source_uri) # :nodoc: uri = URI source_uri - if uri.scheme and uri.scheme.downcase == 'http' and - uri.host.downcase == 'rubygems.org' + if uri.scheme and uri.scheme.downcase == "http" and + uri.host.downcase == "rubygems.org" question = <<-QUESTION.chomp https://rubygems.org is recommended for security over #{uri} @@ -112,7 +112,7 @@ def clear_all # :nodoc: end def defaults_str # :nodoc: - '--list' + "--list" end def description # :nodoc: diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb index 6fba3a36ece4..6457a755ae46 100644 --- a/lib/rubygems/commands/specification_command.rb +++ b/lib/rubygems/commands/specification_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../version_option' -require_relative '../package' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../version_option" +require_relative "../package" class Gem::Commands::SpecificationCommand < Gem::Command include Gem::LocalRemoteOptions @@ -11,28 +11,28 @@ class Gem::Commands::SpecificationCommand < Gem::Command def initialize Gem.load_yaml - super 'specification', 'Display gem specification (in yaml)', + super "specification", "Display gem specification (in yaml)", :domain => :local, :version => Gem::Requirement.default, :format => :yaml - add_version_option('examine') + add_version_option("examine") add_platform_option add_prerelease_option - add_option('--all', 'Output specifications for all versions of', - 'the gem') do |value, options| + add_option("--all", "Output specifications for all versions of", + "the gem") do |value, options| options[:all] = true end - add_option('--ruby', 'Output ruby format') do |value, options| + add_option("--ruby", "Output ruby format") do |value, options| options[:format] = :ruby end - add_option('--yaml', 'Output YAML format') do |value, options| + add_option("--yaml", "Output YAML format") do |value, options| options[:format] = :yaml end - add_option('--marshal', 'Output Marshal format') do |value, options| + add_option("--marshal", "Output Marshal format") do |value, options| options[:format] = :marshal end diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb index 62a97966f1f7..0246f42e3ece 100644 --- a/lib/rubygems/commands/stale_command.rb +++ b/lib/rubygems/commands/stale_command.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" class Gem::Commands::StaleCommand < Gem::Command def initialize - super('stale', 'List gems along with access times') + super("stale", "List gems along with access times") end def description # :nodoc: diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 467c8bf7ed6b..d03a96bf8718 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../version_option' -require_relative '../uninstaller' -require 'fileutils' +require_relative "../command" +require_relative "../version_option" +require_relative "../uninstaller" +require "fileutils" ## # Gem uninstaller command line tool @@ -13,78 +13,78 @@ class Gem::Commands::UninstallCommand < Gem::Command include Gem::VersionOption def initialize - super 'uninstall', 'Uninstall gems from the local repository', + super "uninstall", "Uninstall gems from the local repository", :version => Gem::Requirement.default, :user_install => true, :check_dev => false, :vendor => false - add_option('-a', '--[no-]all', - 'Uninstall all matching versions' + add_option("-a", "--[no-]all", + "Uninstall all matching versions" ) do |value, options| options[:all] = value end - add_option('-I', '--[no-]ignore-dependencies', - 'Ignore dependency requirements while', - 'uninstalling') do |value, options| + add_option("-I", "--[no-]ignore-dependencies", + "Ignore dependency requirements while", + "uninstalling") do |value, options| options[:ignore] = value end - add_option('-D', '--[no-]check-development', - 'Check development dependencies while uninstalling', - '(default: false)') do |value, options| + add_option("-D", "--[no-]check-development", + "Check development dependencies while uninstalling", + "(default: false)") do |value, options| options[:check_dev] = value end - add_option('-x', '--[no-]executables', - 'Uninstall applicable executables without', - 'confirmation') do |value, options| + add_option("-x", "--[no-]executables", + "Uninstall applicable executables without", + "confirmation") do |value, options| options[:executables] = value end - add_option('-i', '--install-dir DIR', - 'Directory to uninstall gem from') do |value, options| + add_option("-i", "--install-dir DIR", + "Directory to uninstall gem from") do |value, options| options[:install_dir] = File.expand_path(value) end - add_option('-n', '--bindir DIR', - 'Directory to remove executables from') do |value, options| + add_option("-n", "--bindir DIR", + "Directory to remove executables from") do |value, options| options[:bin_dir] = File.expand_path(value) end - add_option('--[no-]user-install', - 'Uninstall from user\'s home directory', - 'in addition to GEM_HOME.') do |value, options| + add_option("--[no-]user-install", + "Uninstall from user's home directory", + "in addition to GEM_HOME.") do |value, options| options[:user_install] = value end - add_option('--[no-]format-executable', - 'Assume executable names match Ruby\'s prefix and suffix.') do |value, options| + add_option("--[no-]format-executable", + "Assume executable names match Ruby's prefix and suffix.") do |value, options| options[:format_executable] = value end - add_option('--[no-]force', - 'Uninstall all versions of the named gems', - 'ignoring dependencies') do |value, options| + add_option("--[no-]force", + "Uninstall all versions of the named gems", + "ignoring dependencies") do |value, options| options[:force] = value end - add_option('--[no-]abort-on-dependent', - 'Prevent uninstalling gems that are', - 'depended on by other gems.') do |value, options| + add_option("--[no-]abort-on-dependent", + "Prevent uninstalling gems that are", + "depended on by other gems.") do |value, options| options[:abort_on_dependent] = value end add_version_option add_platform_option - add_option('--vendor', - 'Uninstall gem from the vendor directory.', - 'Only for use by gem repackagers.') do |value, options| + add_option("--vendor", + "Uninstall gem from the vendor directory.", + "Only for use by gem repackagers.") do |value, options| unless Gem.vendor_dir - raise Gem::OptionParser::InvalidOption.new 'your platform is not supported' + raise Gem::OptionParser::InvalidOption.new "your platform is not supported" end - alert_warning 'Use your OS package manager to uninstall vendor gems' + alert_warning "Use your OS package manager to uninstall vendor gems" options[:vendor] = true options[:install_dir] = Gem.vendor_dir end diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb index 3f1708375f98..a365e8541659 100644 --- a/lib/rubygems/commands/unpack_command.rb +++ b/lib/rubygems/commands/unpack_command.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../version_option' -require_relative '../security_option' -require_relative '../remote_fetcher' -require_relative '../package' +require_relative "../command" +require_relative "../version_option" +require_relative "../security_option" +require_relative "../remote_fetcher" +require_relative "../package" # forward-declare @@ -17,18 +17,18 @@ class Gem::Commands::UnpackCommand < Gem::Command include Gem::SecurityOption def initialize - require 'fileutils' + require "fileutils" - super 'unpack', 'Unpack an installed gem to the current directory', + super "unpack", "Unpack an installed gem to the current directory", :version => Gem::Requirement.default, :target => Dir.pwd - add_option('--target=DIR', - 'target directory for unpacking') do |value, options| + add_option("--target=DIR", + "target directory for unpacking") do |value, options| options[:target] = value end - add_option('--spec', 'unpack the gem specification') do |value, options| + add_option("--spec", "unpack the gem specification") do |value, options| options[:spec] = true end @@ -103,11 +103,11 @@ def execute end end - File.open destination, 'w' do |io| + File.open destination, "w" do |io| io.write metadata end else - basename = File.basename path, '.gem' + basename = File.basename path, ".gem" target_dir = File.expand_path basename, options[:target] package = Gem::Package.new path, security_policy diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index 04ce0ea9351b..a0796426699f 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../command_manager' -require_relative '../dependency_installer' -require_relative '../install_update_options' -require_relative '../local_remote_options' -require_relative '../spec_fetcher' -require_relative '../version_option' -require_relative '../install_message' # must come before rdoc for messaging -require_relative '../rdoc' +require_relative "../command" +require_relative "../command_manager" +require_relative "../dependency_installer" +require_relative "../install_update_options" +require_relative "../local_remote_options" +require_relative "../spec_fetcher" +require_relative "../version_option" +require_relative "../install_message" # must come before rdoc for messaging +require_relative "../rdoc" class Gem::Commands::UpdateCommand < Gem::Command include Gem::InstallUpdateOptions @@ -25,7 +25,7 @@ def initialize options.merge!(install_update_options) - super 'update', 'Update installed gems to the latest version', options + super "update", "Update installed gems to the latest version", options add_install_update_options @@ -35,8 +35,8 @@ def initialize value end - add_option('--system [VERSION]', Gem::Version, - 'Update the RubyGems system software') do |value, options| + add_option("--system [VERSION]", Gem::Version, + "Update the RubyGems system software") do |value, options| value = true unless value options[:system] = value @@ -176,13 +176,13 @@ def install_rubygems(spec) # :nodoc: args = update_rubygems_arguments version = spec.version - update_dir = File.join spec.base_dir, 'gems', "rubygems-update-#{version}" + update_dir = File.join spec.base_dir, "gems", "rubygems-update-#{version}" Dir.chdir update_dir do say "Installing RubyGems #{version}" unless options[:silent] installed = preparing_gem_layout_for(version) do - system Gem.ruby, '--disable-gems', 'setup.rb', *args + system Gem.ruby, "--disable-gems", "setup.rb", *args end say "RubyGems system software updated" if installed unless options[:silent] @@ -224,7 +224,7 @@ def rubygems_target_version requirement = Gem::Requirement.new ">= #{Gem::VERSION}" rubygems_update = Gem::Specification.new - rubygems_update.name = 'rubygems-update' + rubygems_update.name = "rubygems-update" rubygems_update.version = version highest_remote_tup = highest_remote_name_tuple(rubygems_update) @@ -278,8 +278,8 @@ def update_rubygems check_oldest_rubygems version - installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement - installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version + installed_gems = Gem::Specification.find_all_by_name "rubygems-update", requirement + installed_gems = update_gem("rubygems-update", version) if installed_gems.empty? || installed_gems.first.version != version return if installed_gems.empty? install_rubygems installed_gems.first @@ -287,11 +287,11 @@ def update_rubygems def update_rubygems_arguments # :nodoc: args = [] - args << '--silent' if options[:silent] - args << '--prefix' << Gem.prefix if Gem.prefix - args << '--no-document' unless options[:document].include?('rdoc') || options[:document].include?('ri') - args << '--no-format-executable' if options[:no_format_executable] - args << '--previous-version' << Gem::VERSION if + args << "--silent" if options[:silent] + args << "--prefix" << Gem.prefix if Gem.prefix + args << "--no-document" unless options[:document].include?("rdoc") || options[:document].include?("ri") + args << "--no-format-executable" if options[:no_format_executable] + args << "--previous-version" << Gem::VERSION if options[:system] == true or Gem::Version.new(options[:system]) >= Gem::Version.new(2) args diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb index 44e87a2b988c..78493e9380ab 100644 --- a/lib/rubygems/commands/which_command.rb +++ b/lib/rubygems/commands/which_command.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require_relative '../command' +require_relative "../command" class Gem::Commands::WhichCommand < Gem::Command def initialize - super 'which', 'Find the location of a library file you can require', + super "which", "Find the location of a library file you can require", :search_gems_first => false, :show_all => false - add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options| + add_option "-a", "--[no-]all", "show all matching files" do |show_all, options| options[:show_all] = show_all end - add_option '-g', '--[no-]gems-first', - 'search gems before non-gems' do |gems_first, options| + add_option "-g", "--[no-]gems-first", + "search gems before non-gems" do |gems_first, options| options[:search_gems_first] = gems_first end end @@ -39,7 +39,7 @@ def execute found = true options[:args].each do |arg| - arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, '') + arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, "") dirs = $LOAD_PATH spec = Gem::Specification.find_by_path arg diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb index cad78aec5f5a..1499f72f5d2f 100644 --- a/lib/rubygems/commands/yank_command.rb +++ b/lib/rubygems/commands/yank_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../command' -require_relative '../local_remote_options' -require_relative '../version_option' -require_relative '../gemcutter_utilities' +require_relative "../command" +require_relative "../local_remote_options" +require_relative "../version_option" +require_relative "../gemcutter_utilities" class Gem::Commands::YankCommand < Gem::Command include Gem::LocalRemoteOptions @@ -28,15 +28,15 @@ def usage # :nodoc: end def initialize - super 'yank', 'Remove a pushed gem from the index' + super "yank", "Remove a pushed gem from the index" add_version_option("remove") add_platform_option("remove") add_otp_option - add_option('--host HOST', - 'Yank from another gemcutter-compatible host', - ' (e.g. https://rubygems.org)') do |value, options| + add_option("--host HOST", + "Yank from another gemcutter-compatible host", + " (e.g. https://rubygems.org)") do |value, options| options[:host] = value end @@ -76,10 +76,10 @@ def yank_api_request(method, version, platform, api) request.add_field("Authorization", api_key) data = { - 'gem_name' => name, - 'version' => version, + "gem_name" => name, + "version" => version, } - data['platform'] = platform if platform + data["platform"] = platform if platform request.set_form_data data end diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 5dd2bfe88daa..d711a51bd08e 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'user_interaction' -require 'rbconfig' +require_relative "user_interaction" +require "rbconfig" ## # Gem::ConfigFile RubyGems options and gem command options from gemrc. @@ -71,7 +71,7 @@ class Gem::ConfigFile # :startdoc: - SYSTEM_WIDE_CONFIG_FILE = File.join SYSTEM_CONFIG_PATH, 'gemrc' + SYSTEM_WIDE_CONFIG_FILE = File.join SYSTEM_CONFIG_PATH, "gemrc" ## # List of arguments supplied to the config file object. @@ -182,20 +182,20 @@ def initialize(args) @update_sources = DEFAULT_UPDATE_SOURCES @concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS @cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS - @ipv4_fallback_enabled = ENV['IPV4_FALLBACK_ENABLED'] == 'true' || DEFAULT_IPV4_FALLBACK_ENABLED + @ipv4_fallback_enabled = ENV["IPV4_FALLBACK_ENABLED"] == "true" || DEFAULT_IPV4_FALLBACK_ENABLED operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS) platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS) system_config = load_file SYSTEM_WIDE_CONFIG_FILE user_config = load_file config_file_name.dup.tap(&Gem::UNTAINT) - environment_config = (ENV['GEMRC'] || '') + environment_config = (ENV["GEMRC"] || "") .split(File::PATH_SEPARATOR).inject({}) do |result, file| result.merge load_file file end @hash = operating_system_config.merge platform_config - unless args.index '--norc' + unless args.index "--norc" @hash = @hash.merge system_config @hash = @hash.merge user_config @hash = @hash.merge environment_config @@ -269,7 +269,7 @@ def check_credentials_permissions # Location of RubyGems.org credentials def credentials_path - credentials = File.join Gem.user_home, '.gem', 'credentials' + credentials = File.join Gem.user_home, ".gem", "credentials" if File.exist? credentials credentials else @@ -320,13 +320,13 @@ def set_api_key(host, api_key) config = load_file(credentials_path).merge(host => api_key) dirname = File.dirname credentials_path - require 'fileutils' + require "fileutils" FileUtils.mkdir_p(dirname) Gem.load_yaml permissions = 0600 & (~File.umask) - File.open(credentials_path, 'w', permissions) do |f| + File.open(credentials_path, "w", permissions) do |f| f.write config.to_yaml end @@ -389,7 +389,7 @@ def each(&block) yield :backtrace, @backtrace yield :bulk_threshold, @bulk_threshold - yield 'config_file_name', @config_file_name if @config_file_name + yield "config_file_name", @config_file_name if @config_file_name hash.each(&block) end @@ -405,7 +405,7 @@ def handle_arguments(arg_list) when /^--debug$/ then $DEBUG = true - warn 'NOTE: Debugging mode prints all exceptions even when rescued' + warn "NOTE: Debugging mode prints all exceptions even when rescued" else @args << arg end @@ -444,7 +444,7 @@ def to_yaml # :nodoc: @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert keys = yaml_hash.keys.map {|key| key.to_s } - keys << 'debug' + keys << "debug" re = Regexp.union(*keys) @hash.each do |key, value| @@ -458,10 +458,10 @@ def to_yaml # :nodoc: # Writes out this config file, replacing its source. def write - require 'fileutils' + require "fileutils" FileUtils.mkdir_p File.dirname(config_file_name) - File.open config_file_name, 'w' do |io| + File.open config_file_name, "w" do |io| io.write to_yaml end end diff --git a/lib/rubygems/core_ext/kernel_gem.rb b/lib/rubygems/core_ext/kernel_gem.rb index e722225739a5..6f96cab84f46 100644 --- a/lib/rubygems/core_ext/kernel_gem.rb +++ b/lib/rubygems/core_ext/kernel_gem.rb @@ -39,7 +39,7 @@ module Kernel # GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb def gem(gem_name, *requirements) # :doc: - skip_list = (ENV['GEM_SKIP'] || "").split(/:/) + skip_list = (ENV["GEM_SKIP"] || "").split(/:/) raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name if gem_name.kind_of? Gem::Dependency diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index 23badd75d2c1..8064d813e1e6 100644 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require 'monitor' +require "monitor" module Kernel diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb index 3373cfdd3b29..7df6c48b8f34 100644 --- a/lib/rubygems/core_ext/kernel_warn.rb +++ b/lib/rubygems/core_ext/kernel_warn.rb @@ -39,7 +39,7 @@ class << self start += 1 if path = loc.path - unless path.start_with?(rubygems_path) or path.start_with?(' Gem.source_date_epoch_string }.merge(env) + build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env) output, status = begin Open3.capture2e(build_env, *command, :chdir => dir) rescue => error @@ -82,7 +82,7 @@ def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {}) results << output end ensure - ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps + ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps end unless status.success? @@ -212,11 +212,11 @@ def build_extensions # Writes +output+ to gem_make.out in the extension install directory. def write_gem_make_out(output) # :nodoc: - destination = File.join @spec.extension_dir, 'gem_make.out' + destination = File.join @spec.extension_dir, "gem_make.out" FileUtils.mkdir_p @spec.extension_dir - File.open destination, 'wb' do |io| + File.open destination, "wb" do |io| io.puts output end diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb index 232c0a313dd2..e33b07a8a233 100644 --- a/lib/rubygems/ext/cargo_builder.rb +++ b/lib/rubygems/ext/cargo_builder.rb @@ -29,14 +29,14 @@ def build(_extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = def build_crate(dest_path, results, args, cargo_dir) env = build_env cmd = cargo_command(cargo_dir, dest_path, args) - runner.call cmd, results, 'cargo', cargo_dir, env + runner.call cmd, results, "cargo", cargo_dir, env results end def build_env build_env = rb_config_env - build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?('RUBY_STATIC') + build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?("RUBY_STATIC") build_env end @@ -46,7 +46,7 @@ def cargo_command(cargo_dir, dest_path, args = []) cmd = [] cmd += [cargo, "rustc"] - cmd += ["--target", ENV['CARGO_BUILD_TARGET']] if ENV['CARGO_BUILD_TARGET'] + cmd += ["--target", ENV["CARGO_BUILD_TARGET"]] if ENV["CARGO_BUILD_TARGET"] cmd += ["--target-dir", dest_path] cmd += ["--manifest-path", manifest] cmd += ["--lib"] @@ -144,13 +144,13 @@ def final_extension_path(dest_path) def cargo_dylib_path(dest_path) prefix = so_ext == "dll" ? "" : "lib" path_parts = [dest_path] - path_parts << ENV['CARGO_BUILD_TARGET'] if ENV['CARGO_BUILD_TARGET'] + path_parts << ENV["CARGO_BUILD_TARGET"] if ENV["CARGO_BUILD_TARGET"] path_parts += [profile_target_directory, "#{prefix}#{cargo_crate_name}.#{so_ext}"] File.join(*path_parts) end def cargo_crate_name - spec.metadata.fetch('cargo_crate_name', spec.name).tr('-', '_') + spec.metadata.fetch("cargo_crate_name", spec.name).tr("-", "_") end def rustc_dynamic_linker_flags(dest_dir) @@ -297,8 +297,8 @@ def get_relative_path(path, base) def profile_target_directory case profile - when :release then 'release' - when :dev then 'debug' + when :release then "release" + when :dev then "debug" else raise "unknown target directory for profile: #{profile}" end end diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb index e47cabef8429..b1626647842a 100644 --- a/lib/rubygems/ext/cmake_builder.rb +++ b/lib/rubygems/ext/cmake_builder.rb @@ -2,8 +2,8 @@ class Gem::Ext::CmakeBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd) - unless File.exist?(File.join(cmake_dir, 'Makefile')) - require_relative '../command' + unless File.exist?(File.join(cmake_dir, "Makefile")) + require_relative "../command" cmd = ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=#{dest_path}", *Gem::Command.build_args] run cmd, results, class_name, cmake_dir diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb index eb2f9fce61d4..51106c63702a 100644 --- a/lib/rubygems/ext/configure_builder.rb +++ b/lib/rubygems/ext/configure_builder.rb @@ -7,7 +7,7 @@ class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, configure_dir=Dir.pwd) - unless File.exist?(File.join(configure_dir, 'Makefile')) + unless File.exist?(File.join(configure_dir, "Makefile")) cmd = ["sh", "./configure", "--prefix=#{dest_path}", *args] run cmd, results, class_name, configure_dir diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 2f0183fe2f72..f8920596d56c 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -7,8 +7,8 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd) - require 'fileutils' - require 'tempfile' + require "fileutils" + require "tempfile" tmp_dest = Dir.mktmpdir(".gem.", extension_dir) @@ -22,16 +22,16 @@ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_di begin require "shellwords" - cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) << File.basename(extension) + cmd = Gem.ruby.shellsplit << "-I" << File.expand_path("../..", __dir__) << File.basename(extension) cmd.push(*args) run(cmd, results, class_name, extension_dir) do |s, r| - mkmf_log = File.join(extension_dir, 'mkmf.log') + mkmf_log = File.join(extension_dir, "mkmf.log") if File.exist? mkmf_log unless s.success? r << "To see why this extension failed to compile, please check" \ " the mkmf.log which can be found here:\n" - r << " " + File.join(dest_path, 'mkmf.log') + "\n" + r << " " + File.join(dest_path, "mkmf.log") + "\n" end FileUtils.mv mkmf_log, dest_path end @@ -67,7 +67,7 @@ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_di private def self.get_relative_path(path, base) - path[0..base.length - 1] = '.' if path.start_with?(base) + path[0..base.length - 1] = "." if path.start_with?(base) path end end diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb index fed98e741c08..9f2e099d40a3 100644 --- a/lib/rubygems/ext/rake_builder.rb +++ b/lib/rubygems/ext/rake_builder.rb @@ -11,16 +11,16 @@ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_di run([Gem.ruby, File.basename(extension), *args], results, class_name, extension_dir) end - rake = ENV['rake'] + rake = ENV["rake"] if rake require "shellwords" rake = rake.shellsplit else begin - rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path('rake', 'rake')] + rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path("rake", "rake")] rescue Gem::Exception - rake = [Gem.default_exec_format % 'rake'] + rake = [Gem.default_exec_format % "rake"] end end diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb index b3f925773b7d..31890a60d72b 100644 --- a/lib/rubygems/gem_runner.rb +++ b/lib/rubygems/gem_runner.rb @@ -5,9 +5,9 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' -require_relative 'command_manager' -require_relative 'deprecate' +require_relative "../rubygems" +require_relative "command_manager" +require_relative "deprecate" ## # Run an instance of the gem program. @@ -41,7 +41,7 @@ def run(args) config_args = Gem.configuration[command_name] config_args = case config_args when String - config_args.split ' ' + config_args.split " " else Array(config_args) end @@ -56,7 +56,7 @@ def run(args) # other arguments in the list. def extract_build_args(args) # :nodoc: - return [] unless offset = args.index('--') + return [] unless offset = args.index("--") build_args = args.slice!(offset...args.length) diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index af0d957bc83b..1eeb341bb853 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'remote_fetcher' -require_relative 'text' +require_relative "remote_fetcher" +require_relative "text" ## # Utility methods for using the RubyGems API. @@ -19,8 +19,8 @@ module Gem::GemcutterUtilities # Add the --key option def add_key_option - add_option('-k', '--key KEYNAME', Symbol, - 'Use the given API key', + add_option("-k", "--key KEYNAME", Symbol, + "Use the given API key", "from #{Gem.configuration.credentials_path}") do |value,options| options[:key] = value end @@ -30,9 +30,9 @@ def add_key_option # Add the --otp option def add_otp_option - add_option('--otp CODE', - 'Digit code for multifactor authentication', - 'You can also use the environment variable GEM_HOST_OTP_CODE') do |value, options| + add_option("--otp CODE", + "Digit code for multifactor authentication", + "You can also use the environment variable GEM_HOST_OTP_CODE") do |value, options| options[:otp] = value end end @@ -69,7 +69,7 @@ def host @host ||= begin - env_rubygems_host = ENV['RUBYGEMS_HOST'] + env_rubygems_host = ENV["RUBYGEMS_HOST"] env_rubygems_host = nil if env_rubygems_host and env_rubygems_host.empty? @@ -83,7 +83,7 @@ def host # If +allowed_push_host+ metadata is present, then it will only allow that host. def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, scope: nil, &block) - require 'net/http' + require "net/http" self.host = host if host unless self.host @@ -118,7 +118,7 @@ def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, scop end def mfa_unauthorized?(response) - response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?('You have enabled multifactor authentication') + response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?("You have enabled multifactor authentication") end def update_scope(scope) @@ -240,13 +240,13 @@ def request_with_otp(method, uri, &block) end def ask_otp - say 'You have enabled multi-factor authentication. Please enter OTP code.' - options[:otp] = ask 'Code: ' + say "You have enabled multi-factor authentication. Please enter OTP code." + options[:otp] = ask "Code: " end def pretty_host(host) if default_host? - 'RubyGems.org' + "RubyGems.org" else host end diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index a5a86f41111c..2299932f45a3 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'package' -require 'tmpdir' +require_relative "../rubygems" +require_relative "package" +require "tmpdir" ## # Top level class for building the gem repository index. @@ -43,28 +43,28 @@ class Gem::Indexer # Create an indexer that will index the gems in +directory+. def initialize(directory, options = {}) - require 'fileutils' - require 'tmpdir' - require 'zlib' + require "fileutils" + require "tmpdir" + require "zlib" options = { :build_modern => true }.merge options @build_modern = options[:build_modern] @dest_directory = directory - @directory = Dir.mktmpdir 'gem_generate_index' + @directory = Dir.mktmpdir "gem_generate_index" marshal_name = "Marshal.#{Gem.marshal_version}" - @master_index = File.join @directory, 'yaml' + @master_index = File.join @directory, "yaml" @marshal_index = File.join @directory, marshal_name - @quick_dir = File.join @directory, 'quick' + @quick_dir = File.join @directory, "quick" @quick_marshal_dir = File.join @quick_dir, marshal_name @quick_marshal_dir_base = File.join "quick", marshal_name # FIX: UGH - @quick_index = File.join @quick_dir, 'index' - @latest_index = File.join @quick_dir, 'latest_index' + @quick_index = File.join @quick_dir, "index" + @latest_index = File.join @quick_dir, "latest_index" @specs_index = File.join @directory, "specs.#{Gem.marshal_version}" @latest_specs_index = @@ -104,7 +104,7 @@ def build_marshal_gemspecs(specs) files = [] - Gem.time 'Generated Marshal quick index gemspecs' do + Gem.time "Generated Marshal quick index gemspecs" do specs.each do |spec| next if spec.default_gem? spec_file_name = "#{spec.original_name}.gemspec.rz" @@ -112,7 +112,7 @@ def build_marshal_gemspecs(specs) marshal_zipped = Gem.deflate Marshal.dump(spec) - File.open marshal_name, 'wb' do |io| + File.open marshal_name, "wb" do |io| io.write marshal_zipped end @@ -136,7 +136,7 @@ def build_modern_index(index, file, name) say "Generating #{name} index" Gem.time "Generated #{name} index" do - File.open(file, 'wb') do |io| + File.open(file, "wb") do |io| specs = index.map do |*spec| # We have to splat here because latest_specs is an array, while the # others are hashes. @@ -169,10 +169,10 @@ def build_modern_indices(specs) latest_specs = Gem::Specification._latest_specs specs - build_modern_index(released.sort, @specs_index, 'specs') - build_modern_index(latest_specs.sort, @latest_specs_index, 'latest specs') + build_modern_index(released.sort, @specs_index, "specs") + build_modern_index(latest_specs.sort, @latest_specs_index, "latest specs") build_modern_index(prerelease.sort, @prerelease_specs_index, - 'prerelease specs') + "prerelease specs") @files += [@specs_index, "#{@specs_index}.gz", @@ -217,7 +217,7 @@ def map_gems_to_specs(gems) def compress_indices say "Compressing indices" - Gem.time 'Compressed indices' do + Gem.time "Compressed indices" do if @build_modern gzip @specs_index gzip @latest_specs_index @@ -252,7 +252,7 @@ def compress(filename, extension) zipped = Gem.deflate data - File.open "#{filename}.#{extension}", 'wb' do |io| + File.open "#{filename}.#{extension}", "wb" do |io| io.write zipped end end @@ -308,7 +308,7 @@ def install_indices end files = files.map do |path| - path.sub(/^#{Regexp.escape @directory}\/?/, '') # HACK? + path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK? end files.each do |file| @@ -358,7 +358,7 @@ def update_index end if updated_gems.empty? - say 'No new gems' + say "No new gems" terminate_interaction 0 end @@ -367,7 +367,7 @@ def update_index files = build_marshal_gemspecs specs - Gem.time 'Updated indexes' do + Gem.time "Updated indexes" do update_specs_index released, @dest_specs_index, @specs_index update_specs_index released, @dest_latest_specs_index, @latest_specs_index update_specs_index(prerelease, @@ -389,7 +389,7 @@ def update_index files << "#{@prerelease_specs_index}.gz" files = files.map do |path| - path.sub(/^#{Regexp.escape @directory}\/?/, '') # HACK? + path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK? end files.each do |file| @@ -420,7 +420,7 @@ def update_specs_index(index, source, dest) specs_index = compact_specs specs_index.uniq.sort - File.open dest, 'wb' do |io| + File.open dest, "wb" do |io| Marshal.dump specs_index, io end end diff --git a/lib/rubygems/install_default_message.rb b/lib/rubygems/install_default_message.rb index 052ef528e175..0d112a15dfb6 100644 --- a/lib/rubygems/install_default_message.rb +++ b/lib/rubygems/install_default_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "user_interaction" ## # A post-install hook that displays "Successfully installed diff --git a/lib/rubygems/install_message.rb b/lib/rubygems/install_message.rb index 861ead3770c1..2565f3626103 100644 --- a/lib/rubygems/install_message.rb +++ b/lib/rubygems/install_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "user_interaction" ## # A default post-install hook that displays "Successfully installed diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb index 454104435dfc..79effcf21f60 100644 --- a/lib/rubygems/install_update_options.rb +++ b/lib/rubygems/install_update_options.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' -require_relative 'security_option' +require_relative "../rubygems" +require_relative "security_option" ## # Mixin methods for install and update options for Gem::Commands @@ -18,22 +18,22 @@ module Gem::InstallUpdateOptions # Add the install/update options to the option parser. def add_install_update_options - add_option(:"Install/Update", '-i', '--install-dir DIR', - 'Gem repository directory to get installed', - 'gems') do |value, options| + add_option(:"Install/Update", "-i", "--install-dir DIR", + "Gem repository directory to get installed", + "gems") do |value, options| options[:install_dir] = File.expand_path(value) end - add_option(:"Install/Update", '-n', '--bindir DIR', - 'Directory where executables will be', - 'placed when the gem is installed') do |value, options| + add_option(:"Install/Update", "-n", "--bindir DIR", + "Directory where executables will be", + "placed when the gem is installed") do |value, options| options[:bin_dir] = File.expand_path(value) end - add_option(:"Install/Update", '--document [TYPES]', Array, - 'Generate documentation for installed gems', - 'List the documentation types you wish to', - 'generate. For example: rdoc,ri') do |value, options| + add_option(:"Install/Update", "--document [TYPES]", Array, + "Generate documentation for installed gems", + "List the documentation types you wish to", + "generate. For example: rdoc,ri") do |value, options| options[:document] = case value when nil then %w[ri] when false then [] @@ -41,63 +41,63 @@ def add_install_update_options end end - add_option(:"Install/Update", '--build-root DIR', - 'Temporary installation root. Useful for building', - 'packages. Do not use this when installing remote gems.') do |value, options| + add_option(:"Install/Update", "--build-root DIR", + "Temporary installation root. Useful for building", + "packages. Do not use this when installing remote gems.") do |value, options| options[:build_root] = File.expand_path(value) end - add_option(:"Install/Update", '--vendor', - 'Install gem into the vendor directory.', - 'Only for use by gem repackagers.') do |value, options| + add_option(:"Install/Update", "--vendor", + "Install gem into the vendor directory.", + "Only for use by gem repackagers.") do |value, options| unless Gem.vendor_dir - raise Gem::OptionParser::InvalidOption.new 'your platform is not supported' + raise Gem::OptionParser::InvalidOption.new "your platform is not supported" end options[:vendor] = true options[:install_dir] = Gem.vendor_dir end - add_option(:"Install/Update", '-N', '--no-document', - 'Disable documentation generation') do |value, options| + add_option(:"Install/Update", "-N", "--no-document", + "Disable documentation generation") do |value, options| options[:document] = [] end - add_option(:"Install/Update", '-E', '--[no-]env-shebang', + add_option(:"Install/Update", "-E", "--[no-]env-shebang", "Rewrite the shebang line on installed", "scripts to use /usr/bin/env") do |value, options| options[:env_shebang] = value end - add_option(:"Install/Update", '-f', '--[no-]force', - 'Force gem to install, bypassing dependency', - 'checks') do |value, options| + add_option(:"Install/Update", "-f", "--[no-]force", + "Force gem to install, bypassing dependency", + "checks") do |value, options| options[:force] = value end - add_option(:"Install/Update", '-w', '--[no-]wrappers', - 'Use bin wrappers for executables', - 'Not available on dosish platforms') do |value, options| + add_option(:"Install/Update", "-w", "--[no-]wrappers", + "Use bin wrappers for executables", + "Not available on dosish platforms") do |value, options| options[:wrappers] = value end add_security_option - add_option(:"Install/Update", '--ignore-dependencies', - 'Do not install any required dependent gems') do |value, options| + add_option(:"Install/Update", "--ignore-dependencies", + "Do not install any required dependent gems") do |value, options| options[:ignore_dependencies] = value end - add_option(:"Install/Update", '--[no-]format-executable', - 'Make installed executable names match Ruby.', - 'If Ruby is ruby18, foo_exec will be', - 'foo_exec18') do |value, options| + add_option(:"Install/Update", "--[no-]format-executable", + "Make installed executable names match Ruby.", + "If Ruby is ruby18, foo_exec will be", + "foo_exec18") do |value, options| options[:format_executable] = value end - add_option(:"Install/Update", '--[no-]user-install', - 'Install in user\'s home directory instead', - 'of GEM_HOME.') do |value, options| + add_option(:"Install/Update", "--[no-]user-install", + "Install in user's home directory instead", + "of GEM_HOME.") do |value, options| options[:user_install] = value end @@ -133,9 +133,9 @@ def add_install_update_options options[:post_install_message] = value end - add_option(:"Install/Update", '-g', '--file [FILE]', - 'Read from a gem dependencies API file and', - 'install the listed gems') do |v,o| + add_option(:"Install/Update", "-g", "--file [FILE]", + "Read from a gem dependencies API file and", + "install the listed gems") do |v,o| v = Gem::GEM_DEP_FILES.find do |file| File.exist? file end unless v @@ -150,32 +150,32 @@ def add_install_update_options options[:gemdeps] = v end - add_option(:"Install/Update", '--without GROUPS', Array, - 'Omit the named groups (comma separated)', - 'when installing from a gem dependencies', - 'file') do |v,o| + add_option(:"Install/Update", "--without GROUPS", Array, + "Omit the named groups (comma separated)", + "when installing from a gem dependencies", + "file") do |v,o| options[:without_groups].concat v.map {|without| without.intern } end - add_option(:"Install/Update", '--default', - 'Add the gem\'s full specification to', - 'specifications/default and extract only its bin') do |v,o| + add_option(:"Install/Update", "--default", + "Add the gem's full specification to", + "specifications/default and extract only its bin") do |v,o| options[:install_as_default] = v end - add_option(:"Install/Update", '--explain', - 'Rather than install the gems, indicate which would', - 'be installed') do |v,o| + add_option(:"Install/Update", "--explain", + "Rather than install the gems, indicate which would", + "be installed") do |v,o| options[:explain] = v end - add_option(:"Install/Update", '--[no-]lock', - 'Create a lock file (when used with -g/--file)') do |v,o| + add_option(:"Install/Update", "--[no-]lock", + "Create a lock file (when used with -g/--file)") do |v,o| options[:lock] = v end - add_option(:"Install/Update", '--[no-]suggestions', - 'Suggest alternates when gems are not found') do |v,o| + add_option(:"Install/Update", "--[no-]suggestions", + "Suggest alternates when gems are not found") do |v,o| options[:suggest_alternate] = v end end @@ -193,7 +193,7 @@ def install_update_options # Default description for the gem install and update commands. def install_update_defaults_str - '--document=ri' + "--document=ri" end end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 748414546702..52307f6d930d 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -5,12 +5,12 @@ # See LICENSE.txt for permissions. #++ -require_relative 'installer_uninstaller_utils' -require_relative 'exceptions' -require_relative 'deprecate' -require_relative 'package' -require_relative 'ext' -require_relative 'user_interaction' +require_relative "installer_uninstaller_utils" +require_relative "exceptions" +require_relative "deprecate" +require_relative "package" +require_relative "ext" +require_relative "user_interaction" ## # The installer installs the files contained in the .gem into the Gem.home. @@ -125,14 +125,14 @@ def initialize(spec) @spec = spec end - def extract_files(destination_dir, pattern = '*') + def extract_files(destination_dir, pattern = "*") FileUtils.mkdir_p destination_dir spec.files.each do |file| file = File.join destination_dir, file next if File.exist? file FileUtils.mkdir_p File.dirname(file) - File.open file, 'w' do |fp| + File.open file, "w" do |fp| fp.puts "# #{file}" end end @@ -177,7 +177,7 @@ def self.for_spec(spec, options = {}) # :post_install_message:: Print gem post install message if true def initialize(package, options={}) - require 'fileutils' + require "fileutils" @options = options @package = package @@ -219,7 +219,7 @@ def check_executable_overwrite(filename) # :nodoc: ruby_executable = false existing = nil - File.open generated_bin, 'rb' do |io| + File.open generated_bin, "rb" do |io| line = io.gets shebang = /^#!.*ruby/ @@ -256,7 +256,7 @@ def check_executable_overwrite(filename) # :nodoc: question = "#{spec.name}'s executable \"#{filename}\" conflicts with ".dup if ruby_executable - question << (existing || 'an unknown executable') + question << (existing || "an unknown executable") return if ask_yes_no "#{question}\nOverwrite the executable?", false @@ -474,7 +474,7 @@ def generate_windows_script(filename, bindir) if Gem.win_platform? script_name = formatted_program_filename(filename) + ".bat" script_path = File.join bindir, File.basename(script_name) - File.open script_path, 'w' do |file| + File.open script_path, "w" do |file| file.puts windows_stub_script(bindir, filename) end @@ -504,7 +504,7 @@ def generate_bin # :nodoc: dir_mode = options[:prog_mode] || (mode | 0111) unless dir_mode == mode - require 'fileutils' + require "fileutils" FileUtils.chmod dir_mode, bin_path end @@ -541,10 +541,10 @@ def generate_plugins # :nodoc: def generate_bin_script(filename, bindir) bin_script_path = File.join bindir, formatted_program_filename(filename) - require 'fileutils' + require "fileutils" FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers - File.open bin_script_path, 'wb', 0755 do |file| + File.open bin_script_path, "wb", 0755 do |file| file.print app_script_text(filename) file.chmod(options[:prog_mode] || 0755) end @@ -565,7 +565,7 @@ def generate_bin_symlink(filename, bindir) if File.exist? dst if File.symlink? dst link = File.readlink(dst).split File::SEPARATOR - cur_version = Gem::Version.create(link[-3].sub(/^.*-/, '')) + cur_version = Gem::Version.create(link[-3].sub(/^.*-/, "")) return if spec.version < cur_version end File.unlink dst @@ -684,9 +684,9 @@ def process_options # :nodoc: @build_args = options[:build_args] unless @build_root.nil? - @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, '')) - @gem_home = File.join(@build_root, @gem_home.gsub(/^[a-zA-Z]:/, '')) - @plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, '')) + @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, "")) + @gem_home = File.join(@build_root, @gem_home.gsub(/^[a-zA-Z]:/, "")) + @plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, "")) alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}\n Plugins dir: #{@plugins_dir}" end end @@ -697,7 +697,7 @@ def check_that_user_bin_dir_is_in_path # :nodoc: user_bin_dir = @bin_dir || Gem.bindir(gem_home) user_bin_dir = user_bin_dir.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR - path = ENV['PATH'] + path = ENV["PATH"] path = path.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR if Gem.win_platform? @@ -708,7 +708,7 @@ def check_that_user_bin_dir_is_in_path # :nodoc: path = path.split(File::PATH_SEPARATOR) unless path.include? user_bin_dir - unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV['HOME'], '~')) + unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV["HOME"], "~")) alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run." self.class.path_warning = true end @@ -788,7 +788,7 @@ def app_script_text(bin_file_name) end def gemdeps_load(name) - return '' if name == "bundler" + return "" if name == "bundler" <<-TEXT @@ -824,7 +824,7 @@ def windows_stub_script(bindir, bin_file_name) TEXT elsif bindir.downcase.start_with? rb_topdir.downcase # stub within ruby folder, but not standard bin. Portable - require 'pathname' + require "pathname" from = Pathname.new bindir to = Pathname.new "#{rb_topdir}/bin" rel = to.relative_path_from from @@ -935,14 +935,14 @@ def pre_install_checks def write_build_info_file return if build_args.empty? - build_info_dir = File.join gem_home, 'build_info' + build_info_dir = File.join gem_home, "build_info" dir_mode = options[:dir_mode] FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755 build_info_file = File.join build_info_dir, "#{spec.full_name}.info" - File.open build_info_file, 'w' do |io| + File.open build_info_file, "w" do |io| build_args.each do |arg| io.puts arg end @@ -955,7 +955,7 @@ def write_build_info_file # Writes the .gem file to the cache directory def write_cache_file - cache_file = File.join gem_home, 'cache', spec.file_name + cache_file = File.join gem_home, "cache", spec.file_name @package.copy_to cache_file end @@ -987,7 +987,7 @@ def ruby_install_name end def load_relative_enabled? - rb_config["LIBRUBY_RELATIVE"] == 'yes' + rb_config["LIBRUBY_RELATIVE"] == "yes" end def bash_prolog_script diff --git a/lib/rubygems/installer_uninstaller_utils.rb b/lib/rubygems/installer_uninstaller_utils.rb index 2c8b7c635e19..d97b4e29b19e 100644 --- a/lib/rubygems/installer_uninstaller_utils.rb +++ b/lib/rubygems/installer_uninstaller_utils.rb @@ -9,12 +9,12 @@ def regenerate_plugins_for(spec, plugins_dir) plugins = spec.plugins return if plugins.empty? - require 'pathname' + require "pathname" spec.plugins.each do |plugin| plugin_script_path = File.join plugins_dir, "#{spec.name}_plugin#{File.extname(plugin)}" - File.open plugin_script_path, 'wb' do |file| + File.open plugin_script_path, "wb" do |file| file.puts "require_relative '#{Pathname.new(plugin).relative_path_from(Pathname.new(plugins_dir))}'" end diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb index 6b5e08bf1c02..b2c2dea905ed 100644 --- a/lib/rubygems/local_remote_options.rb +++ b/lib/rubygems/local_remote_options.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require 'uri' -require_relative '../rubygems' +require "uri" +require_relative "../rubygems" ## # Mixin methods for local and remote Gem::Command options. @@ -38,18 +38,18 @@ def accept_uri_http # Add local/remote options to the command line parser. def add_local_remote_options - add_option(:"Local/Remote", '-l', '--local', - 'Restrict operations to the LOCAL domain') do |value, options| + add_option(:"Local/Remote", "-l", "--local", + "Restrict operations to the LOCAL domain") do |value, options| options[:domain] = :local end - add_option(:"Local/Remote", '-r', '--remote', - 'Restrict operations to the REMOTE domain') do |value, options| + add_option(:"Local/Remote", "-r", "--remote", + "Restrict operations to the REMOTE domain") do |value, options| options[:domain] = :remote end - add_option(:"Local/Remote", '-b', '--both', - 'Allow LOCAL and REMOTE operations') do |value, options| + add_option(:"Local/Remote", "-b", "--both", + "Allow LOCAL and REMOTE operations") do |value, options| options[:domain] = :both end @@ -64,7 +64,7 @@ def add_local_remote_options # Add the --bulk-threshold option def add_bulk_threshold_option - add_option(:"Local/Remote", '-B', '--bulk-threshold COUNT', + add_option(:"Local/Remote", "-B", "--bulk-threshold COUNT", "Threshold for switching to bulk", "synchronization (default #{Gem.configuration.bulk_threshold})") do |value, options| @@ -76,8 +76,8 @@ def add_bulk_threshold_option # Add the --clear-sources option def add_clear_sources_option - add_option(:"Local/Remote", '--clear-sources', - 'Clear the gem sources') do |value, options| + add_option(:"Local/Remote", "--clear-sources", + "Clear the gem sources") do |value, options| Gem.sources = nil options[:sources_cleared] = true end @@ -89,8 +89,8 @@ def add_clear_sources_option def add_proxy_option accept_uri_http - add_option(:"Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP, - 'Use HTTP proxy for remote operations') do |value, options| + add_option(:"Local/Remote", "-p", "--[no-]http-proxy [URL]", URI::HTTP, + "Use HTTP proxy for remote operations") do |value, options| options[:http_proxy] = (value == false) ? :no_proxy : value Gem.configuration[:http_proxy] = options[:http_proxy] end @@ -102,9 +102,9 @@ def add_proxy_option def add_source_option accept_uri_http - add_option(:"Local/Remote", '-s', '--source URL', URI::HTTP, - 'Append URL to list of remote gem sources') do |source, options| - source << '/' if source !~ /\/\z/ + add_option(:"Local/Remote", "-s", "--source URL", URI::HTTP, + "Append URL to list of remote gem sources") do |source, options| + source << "/" if source !~ /\/\z/ if options.delete :sources_cleared Gem.sources = [source] @@ -118,8 +118,8 @@ def add_source_option # Add the --update-sources option def add_update_sources_option - add_option(:Deprecated, '-u', '--[no-]update-sources', - 'Update local source cache') do |value, options| + add_option(:Deprecated, "-u", "--[no-]update-sources", + "Update local source cache") do |value, options| Gem.configuration.update_sources = value end end diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb index 914ecb9a71ef..5cc67ad09944 100644 --- a/lib/rubygems/mock_gem_ui.rb +++ b/lib/rubygems/mock_gem_ui.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'user_interaction' +require_relative "user_interaction" ## # This Gem::StreamUI subclass records input and output to StringIO for @@ -40,7 +40,7 @@ def noecho end def initialize(input = "") - require 'stringio' + require "stringio" ins = StringIO.new input outs = StringIO.new errs = StringIO.new diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb index c732d7f968e1..b9f330ee4db3 100644 --- a/lib/rubygems/name_tuple.rb +++ b/lib/rubygems/name_tuple.rb @@ -48,7 +48,7 @@ def self.null def full_name case @platform - when nil, 'ruby', '' + when nil, "ruby", "" "#{@name}-#{@version}" else "#{@name}-#{@version}-#{@platform}" diff --git a/lib/rubygems/optparse.rb b/lib/rubygems/optparse.rb index 65be9f6b74ba..6ed718423c91 100644 --- a/lib/rubygems/optparse.rb +++ b/lib/rubygems/optparse.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require_relative 'optparse/lib/optparse' +require_relative "optparse/lib/optparse" diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb index 2dd8e8c28e9f..1e87837b0e90 100644 --- a/lib/rubygems/package.rb +++ b/lib/rubygems/package.rb @@ -5,8 +5,8 @@ #++ require_relative "../rubygems" -require_relative 'security' -require_relative 'user_interaction' +require_relative "security" +require_relative "user_interaction" ## # Example using a Gem::Package @@ -158,7 +158,7 @@ def self.new(gem, security_policy = nil) return super unless gem.present? return super unless gem.start - return super unless gem.start.include? 'MD5SUM =' + return super unless gem.start.include? "MD5SUM =" Gem::Package::Old.new gem end @@ -178,9 +178,9 @@ def self.raw_spec(path, security_policy = nil) tar = Gem::Package::TarReader.new io tar.each_entry do |entry| case entry.full_name - when 'metadata' then + when "metadata" then metadata = entry.read - when 'metadata.gz' then + when "metadata.gz" then metadata = Gem::Util.gunzip entry.read end end @@ -193,7 +193,7 @@ def self.raw_spec(path, security_policy = nil) # Creates a new package that will read or write to the file +gem+. def initialize(gem, security_policy) # :notnew: - require 'zlib' + require "zlib" @gem = gem @@ -229,7 +229,7 @@ def add_checksums(tar) end end - tar.add_file_signed 'checksums.yaml.gz', 0444, @signer do |io| + tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io| gzip_to io do |gz_io| Psych.dump checksums_by_algorithm, gz_io end @@ -241,7 +241,7 @@ def add_checksums(tar) # and adds this file to the +tar+. def add_contents(tar) # :nodoc: - digests = tar.add_file_signed 'data.tar.gz', 0444, @signer do |io| + digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io| gzip_to io do |gz_io| Gem::Package::TarWriter.new gz_io do |data_tar| add_files data_tar @@ -249,7 +249,7 @@ def add_contents(tar) # :nodoc: end end - @checksums['data.tar.gz'] = digests + @checksums["data.tar.gz"] = digests end ## @@ -266,7 +266,7 @@ def add_files(tar) # :nodoc: next unless stat.file? tar.add_file_simple file, stat.mode, stat.size do |dst_io| - File.open file, 'rb' do |src_io| + File.open file, "rb" do |src_io| dst_io.write src_io.read 16384 until src_io.eof? end end @@ -277,13 +277,13 @@ def add_files(tar) # :nodoc: # Adds the package's Gem::Specification to the +tar+ file def add_metadata(tar) # :nodoc: - digests = tar.add_file_signed 'metadata.gz', 0444, @signer do |io| + digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io| gzip_to io do |gz_io| gz_io.write @spec.to_yaml end end - @checksums['metadata.gz'] = digests + @checksums["metadata.gz"] = digests end ## @@ -335,7 +335,7 @@ def contents gem_tar = Gem::Package::TarReader.new io gem_tar.each do |entry| - next unless entry.full_name == 'data.tar.gz' + next unless entry.full_name == "data.tar.gz" open_tar_gz entry do |pkg_tar| pkg_tar.each do |contents_entry| @@ -387,7 +387,7 @@ def extract_files(destination_dir, pattern = "*") reader = Gem::Package::TarReader.new io reader.each do |entry| - next unless entry.full_name == 'data.tar.gz' + next unless entry.full_name == "data.tar.gz" extract_tar_gz entry, destination_dir, pattern @@ -420,7 +420,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc: real_destination = link_target.start_with?("/") ? link_target : File.expand_path(link_target, File.dirname(destination)) raise Gem::Package::SymlinkError.new(entry.full_name, real_destination, destination_dir) unless - normalize_path(real_destination).start_with? normalize_path(destination_dir + '/') + normalize_path(real_destination).start_with? normalize_path(destination_dir + "/") end FileUtils.rm_rf destination @@ -439,7 +439,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc: directories << mkdir end - File.open destination, 'wb' do |out| + File.open destination, "wb" do |out| out.write entry.read FileUtils.chmod file_mode(entry.header.mode), destination end if entry.file? @@ -481,13 +481,13 @@ def gzip_to(io) # :yields: gz_io def install_location(filename, destination_dir) # :nodoc: raise Gem::Package::PathError.new(filename, destination_dir) if - filename.start_with? '/' + filename.start_with? "/" destination_dir = File.realpath(destination_dir) destination = File.expand_path(filename, destination_dir) raise Gem::Package::PathError.new(destination, destination_dir) unless - normalize_path(destination).start_with? normalize_path(destination_dir + '/') + normalize_path(destination).start_with? normalize_path(destination_dir + "/") destination.tap(&Gem::UNTAINT) destination @@ -506,9 +506,9 @@ def normalize_path(pathname) def load_spec(entry) # :nodoc: case entry.full_name - when 'metadata' then + when "metadata" then @spec = Gem::Specification.from_yaml entry.read - when 'metadata.gz' then + when "metadata.gz" then Zlib::GzipReader.wrap(entry, external_encoding: Encoding::UTF_8) do |gzio| @spec = Gem::Specification.from_yaml gzio.read end @@ -532,7 +532,7 @@ def open_tar_gz(io) # :nodoc: def read_checksums(gem) Gem.load_yaml - @checksums = gem.seek 'checksums.yaml.gz' do |entry| + @checksums = gem.seek "checksums.yaml.gz" do |entry| Zlib::GzipReader.wrap entry do |gz_io| Gem::SafeYAML.safe_load gz_io.read end @@ -544,7 +544,7 @@ def read_checksums(gem) # certificate and key are not present only checksum generation is set up. def setup_signer(signer_options: {}) - passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] + passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"] if @spec.signing_key @signer = Gem::Security::Signer.new( @@ -651,7 +651,7 @@ def verify_entry(entry) case file_name when "metadata", "metadata.gz" then load_spec entry - when 'data.tar.gz' then + when "data.tar.gz" then verify_gz entry end rescue @@ -668,12 +668,12 @@ def verify_files(gem) end unless @spec - raise Gem::Package::FormatError.new 'package metadata is missing', @gem + raise Gem::Package::FormatError.new "package metadata is missing", @gem end - unless @files.include? 'data.tar.gz' + unless @files.include? "data.tar.gz" raise Gem::Package::FormatError.new \ - 'package content (data.tar.gz) is missing', @gem + "package content (data.tar.gz) is missing", @gem end if duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first) and duplicates.any? @@ -693,12 +693,12 @@ def verify_gz(entry) # :nodoc: end end -require_relative 'package/digest_io' -require_relative 'package/source' -require_relative 'package/file_source' -require_relative 'package/io_source' -require_relative 'package/old' -require_relative 'package/tar_header' -require_relative 'package/tar_reader' -require_relative 'package/tar_reader/entry' -require_relative 'package/tar_writer' +require_relative "package/digest_io" +require_relative "package/source" +require_relative "package/file_source" +require_relative "package/io_source" +require_relative "package/old" +require_relative "package/tar_header" +require_relative "package/tar_reader" +require_relative "package/tar_reader/entry" +require_relative "package/tar_writer" diff --git a/lib/rubygems/package/file_source.rb b/lib/rubygems/package/file_source.rb index 114a950c77ee..14c7a9f6d217 100644 --- a/lib/rubygems/package/file_source.rb +++ b/lib/rubygems/package/file_source.rb @@ -22,10 +22,10 @@ def present? end def with_write_io(&block) - File.open path, 'wb', &block + File.open path, "wb", &block end def with_read_io(&block) - File.open path, 'rb', &block + File.open path, "rb", &block end end diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb index 301d403411af..09a02d3ecd62 100644 --- a/lib/rubygems/package/old.rb +++ b/lib/rubygems/package/old.rb @@ -19,8 +19,8 @@ class Gem::Package::Old < Gem::Package # cannot be written. def initialize(gem, security_policy) - require 'fileutils' - require 'zlib' + require "fileutils" + require "zlib" Gem.load_yaml @contents = nil @@ -41,7 +41,7 @@ def contents read_until_dashes io # spec header = file_list io - @contents = header.map {|file| file['path'] } + @contents = header.map {|file| file["path"] } end end @@ -59,7 +59,7 @@ def extract_files(destination_dir) raise Gem::Exception, errstr unless header header.each do |entry| - full_name = entry['path'] + full_name = entry["path"] destination = install_location full_name, destination_dir @@ -73,13 +73,13 @@ def extract_files(destination_dir) file_data = Zlib::Inflate.inflate file_data raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if - file_data.length != entry['size'].to_i + file_data.length != entry["size"].to_i FileUtils.rm_rf destination FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755 - File.open destination, 'wb', file_mode(entry['mode']) do |out| + File.open destination, "wb", file_mode(entry["mode"]) do |out| out.write file_data end @@ -119,7 +119,7 @@ def skip_ruby(io) # :nodoc: loop do line = io.gets - return if line.chomp == '__END__' + return if line.chomp == "__END__" break unless line end @@ -160,7 +160,7 @@ def verify return true unless @security_policy raise Gem::Security::Exception, - 'old format gems do not contain signatures and cannot be verified' if + "old format gems do not contain signatures and cannot be verified" if @security_policy.verify_data true diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb index ce9b49e3ebef..fb70765dde2f 100644 --- a/lib/rubygems/package/tar_header.rb +++ b/lib/rubygems/package/tar_header.rb @@ -53,42 +53,42 @@ class Gem::Package::TarHeader ## # Pack format for a tar header - PACK_FORMAT = 'a100' + # name - 'a8' + # mode - 'a8' + # uid - 'a8' + # gid - 'a12' + # size - 'a12' + # mtime - 'a7a' + # chksum - 'a' + # typeflag - 'a100' + # linkname - 'a6' + # magic - 'a2' + # version - 'a32' + # uname - 'a32' + # gname - 'a8' + # devmajor - 'a8' + # devminor - 'a155' # prefix + PACK_FORMAT = "a100" + # name + "a8" + # mode + "a8" + # uid + "a8" + # gid + "a12" + # size + "a12" + # mtime + "a7a" + # chksum + "a" + # typeflag + "a100" + # linkname + "a6" + # magic + "a2" + # version + "a32" + # uname + "a32" + # gname + "a8" + # devmajor + "a8" + # devminor + "a155" # prefix ## # Unpack format for a tar header - UNPACK_FORMAT = 'A100' + # name - 'A8' + # mode - 'A8' + # uid - 'A8' + # gid - 'A12' + # size - 'A12' + # mtime - 'A8' + # checksum - 'A' + # typeflag - 'A100' + # linkname - 'A6' + # magic - 'A2' + # version - 'A32' + # uname - 'A32' + # gname - 'A8' + # devmajor - 'A8' + # devminor - 'A155' # prefix + UNPACK_FORMAT = "A100" + # name + "A8" + # mode + "A8" + # uid + "A8" + # gid + "A12" + # size + "A12" + # mtime + "A8" + # checksum + "A" + # typeflag + "A100" + # linkname + "A6" + # magic + "A2" + # version + "A32" + # uname + "A32" + # gname + "A8" + # devmajor + "A8" + # devminor + "A155" # prefix attr_reader(*FIELDS) @@ -134,7 +134,7 @@ def self.oct_or_256based(str) # \ff flags a negative 256-based number # In case we have a match, parse it as a signed binary value # in big-endian order, except that the high-order bit is ignored. - return str.unpack('N2').last if str =~ /\A[\x80\xff]/n + return str.unpack("N2").last if str =~ /\A[\x80\xff]/n strict_oct(str) end diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb index 41121f3bfb39..cdc3fdc01515 100644 --- a/lib/rubygems/package/tar_reader.rb +++ b/lib/rubygems/package/tar_reader.rb @@ -121,4 +121,4 @@ def seek(name) # :yields: entry end end -require_relative 'tar_reader/entry' +require_relative "tar_reader/entry" diff --git a/lib/rubygems/package/tar_reader/entry.rb b/lib/rubygems/package/tar_reader/entry.rb index 5865599d3aab..8634381c18f0 100644 --- a/lib/rubygems/package/tar_reader/entry.rb +++ b/lib/rubygems/package/tar_reader/entry.rb @@ -68,9 +68,9 @@ def full_name @header.name end rescue ArgumentError => e - raise unless e.message == 'string contains null byte' + raise unless e.message == "string contains null byte" raise Gem::Package::TarInvalidError, - 'tar is corrupt, name contains null byte' + "tar is corrupt, name contains null byte" end ## diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb index 877cc167c92d..6f068f50c22b 100644 --- a/lib/rubygems/package/tar_writer.rb +++ b/lib/rubygems/package/tar_writer.rb @@ -166,7 +166,7 @@ def add_file_digest(name, mode, digest_algorithms) # :yields: io def add_file_signed(name, mode, signer) digest_algorithms = [ signer.digest_algorithm, - Gem::Security.create_digest('SHA512'), + Gem::Security.create_digest("SHA512"), ].compact.uniq digests = add_file_digest name, mode, digest_algorithms do |io| @@ -304,14 +304,14 @@ def split_name(name) # :nodoc: raise Gem::Package::TooLongFileName.new("File \"#{name}\" has a too long path (should be 256 or less)") end - prefix = '' + prefix = "" if name.bytesize > 100 - parts = name.split('/', -1) # parts are never empty here + parts = name.split("/", -1) # parts are never empty here name = parts.pop # initially empty for names with a trailing slash ("foo/.../bar/") - prefix = parts.join('/') # if empty, then it's impossible to split (parts is empty too) + prefix = parts.join("/") # if empty, then it's impossible to split (parts is empty too) while !parts.empty? && (prefix.bytesize > 155 || name.empty?) - name = parts.pop + '/' + name - prefix = parts.join('/') + name = parts.pop + "/" + name + prefix = parts.join("/") end if name.bytesize > 100 or prefix.empty? diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb index bb48616b0eec..8432bc580658 100644 --- a/lib/rubygems/package_task.rb +++ b/lib/rubygems/package_task.rb @@ -20,9 +20,9 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require_relative '../rubygems' -require_relative 'package' -require 'rake/packagetask' +require_relative "../rubygems" +require_relative "package" +require "rake/packagetask" ## # Create a package based upon a Gem::Specification. Gem packages, as well as @@ -113,7 +113,7 @@ def define Gem::Package.build gem_spec verbose trace do - mv gem_file, '..' + mv gem_file, ".." end end end diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 8fcabf164d07..607e3906d6ed 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -12,7 +12,7 @@ class Gem::Platform attr_accessor :cpu, :os, :version def self.local - arch = RbConfig::CONFIG['arch'] + arch = RbConfig::CONFIG["arch"] arch = "#{arch}_60" if arch =~ /mswin(?:32|64)$/ @local ||= new(arch) end @@ -56,7 +56,7 @@ def self.new(arch) # :nodoc: case arch when Gem::Platform::CURRENT then Gem::Platform.local - when Gem::Platform::RUBY, nil, '' then + when Gem::Platform::RUBY, nil, "" then Gem::Platform::RUBY else super @@ -68,7 +68,7 @@ def initialize(arch) when Array then @cpu, @os, @version = arch when String then - arch = arch.split '-' + arch = arch.split "-" if arch.length > 2 and arch.last !~ /\d/ # reassemble x86-linux-gnu extra = arch.pop @@ -78,7 +78,7 @@ def initialize(arch) cpu = arch.shift @cpu = case cpu - when /i\d86/ then 'x86' + when /i\d86/ then "x86" else cpu end @@ -91,31 +91,31 @@ def initialize(arch) @cpu, os = nil, cpu if os.nil? # legacy jruby @os, @version = case os - when /aix(\d+)?/ then [ 'aix', $1 ] - when /cygwin/ then [ 'cygwin', nil ] - when /darwin(\d+)?/ then [ 'darwin', $1 ] - when /^macruby$/ then [ 'macruby', nil ] - when /freebsd(\d+)?/ then [ 'freebsd', $1 ] - when /hpux(\d+)?/ then [ 'hpux', $1 ] - when /^java$/, /^jruby$/ then [ 'java', nil ] - when /^java([\d.]*)/ then [ 'java', $1 ] - when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ] - when /^dotnet$/ then [ 'dotnet', nil ] - when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ] - when /linux-?((?!gnu)\w+)?/ then [ 'linux', $1 ] - when /mingw32/ then [ 'mingw32', nil ] - when /mingw-?(\w+)?/ then [ 'mingw', $1 ] + when /aix(\d+)?/ then [ "aix", $1 ] + when /cygwin/ then [ "cygwin", nil ] + when /darwin(\d+)?/ then [ "darwin", $1 ] + when /^macruby$/ then [ "macruby", nil ] + when /freebsd(\d+)?/ then [ "freebsd", $1 ] + when /hpux(\d+)?/ then [ "hpux", $1 ] + when /^java$/, /^jruby$/ then [ "java", nil ] + when /^java([\d.]*)/ then [ "java", $1 ] + when /^dalvik(\d+)?$/ then [ "dalvik", $1 ] + when /^dotnet$/ then [ "dotnet", nil ] + when /^dotnet([\d.]*)/ then [ "dotnet", $1 ] + when /linux-?((?!gnu)\w+)?/ then [ "linux", $1 ] + when /mingw32/ then [ "mingw32", nil ] + when /mingw-?(\w+)?/ then [ "mingw", $1 ] when /(mswin\d+)(\_(\d+))?/ then os, version = $1, $3 - @cpu = 'x86' if @cpu.nil? and os =~ /32$/ + @cpu = "x86" if @cpu.nil? and os =~ /32$/ [os, version] - when /netbsdelf/ then [ 'netbsdelf', nil ] - when /openbsd(\d+\.\d+)?/ then [ 'openbsd', $1 ] - when /bitrig(\d+\.\d+)?/ then [ 'bitrig', $1 ] - when /solaris(\d+\.\d+)?/ then [ 'solaris', $1 ] + when /netbsdelf/ then [ "netbsdelf", nil ] + when /openbsd(\d+\.\d+)?/ then [ "openbsd", $1 ] + when /bitrig(\d+\.\d+)?/ then [ "bitrig", $1 ] + when /solaris(\d+\.\d+)?/ then [ "solaris", $1 ] # test when /^(\w+_platform)(\d+)?/ then [ $1, $2 ] - else [ 'unknown', nil ] + else [ "unknown", nil ] end when Gem::Platform then @cpu = arch.cpu @@ -131,7 +131,7 @@ def to_a end def to_s - to_a.compact.join '-' + to_a.compact.join "-" end ## @@ -160,12 +160,12 @@ def ===(other) return nil unless Gem::Platform === other # universal-mingw32 matches x64-mingw-ucrt - return true if (@cpu == 'universal' or other.cpu == 'universal') and - @os.start_with?('mingw') and other.os.start_with?('mingw') + return true if (@cpu == "universal" or other.cpu == "universal") and + @os.start_with?("mingw") and other.os.start_with?("mingw") # cpu - ([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or - (@cpu == 'arm' and other.cpu.start_with?("arm"))) and + ([nil,"universal"].include?(@cpu) or [nil, "universal"].include?(other.cpu) or @cpu == other.cpu or + (@cpu == "arm" and other.cpu.start_with?("arm"))) and # os @os == other.os and @@ -184,17 +184,17 @@ def =~(other) when String then # This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007 other = case other - when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ] - when /^i\d86-linux/ then ['x86', 'linux', nil ] - when 'java', 'jruby' then [nil, 'java', nil ] - when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ] - when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ] - when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ] - when /mswin64(\_(\d+))?/ then ['x64', 'mswin64', $2 ] - when 'powerpc-darwin' then ['powerpc', 'darwin', nil ] - when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ] - when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8' ] - when /universal-darwin(\d)/ then ['universal', 'darwin', $1 ] + when /^i686-darwin(\d)/ then ["x86", "darwin", $1 ] + when /^i\d86-linux/ then ["x86", "linux", nil ] + when "java", "jruby" then [nil, "java", nil ] + when /^dalvik(\d+)?$/ then [nil, "dalvik", $1 ] + when /dotnet(\-(\d+\.\d+))?/ then ["universal","dotnet", $2 ] + when /mswin32(\_(\d+))?/ then ["x86", "mswin32", $2 ] + when /mswin64(\_(\d+))?/ then ["x64", "mswin64", $2 ] + when "powerpc-darwin" then ["powerpc", "darwin", nil ] + when /powerpc-darwin(\d)/ then ["powerpc", "darwin", $1 ] + when /sparc-solaris2.8/ then ["sparc", "solaris", "2.8" ] + when /universal-darwin(\d)/ then ["universal", "darwin", $1 ] else other end @@ -210,11 +210,11 @@ def =~(other) # A pure-Ruby gem that may use Gem::Specification#extensions to build # binary files. - RUBY = 'ruby'.freeze + RUBY = "ruby".freeze ## # A platform-specific gem that is built for the packaging Ruby's platform. # This will be replaced with Gem::Platform::local. - CURRENT = 'current'.freeze + CURRENT = "current".freeze end diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb index 6f399a289efc..b90f9f7d1db0 100644 --- a/lib/rubygems/psych_tree.rb +++ b/lib/rubygems/psych_tree.rb @@ -7,7 +7,7 @@ def self.create end unless respond_to? :create def visit_String(str) - return super unless str == '=' # or whatever you want + return super unless str == "=" # or whatever you want quote = Psych::Nodes::Scalar::SINGLE_QUOTED @emitter.scalar str, nil, nil, false, true, quote diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb index e0c71c43cbef..4601d9374ca9 100644 --- a/lib/rubygems/query_utils.rb +++ b/lib/rubygems/query_utils.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative 'local_remote_options' -require_relative 'spec_fetcher' -require_relative 'version_option' -require_relative 'text' +require_relative "local_remote_options" +require_relative "spec_fetcher" +require_relative "version_option" +require_relative "text" module Gem::QueryUtils @@ -12,41 +12,41 @@ module Gem::QueryUtils include Gem::VersionOption def add_query_options - add_option('-i', '--[no-]installed', - 'Check for installed gem') do |value, options| + add_option("-i", "--[no-]installed", + "Check for installed gem") do |value, options| options[:installed] = value end - add_option('-I', 'Equivalent to --no-installed') do |value, options| + add_option("-I", "Equivalent to --no-installed") do |value, options| options[:installed] = false end add_version_option command, "for use with --installed" - add_option('-d', '--[no-]details', - 'Display detailed information of gem(s)') do |value, options| + add_option("-d", "--[no-]details", + "Display detailed information of gem(s)") do |value, options| options[:details] = value end - add_option('--[no-]versions', - 'Display only gem names') do |value, options| + add_option("--[no-]versions", + "Display only gem names") do |value, options| options[:versions] = value options[:details] = false unless value end - add_option('-a', '--all', - 'Display all gem versions') do |value, options| + add_option("-a", "--all", + "Display all gem versions") do |value, options| options[:all] = value end - add_option('-e', '--exact', - 'Name of gem(s) to query on matches the', - 'provided STRING') do |value, options| + add_option("-e", "--exact", + "Name of gem(s) to query on matches the", + "provided STRING") do |value, options| options[:exact] = value end - add_option('--[no-]prerelease', - 'Display prerelease versions') do |value, options| + add_option("--[no-]prerelease", + "Display prerelease versions") do |value, options| options[:prerelease] = value end @@ -257,7 +257,7 @@ def entry_versions(entry, name_tuples, platforms, specs) if pls != [Gem::Platform::RUBY] platform_list = [pls.delete(Gem::Platform::RUBY), *pls.sort].compact - out = platform_list.unshift(out).join(' ') + out = platform_list.unshift(out).join(" ") end out @@ -284,7 +284,7 @@ def make_entry(entry_tuples, platforms) def spec_authors(entry, spec) authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup - authors << spec.authors.join(', ') + authors << spec.authors.join(", ") entry << format_text(authors, 68, 4) end @@ -298,7 +298,7 @@ def spec_license(entry, spec) return if spec.license.nil? or spec.license.empty? licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup - licenses << spec.licenses.join(', ') + licenses << spec.licenses.join(", ") entry << "\n" << format_text(licenses, 68, 4) end @@ -306,15 +306,15 @@ def spec_loaded_from(entry, spec, specs) return unless spec.loaded_from if specs.length == 1 - default = spec.default_gem? ? ' (default)' : nil + default = spec.default_gem? ? " (default)" : nil entry << "\n" << " Installed at#{default}: #{spec.base_dir}" else - label = 'Installed at' + label = "Installed at" specs.each do |s| version = s.version.to_s - version << ', default' if s.default_gem? + version << ", default" if s.default_gem? entry << "\n" << " #{label} (#{version}): #{s.base_dir}" - label = ' ' * label.length + label = " " * label.length end end end @@ -327,7 +327,7 @@ def spec_platforms(entry, platforms) return unless non_ruby if platforms.length == 1 - title = platforms.values.length == 1 ? 'Platform' : 'Platforms' + title = platforms.values.length == 1 ? "Platform" : "Platforms" entry << " #{title}: #{platforms.values.sort.join(', ')}\n" else entry << " Platforms:\n" @@ -336,7 +336,7 @@ def spec_platforms(entry, platforms) sorted_platforms.each do |version, pls| label = " #{version}: " - data = format_text pls.sort.join(', '), 68, label.length + data = format_text pls.sort.join(", "), 68, label.length data[0, label.length] = label entry << data << "\n" end diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb index ac5e8f082200..769ec61d1eec 100644 --- a/lib/rubygems/rdoc.rb +++ b/lib/rubygems/rdoc.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative '../rubygems' +require_relative "../rubygems" begin - require 'rdoc/rubygems_hook' + require "rdoc/rubygems_hook" module Gem RDoc = ::RDoc::RubygemsHook end diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index b8f9f90cee3d..d0287398614c 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative '../rubygems' -require_relative 'request' -require_relative 'request/connection_pools' -require_relative 's3_uri_signer' -require_relative 'uri_formatter' -require_relative 'uri' -require_relative 'user_interaction' +require_relative "../rubygems" +require_relative "request" +require_relative "request/connection_pools" +require_relative "s3_uri_signer" +require_relative "uri_formatter" +require_relative "uri" +require_relative "user_interaction" ## # RemoteFetcher handles the details of fetching gems and gem information from @@ -72,10 +72,10 @@ def self.fetcher # fetching the gem. def initialize(proxy=nil, dns=nil, headers={}) - require_relative 'core_ext/tcpsocket_init' if Gem.configuration.ipv4_fallback_enabled - require 'net/http' - require 'stringio' - require 'uri' + require_relative "core_ext/tcpsocket_init" if Gem.configuration.ipv4_fallback_enabled + require "net/http" + require "stringio" + require "uri" Socket.do_not_reverse_lookup = true @@ -136,7 +136,7 @@ def download(spec, source_uri, install_dir = Gem.dir) # REFACTOR: split this up and dispatch on scheme (eg download_http) # REFACTOR: be sure to clean up fake fetcher when you do this... cleaner case scheme - when 'http', 'https', 's3' then + when "http", "https", "s3" then unless File.exist? local_gem_path begin verbose "Downloading gem #{gem_file_name}" @@ -156,12 +156,12 @@ def download(spec, source_uri, install_dir = Gem.dir) self.cache_update_path remote_gem_path, local_gem_path end end - when 'file' then + when "file" then begin path = source_uri.path - path = File.dirname(path) if File.extname(path) == '.gem' + path = File.dirname(path) if File.extname(path) == ".gem" - remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, 'gems', gem_file_name)) + remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, "gems", gem_file_name)) FileUtils.cp(remote_gem_path, local_gem_path) rescue Errno::EACCES @@ -171,7 +171,7 @@ def download(spec, source_uri, install_dir = Gem.dir) verbose "Using local gem #{local_gem_path}" when nil then # TODO test for local overriding cache source_path = if Gem.win_platform? && source_uri.scheme && - !source_uri.path.include?(':') + !source_uri.path.include?(":") "#{source_uri.scheme}:#{source_uri.path}" else source_uri.path @@ -216,9 +216,9 @@ def fetch_http(uri, last_modified = nil, head = false, depth = 0) head ? response : response.body when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther, Net::HTTPTemporaryRedirect then - raise FetchError.new('too many redirects', uri) if depth > 10 + raise FetchError.new("too many redirects", uri) if depth > 10 - unless location = response['Location'] + unless location = response["Location"] raise FetchError.new("redirecting but no redirect location was given", uri) end location = Gem::Uri.new location @@ -312,7 +312,7 @@ def request(uri, request_class, last_modified = nil) end def https?(uri) - uri.scheme.downcase == 'https' + uri.scheme.downcase == "https" end def close_all diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index 6d6c2d8de8e8..d15ba91209fb 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'net/http' -require_relative 'user_interaction' +require "net/http" +require_relative "user_interaction" class Gem::Request extend Gem::UserInteraction @@ -44,7 +44,7 @@ def self.get_cert_files end def self.configure_connection_for_https(connection, cert_files) - raise Gem::Exception.new('OpenSSL is not available. Install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources') unless Gem::HAVE_OPENSSL + raise Gem::Exception.new("OpenSSL is not available. Install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources") unless Gem::HAVE_OPENSSL connection.use_ssl = true connection.verify_mode = @@ -96,10 +96,10 @@ def self.verify_certificate_message(error_number, cert) return unless cert case error_number when OpenSSL::X509::V_ERR_CERT_HAS_EXPIRED then - require 'time' + require "time" "Certificate #{cert.subject} expired at #{cert.not_after.iso8601}" when OpenSSL::X509::V_ERR_CERT_NOT_YET_VALID then - require 'time' + require "time" "Certificate #{cert.subject} not valid until #{cert.not_before.iso8601}" when OpenSSL::X509::V_ERR_CERT_REJECTED then "Certificate #{cert.subject} is rejected" @@ -140,13 +140,13 @@ def fetch Gem::UriFormatter.new(@uri.password).unescape end - request.add_field 'User-Agent', @user_agent - request.add_field 'Connection', 'keep-alive' - request.add_field 'Keep-Alive', '30' + request.add_field "User-Agent", @user_agent + request.add_field "Connection", "keep-alive" + request.add_field "Keep-Alive", "30" if @last_modified - require 'time' - request.add_field 'If-Modified-Since', @last_modified.httpdate + require "time" + request.add_field "If-Modified-Since", @last_modified.httpdate end yield request if block_given? @@ -158,7 +158,7 @@ def fetch # Returns a proxy URI for the given +scheme+ if one is set in the # environment variables. - def self.get_proxy_from_env(scheme = 'http') + def self.get_proxy_from_env(scheme = "http") _scheme = scheme.downcase _SCHEME = scheme.upcase env_proxy = ENV["#{_scheme}_proxy"] || ENV["#{_SCHEME}_PROXY"] @@ -166,8 +166,8 @@ def self.get_proxy_from_env(scheme = 'http') no_env_proxy = env_proxy.nil? || env_proxy.empty? if no_env_proxy - return (_scheme == 'https' || _scheme == 'http') ? - :no_proxy : get_proxy_from_env('http') + return (_scheme == "https" || _scheme == "http") ? + :no_proxy : get_proxy_from_env("http") end require "uri" @@ -229,14 +229,14 @@ def perform_request(request) # :nodoc: reset connection - raise Gem::RemoteFetcher::FetchError.new('too many bad responses', @uri) if bad_response + raise Gem::RemoteFetcher::FetchError.new("too many bad responses", @uri) if bad_response bad_response = true retry rescue Net::HTTPFatalError verbose "fatal error" - raise Gem::RemoteFetcher::FetchError.new('fatal error', @uri) + raise Gem::RemoteFetcher::FetchError.new("fatal error", @uri) # HACK work around EOFError bug in Net::HTTP # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible # to install gems. @@ -246,7 +246,7 @@ def perform_request(request) # :nodoc: requests = @requests[connection.object_id] verbose "connection reset after #{requests} requests, retrying" - raise Gem::RemoteFetcher::FetchError.new('too many connection resets', @uri) if retried + raise Gem::RemoteFetcher::FetchError.new("too many connection resets", @uri) if retried reset connection @@ -273,7 +273,7 @@ def user_agent ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}".dup ruby_version = RUBY_VERSION - ruby_version += 'dev' if RUBY_PATCHLEVEL == -1 + ruby_version += "dev" if RUBY_PATCHLEVEL == -1 ua << " Ruby/#{ruby_version} (#{RUBY_RELEASE_DATE}" if RUBY_PATCHLEVEL >= 0 @@ -283,12 +283,12 @@ def user_agent end ua << ")" - ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != 'ruby' + ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != "ruby" ua end end -require_relative 'request/http_pool' -require_relative 'request/https_pool' -require_relative 'request/connection_pools' +require_relative "request/http_pool" +require_relative "request/https_pool" +require_relative "request/connection_pools" diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb index a4c2929b382a..a283267674ac 100644 --- a/lib/rubygems/request/connection_pools.rb +++ b/lib/rubygems/request/connection_pools.rb @@ -37,7 +37,7 @@ def close_all # Returns list of no_proxy entries (if any) from the environment def get_no_proxy_from_env - env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY'] + env_no_proxy = ENV["no_proxy"] || ENV["NO_PROXY"] return [] if env_no_proxy.nil? or env_no_proxy.empty? @@ -45,7 +45,7 @@ def get_no_proxy_from_env end def https?(uri) - uri.scheme.downcase == 'https' + uri.scheme.downcase == "https" end def no_proxy?(host, env_no_proxy) diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index 01b01599a8f2..df215e4af38a 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'tsort' +require_relative "tsort" ## # A RequestSet groups a request to activate a set of dependencies. @@ -254,7 +254,7 @@ def install_from_gemdeps(options, &block) end def install_into(dir, force = true, options = {}) - gem_home, ENV['GEM_HOME'] = ENV['GEM_HOME'], dir + gem_home, ENV["GEM_HOME"] = ENV["GEM_HOME"], dir existing = force ? [] : specs_in(dir) existing.delete_if {|s| @always_install.include? s } @@ -287,7 +287,7 @@ def install_into(dir, force = true, options = {}) installed ensure - ENV['GEM_HOME'] = gem_home + ENV["GEM_HOME"] = gem_home end ## @@ -337,32 +337,32 @@ def load_gemdeps(path, without_groups = [], installing = false) end def pretty_print(q) # :nodoc: - q.group 2, '[RequestSet:', ']' do + q.group 2, "[RequestSet:", "]" do q.breakable if @remote - q.text 'remote' + q.text "remote" q.breakable end if @prerelease - q.text 'prerelease' + q.text "prerelease" q.breakable end if @development_shallow - q.text 'shallow development' + q.text "shallow development" q.breakable elsif @development - q.text 'development' + q.text "development" q.breakable end if @soft_missing - q.text 'soft missing' + q.text "soft missing" end - q.group 2, '[dependencies:', ']' do + q.group 2, "[dependencies:", "]" do q.breakable @dependencies.map do |dep| q.text dep.to_s @@ -371,7 +371,7 @@ def pretty_print(q) # :nodoc: end q.breakable - q.text 'sets:' + q.text "sets:" q.breakable q.pp @sets.map {|set| set.class } @@ -461,6 +461,6 @@ def tsort_each_child(node) # :nodoc: end end -require_relative 'request_set/gem_dependency_api' -require_relative 'request_set/lockfile' -require_relative 'request_set/lockfile/tokenizer' +require_relative "request_set/gem_dependency_api" +require_relative "request_set/lockfile" +require_relative "request_set/lockfile/tokenizer" diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb index 7188b07346f0..568d9f952ff8 100644 --- a/lib/rubygems/request_set/gem_dependency_api.rb +++ b/lib/rubygems/request_set/gem_dependency_api.rb @@ -50,10 +50,10 @@ class Gem::RequestSet::GemDependencyAPI :ruby_21 => %w[ruby rbx maglev truffleruby], }.freeze - mswin = Gem::Platform.new 'x86-mswin32' - mswin64 = Gem::Platform.new 'x64-mswin64' - x86_mingw = Gem::Platform.new 'x86-mingw32' - x64_mingw = Gem::Platform.new 'x64-mingw32' + mswin = Gem::Platform.new "x86-mswin32" + mswin64 = Gem::Platform.new "x64-mswin64" + x86_mingw = Gem::Platform.new "x86-mingw32" + x64_mingw = Gem::Platform.new "x64-mingw32" PLATFORM_MAP = { # :nodoc: :jruby => Gem::Platform::RUBY, @@ -91,11 +91,11 @@ class Gem::RequestSet::GemDependencyAPI :x64_mingw_21 => x64_mingw, }.freeze - gt_eq_0 = Gem::Requirement.new '>= 0' - tilde_gt_1_8_0 = Gem::Requirement.new '~> 1.8.0' - tilde_gt_1_9_0 = Gem::Requirement.new '~> 1.9.0' - tilde_gt_2_0_0 = Gem::Requirement.new '~> 2.0.0' - tilde_gt_2_1_0 = Gem::Requirement.new '~> 2.1.0' + gt_eq_0 = Gem::Requirement.new ">= 0" + tilde_gt_1_8_0 = Gem::Requirement.new "~> 1.8.0" + tilde_gt_1_9_0 = Gem::Requirement.new "~> 1.9.0" + tilde_gt_2_0_0 = Gem::Requirement.new "~> 2.0.0" + tilde_gt_2_1_0 = Gem::Requirement.new "~> 2.1.0" VERSION_MAP = { # :nodoc: :jruby => gt_eq_0, @@ -435,7 +435,7 @@ def gem_git_reference(options) # :nodoc: reference ||= ref reference ||= branch reference ||= tag - reference ||= 'master' + reference ||= "master" if ref && branch warn <<-WARNING @@ -637,8 +637,8 @@ def gem_deps_file # :nodoc: # :development. Only one group may be specified. def gemspec(options = {}) - name = options.delete(:name) || '{,*}' - path = options.delete(:path) || '.' + name = options.delete(:name) || "{,*}" + path = options.delete(:path) || "." development_group = options.delete(:development_group) || :development spec = find_gemspec name, path @@ -697,11 +697,11 @@ def group(*groups) def pin_gem_source(name, type = :default, source = nil) source_description = case type - when :default then '(default)' + when :default then "(default)" when :path then "path: #{source}" when :git then "git: #{source}" when :source then "source: #{source}" - else '(unknown)' + else "(unknown)" end raise ArgumentError, @@ -788,7 +788,7 @@ def ruby(version, options = {}) engine_version = options[:engine_version] raise ArgumentError, - 'You must specify engine_version along with the Ruby engine' if + "You must specify engine_version along with the Ruby engine" if engine and not engine_version return true if @installing diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb index 684d3fc7fe63..3ba202f661ba 100644 --- a/lib/rubygems/request_set/lockfile.rb +++ b/lib/rubygems/request_set/lockfile.rb @@ -76,7 +76,7 @@ def initialize(request_set, gem_deps_file, dependencies) @gem_deps_file = File.expand_path(gem_deps_file) @gem_deps_dir = File.dirname(@gem_deps_file) - if RUBY_VERSION < '2.7' + if RUBY_VERSION < "2.7" @gem_deps_file.untaint unless gem_deps_file.tainted? end @@ -106,7 +106,7 @@ def add_GEM(out, spec_groups) # :nodoc: out << " specs:" requests.sort_by {|request| request.name }.each do |request| - next if request.spec.name == 'bundler' + next if request.spec.name == "bundler" platform = "-#{request.spec.platform}" unless Gem::Platform::RUBY == request.spec.platform @@ -156,7 +156,7 @@ def relative_path_from(dest, base) # :nodoc: if dest.index(base) == 0 offset = dest[base.size + 1..-1] - return '.' unless offset + return "." unless offset offset else @@ -224,7 +224,7 @@ def to_s def write content = to_s - File.open "#{@gem_deps_file}.lock", 'w' do |io| + File.open "#{@gem_deps_file}.lock", "w" do |io| io.write content end end @@ -236,4 +236,4 @@ def requests end end -require_relative 'lockfile/tokenizer' +require_relative "lockfile/tokenizer" diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb index 8c12b435afb0..376d37f9e2d8 100644 --- a/lib/rubygems/request_set/lockfile/parser.rb +++ b/lib/rubygems/request_set/lockfile/parser.rb @@ -19,15 +19,15 @@ def parse @tokens.skip :newline case token.value - when 'DEPENDENCIES' then + when "DEPENDENCIES" then parse_DEPENDENCIES - when 'GIT' then + when "GIT" then parse_GIT - when 'GEM' then + when "GEM" then parse_GEM - when 'PATH' then + when "PATH" then parse_PATH - when 'PLATFORMS' then + when "PLATFORMS" then parse_PLATFORMS else token = get until @tokens.empty? or peek.first == :section @@ -110,8 +110,8 @@ def parse_DEPENDENCIES # :nodoc: def parse_GEM # :nodoc: sources = [] - while [:entry, 'remote'] == peek.first(2) do - get :entry, 'remote' + while [:entry, "remote"] == peek.first(2) do + get :entry, "remote" data = get(:text).value skip :newline @@ -120,7 +120,7 @@ def parse_GEM # :nodoc: sources << Gem::Source.new(Gem::DEFAULT_HOST) if sources.empty? - get :entry, 'specs' + get :entry, "specs" skip :newline @@ -145,7 +145,7 @@ def parse_GEM # :nodoc: data = token.value if type == :text and column == 4 - version, platform = data.split '-', 2 + version, platform = data.split "-", 2 platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY @@ -171,12 +171,12 @@ def parse_GEM # :nodoc: end def parse_GIT # :nodoc: - get :entry, 'remote' + get :entry, "remote" repository = get(:text).value skip :newline - get :entry, 'revision' + get :entry, "revision" revision = get(:text).value skip :newline @@ -190,7 +190,7 @@ def parse_GIT # :nodoc: skip :newline end - get :entry, 'specs' + get :entry, "specs" skip :newline @@ -234,12 +234,12 @@ def parse_GIT # :nodoc: end def parse_PATH # :nodoc: - get :entry, 'remote' + get :entry, "remote" directory = get(:text).value skip :newline - get :entry, 'specs' + get :entry, "specs" skip :newline diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb index cb8030c143d7..79c573a02d9f 100644 --- a/lib/rubygems/request_set/lockfile/tokenizer.rb +++ b/lib/rubygems/request_set/lockfile/tokenizer.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'parser' +require_relative "parser" class Gem::RequestSet::Lockfile::Tokenizer Token = Struct.new :type, :value, :column, :line @@ -57,7 +57,7 @@ def peek private def tokenize(input) - require 'strscan' + require "strscan" s = StringScanner.new input until s.eos? do diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb index 9edd6aa7d3cd..12bf371f4ed1 100644 --- a/lib/rubygems/requirement.rb +++ b/lib/rubygems/requirement.rb @@ -61,7 +61,7 @@ def self.create(*inputs) input when Gem::Version, Array then new input - when '!' then + when "!" then source_set else if input.respond_to? :to_str @@ -73,11 +73,11 @@ def self.create(*inputs) end def self.default - new '>= 0' + new ">= 0" end def self.default_prerelease - new '>= 0.a' + new ">= 0.a" end ### @@ -218,7 +218,7 @@ def to_yaml_properties # :nodoc: end def encode_with(coder) # :nodoc: - coder.add 'requirements', @requirements + coder.add "requirements", @requirements end ## @@ -230,7 +230,7 @@ def prerelease? end def pretty_print(q) # :nodoc: - q.group 1, 'Gem::Requirement.new(', ')' do + q.group 1, "Gem::Requirement.new(", ")" do q.pp as_list end end diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index 51a11fed4747..097e8243eedb 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'dependency' -require_relative 'exceptions' -require_relative 'util/list' +require_relative "dependency" +require_relative "exceptions" +require_relative "util/list" ## # Given a set of Gem::Dependency objects as +needed+ and a way to query the @@ -10,14 +10,14 @@ # all the requirements. class Gem::Resolver - require_relative 'resolver/molinillo' + require_relative "resolver/molinillo" ## # If the DEBUG_RESOLVER environment variable is set then debugging mode is # enabled for the resolver. This will display information about the state # of the resolver while a set of dependencies is being resolved. - DEBUG_RESOLVER = !ENV['DEBUG_RESOLVER'].nil? + DEBUG_RESOLVER = !ENV["DEBUG_RESOLVER"].nil? ## # Set to true if all development dependencies should be considered. @@ -74,7 +74,7 @@ def self.compose_sets(*sets) case sets.length when 0 then - raise ArgumentError, 'one set in the composition must be non-nil' + raise ArgumentError, "one set in the composition must be non-nil" when 1 then sets.first else @@ -124,7 +124,7 @@ def explain_list(stage) # :nodoc: data = yield $stderr.printf "%10s (%d entries)\n", stage.to_s.upcase, data.size unless data.empty? - require 'pp' + require "pp" PP.pp data, $stderr end end @@ -173,7 +173,7 @@ def requests(s, act, reqs=[]) # :nodoc: include Molinillo::UI def output - @output ||= debug? ? $stdout : File.open(IO::NULL, 'w') + @output ||= debug? ? $stdout : File.open(IO::NULL, "w") end def debug? @@ -318,30 +318,30 @@ def amount_constrained(dependency) private :amount_constrained end -require_relative 'resolver/activation_request' -require_relative 'resolver/conflict' -require_relative 'resolver/dependency_request' -require_relative 'resolver/requirement_list' -require_relative 'resolver/stats' - -require_relative 'resolver/set' -require_relative 'resolver/api_set' -require_relative 'resolver/composed_set' -require_relative 'resolver/best_set' -require_relative 'resolver/current_set' -require_relative 'resolver/git_set' -require_relative 'resolver/index_set' -require_relative 'resolver/installer_set' -require_relative 'resolver/lock_set' -require_relative 'resolver/vendor_set' -require_relative 'resolver/source_set' - -require_relative 'resolver/specification' -require_relative 'resolver/spec_specification' -require_relative 'resolver/api_specification' -require_relative 'resolver/git_specification' -require_relative 'resolver/index_specification' -require_relative 'resolver/installed_specification' -require_relative 'resolver/local_specification' -require_relative 'resolver/lock_specification' -require_relative 'resolver/vendor_specification' +require_relative "resolver/activation_request" +require_relative "resolver/conflict" +require_relative "resolver/dependency_request" +require_relative "resolver/requirement_list" +require_relative "resolver/stats" + +require_relative "resolver/set" +require_relative "resolver/api_set" +require_relative "resolver/composed_set" +require_relative "resolver/best_set" +require_relative "resolver/current_set" +require_relative "resolver/git_set" +require_relative "resolver/index_set" +require_relative "resolver/installer_set" +require_relative "resolver/lock_set" +require_relative "resolver/vendor_set" +require_relative "resolver/source_set" + +require_relative "resolver/specification" +require_relative "resolver/spec_specification" +require_relative "resolver/api_specification" +require_relative "resolver/git_specification" +require_relative "resolver/index_specification" +require_relative "resolver/installed_specification" +require_relative "resolver/local_specification" +require_relative "resolver/lock_specification" +require_relative "resolver/vendor_specification" diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb index ae35681db970..27877e0f4be8 100644 --- a/lib/rubygems/resolver/activation_request.rb +++ b/lib/rubygems/resolver/activation_request.rb @@ -93,7 +93,7 @@ def full_spec end def inspect # :nodoc: - '#<%s for %p from %s>' % [ + "#<%s for %p from %s>" % [ self.class, @spec, @request ] end @@ -130,12 +130,12 @@ def parent end def pretty_print(q) # :nodoc: - q.group 2, '[Activation request', ']' do + q.group 2, "[Activation request", "]" do q.breakable q.pp @spec q.breakable - q.text ' for ' + q.text " for " q.pp @request end end diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb index 21c9b8920cfd..f2bef54a9cd0 100644 --- a/lib/rubygems/resolver/api_set.rb +++ b/lib/rubygems/resolver/api_set.rb @@ -26,13 +26,13 @@ class Gem::Resolver::APISet < Gem::Resolver::Set # API URL +dep_uri+ which is described at # https://guides.rubygems.org/rubygems-org-api - def initialize(dep_uri = 'https://index.rubygems.org/info/') + def initialize(dep_uri = "https://index.rubygems.org/info/") super() dep_uri = URI dep_uri unless URI === dep_uri @dep_uri = dep_uri - @uri = dep_uri + '..' + @uri = dep_uri + ".." @data = Hash.new {|h,k| h[k] = [] } @source = Gem::Source.new @uri @@ -83,12 +83,12 @@ def prefetch_now # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[APISet', ']' do + q.group 2, "[APISet", "]" do q.breakable q.text "URI: #{@dep_uri}" q.breakable - q.text 'gem names:' + q.text "gem names:" q.pp @data.keys end end diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb index b5aa0b71d48c..7af4d9cff369 100644 --- a/lib/rubygems/resolver/api_specification.rb +++ b/lib/rubygems/resolver/api_specification.rb @@ -62,7 +62,7 @@ def installable_platform? # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[APISpecification', ']' do + q.group 2, "[APISpecification", "]" do q.breakable q.text "name: #{name}" @@ -73,7 +73,7 @@ def pretty_print(q) # :nodoc: q.text "platform: #{platform}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp @dependencies diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb index 300ea8015cea..ab91ebca087e 100644 --- a/lib/rubygems/resolver/best_set.rb +++ b/lib/rubygems/resolver/best_set.rb @@ -41,9 +41,9 @@ def prefetch(reqs) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[BestSet', ']' do + q.group 2, "[BestSet", "]" do q.breakable - q.text 'sets:' + q.text "sets:" q.breakable q.pp @sets diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb index 4c4588d7e8b7..54a7ca4641a2 100644 --- a/lib/rubygems/resolver/conflict.rb +++ b/lib/rubygems/resolver/conflict.rb @@ -65,7 +65,7 @@ def explanation matching = matching % [ dependency, - alternates.join(', '), + alternates.join(", "), ] end @@ -97,21 +97,21 @@ def for_spec?(spec) end def pretty_print(q) # :nodoc: - q.group 2, '[Dependency conflict: ', ']' do + q.group 2, "[Dependency conflict: ", "]" do q.breakable - q.text 'activated ' + q.text "activated " q.pp @activated q.breakable - q.text ' dependency ' + q.text " dependency " q.pp @dependency q.breakable if @dependency == @failed_dep - q.text ' failed' + q.text " failed" else - q.text ' failed dependency ' + q.text " failed dependency " q.pp @failed_dep end end @@ -139,7 +139,7 @@ def request_path(current) end end - path = ['user request (gem command or Gemfile)'] if path.empty? + path = ["user request (gem command or Gemfile)"] if path.empty? path end diff --git a/lib/rubygems/resolver/dependency_request.rb b/lib/rubygems/resolver/dependency_request.rb index 356aadb3b2f2..70a61cbc25bc 100644 --- a/lib/rubygems/resolver/dependency_request.rb +++ b/lib/rubygems/resolver/dependency_request.rb @@ -95,12 +95,12 @@ def request_context end def pretty_print(q) # :nodoc: - q.group 2, '[Dependency request ', ']' do + q.group 2, "[Dependency request ", "]" do q.breakable q.text @dependency.to_s q.breakable - q.text ' requested by ' + q.text " requested by " q.pp @requester end end diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb index eac51f15ad79..f010273a8ff6 100644 --- a/lib/rubygems/resolver/git_set.rb +++ b/lib/rubygems/resolver/git_set.rb @@ -35,7 +35,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set def initialize # :nodoc: super() - @git = ENV['git'] || 'git' + @git = ENV["git"] || "git" @need_submodules = {} @repositories = {} @root_dir = Gem.dir @@ -104,7 +104,7 @@ def prefetch(reqs) end def pretty_print(q) # :nodoc: - q.group 2, '[GitSet', ']' do + q.group 2, "[GitSet", "]" do next if @repositories.empty? q.breakable diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb index ee47080ab465..d1e04737da02 100644 --- a/lib/rubygems/resolver/git_specification.rb +++ b/lib/rubygems/resolver/git_specification.rb @@ -21,7 +21,7 @@ def add_dependency(dependency) # :nodoc: # the executables. def install(options = {}) - require_relative '../installer' + require_relative "../installer" installer = Gem::Installer.for_spec spec, options @@ -35,7 +35,7 @@ def install(options = {}) end def pretty_print(q) # :nodoc: - q.group 2, '[GitSpecification', ']' do + q.group 2, "[GitSpecification", "]" do q.breakable q.text "name: #{name}" @@ -43,7 +43,7 @@ def pretty_print(q) # :nodoc: q.text "version: #{version}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp dependencies diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb index 9390e3425529..2344178314b1 100644 --- a/lib/rubygems/resolver/index_set.rb +++ b/lib/rubygems/resolver/index_set.rb @@ -53,14 +53,14 @@ def find_all(req) end def pretty_print(q) # :nodoc: - q.group 2, '[IndexSet', ']' do + q.group 2, "[IndexSet", "]" do q.breakable - q.text 'sources:' + q.text "sources:" q.breakable q.pp @f.sources q.breakable - q.text 'specs:' + q.text "specs:" q.breakable diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb index 9ea76f40bae7..e8c3b35f7e63 100644 --- a/lib/rubygems/resolver/index_specification.rb +++ b/lib/rubygems/resolver/index_specification.rb @@ -66,11 +66,11 @@ def hash end def inspect # :nodoc: - '#<%s %s source %s>' % [self.class, full_name, @source] + "#<%s %s source %s>" % [self.class, full_name, @source] end def pretty_print(q) # :nodoc: - q.group 2, '[Index specification', ']' do + q.group 2, "[Index specification", "]" do q.breakable q.text full_name @@ -80,7 +80,7 @@ def pretty_print(q) # :nodoc: end q.breakable - q.text 'source ' + q.text "source " q.pp @source end end diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb index 167ba1439ebd..7c7ad8d85b9b 100644 --- a/lib/rubygems/resolver/installed_specification.rb +++ b/lib/rubygems/resolver/installed_specification.rb @@ -30,7 +30,7 @@ def installable_platform? end def pretty_print(q) # :nodoc: - q.group 2, '[InstalledSpecification', ']' do + q.group 2, "[InstalledSpecification", "]" do q.breakable q.text "name: #{name}" @@ -41,7 +41,7 @@ def pretty_print(q) # :nodoc: q.text "platform: #{platform}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp spec.dependencies end diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index 45252ed24124..15580d7095e2 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -190,7 +190,7 @@ def prerelease=(allow_prerelease) def inspect # :nodoc: always_install = @always_install.map {|s| s.full_name } - '#<%s domain: %s specs: %p always install: %p>' % [ + "#<%s domain: %s specs: %p always install: %p>" % [ self.class, @domain, @specs.keys, always_install ] end @@ -219,16 +219,16 @@ def local?(dep_name) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[InstallerSet', ']' do + q.group 2, "[InstallerSet", "]" do q.breakable q.text "domain: #{@domain}" q.breakable - q.text 'specs: ' + q.text "specs: " q.pp @specs.keys q.breakable - q.text 'always install: ' + q.text "always install: " q.pp @always_install end end diff --git a/lib/rubygems/resolver/local_specification.rb b/lib/rubygems/resolver/local_specification.rb index 9c69c4ab74cb..c27bab0f5a5c 100644 --- a/lib/rubygems/resolver/local_specification.rb +++ b/lib/rubygems/resolver/local_specification.rb @@ -17,7 +17,7 @@ def local? # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[LocalSpecification', ']' do + q.group 2, "[LocalSpecification", "]" do q.breakable q.text "name: #{name}" @@ -28,7 +28,7 @@ def pretty_print(q) # :nodoc: q.text "platform: #{platform}" q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp dependencies diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb index eabf217abace..ff6c6c912f99 100644 --- a/lib/rubygems/resolver/lock_set.rb +++ b/lib/rubygems/resolver/lock_set.rb @@ -63,15 +63,15 @@ def load_spec(name, version, platform, source) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[LockSet', ']' do + q.group 2, "[LockSet", "]" do q.breakable - q.text 'source:' + q.text "source:" q.breakable q.pp @source q.breakable - q.text 'specs:' + q.text "specs:" q.breakable q.pp @specs.map {|spec| spec.full_name } diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb index cdb8e4e4258b..4a30dcf84902 100644 --- a/lib/rubygems/resolver/lock_specification.rb +++ b/lib/rubygems/resolver/lock_specification.rb @@ -29,7 +29,7 @@ def initialize(set, name, version, sources, platform) def install(options = {}) destination = options[:install_dir] || Gem.dir - if File.exist? File.join(destination, 'specifications', spec.spec_name) + if File.exist? File.join(destination, "specifications", spec.spec_name) yield nil return end @@ -45,7 +45,7 @@ def add_dependency(dependency) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[LockSpecification', ']' do + q.group 2, "[LockSpecification", "]" do q.breakable q.text "name: #{@name}" @@ -59,7 +59,7 @@ def pretty_print(q) # :nodoc: unless @dependencies.empty? q.breakable - q.text 'dependencies:' + q.text "dependencies:" q.breakable q.pp @dependencies end diff --git a/lib/rubygems/resolver/molinillo.rb b/lib/rubygems/resolver/molinillo.rb index 12ca740e5acb..e1543425711e 100644 --- a/lib/rubygems/resolver/molinillo.rb +++ b/lib/rubygems/resolver/molinillo.rb @@ -1,2 +1,2 @@ # frozen_string_literal: true -require_relative 'molinillo/lib/molinillo' +require_relative "molinillo/lib/molinillo" diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb index dfcb7eb05721..3da803cab5e7 100644 --- a/lib/rubygems/resolver/specification.rb +++ b/lib/rubygems/resolver/specification.rb @@ -93,7 +93,7 @@ def full_name # specification. def install(options = {}) - require_relative '../installer' + require_relative "../installer" gem = download options diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb index 48c640d8c943..6c0ef2a1a1aa 100644 --- a/lib/rubygems/resolver/vendor_set.rb +++ b/lib/rubygems/resolver/vendor_set.rb @@ -69,7 +69,7 @@ def load_spec(name, version, platform, source) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[VendorSet', ']' do + q.group 2, "[VendorSet", "]" do next if @directories.empty? q.breakable diff --git a/lib/rubygems/s3_uri_signer.rb b/lib/rubygems/s3_uri_signer.rb index 4d1deee9972f..5522753af5e9 100644 --- a/lib/rubygems/s3_uri_signer.rb +++ b/lib/rubygems/s3_uri_signer.rb @@ -1,4 +1,4 @@ -require_relative 'openssl' +require_relative "openssl" ## # S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems @@ -138,14 +138,14 @@ def base64_uri_escape(str) end def ec2_metadata_credentials_json - require 'net/http' - require_relative 'request' - require_relative 'request/connection_pools' - require 'json' + require "net/http" + require_relative "request" + require_relative "request/connection_pools" + require "json" iam_info = ec2_metadata_request(EC2_IAM_INFO) # Expected format: arn:aws:iam:::instance-profile/ - role_name = iam_info['InstanceProfileArn'].split('/').last + role_name = iam_info["InstanceProfileArn"].split("/").last ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name) end diff --git a/lib/rubygems/safe_yaml.rb b/lib/rubygems/safe_yaml.rb index 81f99ee26e76..5a98505598a6 100644 --- a/lib/rubygems/safe_yaml.rb +++ b/lib/rubygems/safe_yaml.rb @@ -26,7 +26,7 @@ module SafeYAML if ::Psych.respond_to? :safe_load def self.safe_load(input) - if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') + if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0.pre1") ::Psych.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true) else ::Psych.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true) @@ -34,7 +34,7 @@ def self.safe_load(input) end def self.load(input) - if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') + if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0.pre1") ::Psych.safe_load(input, permitted_classes: [::Symbol]) else ::Psych.safe_load(input, [::Symbol]) diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb index fc23c1c481e2..4eb402305546 100644 --- a/lib/rubygems/security.rb +++ b/lib/rubygems/security.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'exceptions' -require_relative 'openssl' +require_relative "exceptions" +require_relative "openssl" ## # = Signing gems @@ -334,7 +334,7 @@ class Exception < Gem::Exception; end ## # Used internally to select the signing digest from all computed digests - DIGEST_NAME = 'SHA256' # :nodoc: + DIGEST_NAME = "SHA256" # :nodoc: ## # Length of keys created by RSA and DSA keys @@ -344,18 +344,18 @@ class Exception < Gem::Exception; end ## # Default algorithm to use when building a key pair - DEFAULT_KEY_ALGORITHM = 'RSA' + DEFAULT_KEY_ALGORITHM = "RSA" ## # Named curve used for Elliptic Curve - EC_NAME = 'secp384r1' + EC_NAME = "secp384r1" ## # Cipher used to encrypt the key pair used to sign gems. # Must be in the list returned by OpenSSL::Cipher.ciphers - KEY_CIPHER = OpenSSL::Cipher.new('AES-256-CBC') if defined?(OpenSSL::Cipher) + KEY_CIPHER = OpenSSL::Cipher.new("AES-256-CBC") if defined?(OpenSSL::Cipher) ## # One day in seconds @@ -376,10 +376,10 @@ class Exception < Gem::Exception; end # * The certificate contains a subject key identifier EXTENSIONS = { - 'basicConstraints' => 'CA:FALSE', - 'keyUsage' => - 'keyEncipherment,dataEncipherment,digitalSignature', - 'subjectKeyIdentifier' => 'hash', + "basicConstraints" => "CA:FALSE", + "keyUsage" => + "keyEncipherment,dataEncipherment,digitalSignature", + "subjectKeyIdentifier" => "hash", }.freeze def self.alt_name_or_x509_entry(certificate, x509_entry) @@ -473,7 +473,7 @@ def self.create_digest(algorithm = DIGEST_NAME) OpenSSL::Digest.new(algorithm) end else - require 'digest' + require "digest" def self.create_digest(algorithm = DIGEST_NAME) Digest.const_get(algorithm).new @@ -487,11 +487,11 @@ def self.create_digest(algorithm = DIGEST_NAME) def self.create_key(algorithm) if defined?(OpenSSL::PKey) case algorithm.downcase - when 'dsa' + when "dsa" OpenSSL::PKey::DSA.new(RSA_DSA_KEY_LENGTH) - when 'rsa' + when "rsa" OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH) - when 'ec' + when "ec" if RUBY_VERSION >= "2.4.0" OpenSSL::PKey::EC.generate(EC_NAME) else @@ -510,11 +510,11 @@ def self.create_key(algorithm) # Turns +email_address+ into an OpenSSL::X509::Name def self.email_to_name(email_address) - email_address = email_address.gsub(/[^\w@.-]+/i, '_') + email_address = email_address.gsub(/[^\w@.-]+/i, "_") - cn, dcs = email_address.split '@' + cn, dcs = email_address.split "@" - dcs = dcs.split '.' + dcs = dcs.split "." OpenSSL::X509::Name.new([ ["CN", cn], @@ -571,17 +571,17 @@ def self.sign(certificate, signing_key, signing_cert, signee_key = certificate.public_key alt_name = certificate.extensions.find do |extension| - extension.oid == 'subjectAltName' + extension.oid == "subjectAltName" end - extensions = extensions.merge 'subjectAltName' => alt_name.value if + extensions = extensions.merge "subjectAltName" => alt_name.value if alt_name issuer_alt_name = signing_cert.extensions.find do |extension| - extension.oid == 'subjectAltName' + extension.oid == "subjectAltName" end - extensions = extensions.merge 'issuerAltName' => issuer_alt_name.value if + extensions = extensions.merge "issuerAltName" => issuer_alt_name.value if issuer_alt_name signed = create_cert signee_subject, signee_key, age, extensions, serial @@ -597,7 +597,7 @@ def self.sign(certificate, signing_key, signing_cert, def self.trust_dir return @trust_dir if @trust_dir - dir = File.join Gem.user_home, '.gem', 'trust' + dir = File.join Gem.user_home, ".gem", "trust" @trust_dir ||= Gem::Security::TrustDir.new dir end @@ -617,7 +617,7 @@ def self.trusted_certificates(&block) def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER) path = File.expand_path path - File.open path, 'wb', permissions do |io| + File.open path, "wb", permissions do |io| if passphrase and cipher io.write pemmable.to_pem cipher, passphrase else @@ -633,9 +633,9 @@ def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KE end if Gem::HAVE_OPENSSL - require_relative 'security/policy' - require_relative 'security/policies' - require_relative 'security/trust_dir' + require_relative "security/policy" + require_relative "security/policies" + require_relative "security/trust_dir" end -require_relative 'security/signer' +require_relative "security/signer" diff --git a/lib/rubygems/security/policies.rb b/lib/rubygems/security/policies.rb index 8f6ad9931608..b3f9070394d4 100644 --- a/lib/rubygems/security/policies.rb +++ b/lib/rubygems/security/policies.rb @@ -5,7 +5,7 @@ module Gem::Security # No security policy: all package signature checks are disabled. NoSecurity = Policy.new( - 'No Security', + "No Security", :verify_data => false, :verify_signer => false, :verify_chain => false, @@ -23,7 +23,7 @@ module Gem::Security # easily spoofed, and is not recommended. AlmostNoSecurity = Policy.new( - 'Almost No Security', + "Almost No Security", :verify_data => true, :verify_signer => false, :verify_chain => false, @@ -40,7 +40,7 @@ module Gem::Security # is not recommended. LowSecurity = Policy.new( - 'Low Security', + "Low Security", :verify_data => true, :verify_signer => true, :verify_chain => false, @@ -59,7 +59,7 @@ module Gem::Security # gem off as unsigned. MediumSecurity = Policy.new( - 'Medium Security', + "Medium Security", :verify_data => true, :verify_signer => true, :verify_chain => true, @@ -78,7 +78,7 @@ module Gem::Security # a reasonable guarantee that the contents of the gem have not been altered. HighSecurity = Policy.new( - 'High Security', + "High Security", :verify_data => true, :verify_signer => true, :verify_chain => true, @@ -91,7 +91,7 @@ module Gem::Security # Policy used to verify a certificate and key when signing a gem SigningPolicy = Policy.new( - 'Signing Policy', + "Signing Policy", :verify_data => false, :verify_signer => true, :verify_chain => true, @@ -104,11 +104,11 @@ module Gem::Security # Hash of configured security policies Policies = { - 'NoSecurity' => NoSecurity, - 'AlmostNoSecurity' => AlmostNoSecurity, - 'LowSecurity' => LowSecurity, - 'MediumSecurity' => MediumSecurity, - 'HighSecurity' => HighSecurity, + "NoSecurity" => NoSecurity, + "AlmostNoSecurity" => AlmostNoSecurity, + "LowSecurity" => LowSecurity, + "MediumSecurity" => MediumSecurity, + "HighSecurity" => HighSecurity, # SigningPolicy is not intended for use by `gem -P` so do not list it }.freeze diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb index 06eae073f4ae..43588fd7f10a 100644 --- a/lib/rubygems/security/policy.rb +++ b/lib/rubygems/security/policy.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative '../user_interaction' +require_relative "../user_interaction" ## # A Gem::Security::Policy object encapsulates the settings for verifying @@ -53,8 +53,8 @@ def initialize(name, policy = {}, opt = {}) # and is valid for the given +time+. def check_chain(chain, time) - raise Gem::Security::Exception, 'missing signing chain' unless chain - raise Gem::Security::Exception, 'empty signing chain' if chain.empty? + raise Gem::Security::Exception, "missing signing chain" unless chain + raise Gem::Security::Exception, "empty signing chain" if chain.empty? begin chain.each_cons 2 do |issuer, cert| @@ -83,7 +83,7 @@ def check_data(public_key, digest, signature, data) # If the +issuer+ is +nil+ no verification is performed. def check_cert(signer, issuer, time) - raise Gem::Security::Exception, 'missing signing certificate' unless + raise Gem::Security::Exception, "missing signing certificate" unless signer message = "certificate #{signer.subject}" @@ -112,7 +112,7 @@ def check_key(signer, key) unless signer and key return true unless @only_signed - raise Gem::Security::Exception, 'missing key or signature' + raise Gem::Security::Exception, "missing key or signature" end raise Gem::Security::Exception, @@ -127,11 +127,11 @@ def check_key(signer, key) # +time+. def check_root(chain, time) - raise Gem::Security::Exception, 'missing signing chain' unless chain + raise Gem::Security::Exception, "missing signing chain" unless chain root = chain.first - raise Gem::Security::Exception, 'missing root certificate' unless root + raise Gem::Security::Exception, "missing root certificate" unless root raise Gem::Security::Exception, "root certificate #{root.subject} is not self-signed " + @@ -146,11 +146,11 @@ def check_root(chain, time) # the digests of the two certificates match according to +digester+ def check_trust(chain, digester, trust_dir) - raise Gem::Security::Exception, 'missing signing chain' unless chain + raise Gem::Security::Exception, "missing signing chain" unless chain root = chain.first - raise Gem::Security::Exception, 'missing root certificate' unless root + raise Gem::Security::Exception, "missing root certificate" unless root path = Gem::Security.trust_dir.cert_path root @@ -182,7 +182,7 @@ def check_trust(chain, digester, trust_dir) def subject(certificate) # :nodoc: certificate.extensions.each do |extension| - next unless extension.oid == 'subjectAltName' + next unless extension.oid == "subjectAltName" return extension.value end @@ -206,7 +206,7 @@ def inspect # :nodoc: # If +key+ is given it is used to validate the signing certificate. def verify(chain, key = nil, digests = {}, signatures = {}, - full_name = '(unknown)') + full_name = "(unknown)") if signatures.empty? if @only_signed raise Gem::Security::Exception, @@ -230,7 +230,7 @@ def verify(chain, key = nil, digests = {}, signatures = {}, end if @verify_data - raise Gem::Security::Exception, 'no digests provided (probable bug)' if + raise Gem::Security::Exception, "no digests provided (probable bug)" if signer_digests.nil? or signer_digests.empty? else signer_digests = {} diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb index 968cf889730a..b1308c4e4212 100644 --- a/lib/rubygems/security/signer.rb +++ b/lib/rubygems/security/signer.rb @@ -42,7 +42,7 @@ class Gem::Security::Signer def self.re_sign_cert(expired_cert, expired_cert_path, private_key) return unless expired_cert.not_after < Time.now - expiry = expired_cert.not_after.strftime('%Y%m%d%H%M%S') + expiry = expired_cert.not_after.strftime("%Y%m%d%H%M%S") expired_cert_file = "#{File.basename(expired_cert_path)}.expired.#{expiry}" new_expired_cert_path = File.join(Gem.user_home, ".gem", expired_cert_file) @@ -105,7 +105,7 @@ def initialize(key, cert_chain, passphrase = nil, options = {}) # this value is preferred, otherwise the subject is used. def extract_name(cert) # :nodoc: - subject_alt_name = cert.extensions.find {|e| 'subjectAltName' == e.oid } + subject_alt_name = cert.extensions.find {|e| "subjectAltName" == e.oid } if subject_alt_name /\Aemail:/ =~ subject_alt_name.value # rubocop:disable Performance/StartWith @@ -139,7 +139,7 @@ def load_cert_chain # :nodoc: def sign(data) return unless @key - raise Gem::Security::Exception, 'no certs provided' if @cert_chain.empty? + raise Gem::Security::Exception, "no certs provided" if @cert_chain.empty? if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now alert("Your certificate has expired, trying to re-sign it...") @@ -182,7 +182,7 @@ def re_sign_key(expiration_length: Gem::Security::ONE_YEAR) # :nodoc: return unless disk_key if disk_key.to_pem == @key.to_pem && disk_cert == old_cert.to_pem - expiry = old_cert.not_after.strftime('%Y%m%d%H%M%S') + expiry = old_cert.not_after.strftime("%Y%m%d%H%M%S") old_cert_file = "gem-public_cert.pem.expired.#{expiry}" old_cert_path = File.join(Gem.user_home, ".gem", old_cert_file) diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb index 456947274ca8..a6882c66e7f1 100644 --- a/lib/rubygems/security/trust_dir.rb +++ b/lib/rubygems/security/trust_dir.rb @@ -41,7 +41,7 @@ def cert_path(certificate) def each_certificate return enum_for __method__ unless block_given? - glob = File.join @dir, '*.pem' + glob = File.join @dir, "*.pem" Dir[glob].each do |certificate_file| begin @@ -92,7 +92,7 @@ def trust_cert(certificate) destination = cert_path certificate - File.open destination, 'wb', 0600 do |io| + File.open destination, "wb", 0600 do |io| io.write certificate.to_pem io.chmod(@permissions[:trusted_cert]) end @@ -104,7 +104,7 @@ def trust_cert(certificate) # permissions. def verify - require 'fileutils' + require "fileutils" if File.exist? @dir raise Gem::Security::Exception, "trust directory #{@dir} is not a directory" unless diff --git a/lib/rubygems/security_option.rb b/lib/rubygems/security_option.rb index a4c570ded5cf..ab3898bf11f8 100644 --- a/lib/rubygems/security_option.rb +++ b/lib/rubygems/security_option.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' +require_relative "../rubygems" # forward-declare @@ -20,9 +20,9 @@ class Policy # :nodoc: module Gem::SecurityOption def add_security_option Gem::OptionParser.accept Gem::Security::Policy do |value| - require_relative 'security' + require_relative "security" - raise Gem::OptionParser::InvalidArgument, 'OpenSSL not installed' unless + raise Gem::OptionParser::InvalidArgument, "OpenSSL not installed" unless defined?(Gem::Security::HighSecurity) policy = Gem::Security::Policies[value] @@ -33,9 +33,9 @@ def add_security_option policy end - add_option(:"Install/Update", '-P', '--trust-policy POLICY', + add_option(:"Install/Update", "-P", "--trust-policy POLICY", Gem::Security::Policy, - 'Specify gem trust policy') do |value, options| + "Specify gem trust policy") do |value, options| options[:security_policy] = value end end diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index 5f49a0d21636..7c3b6786458d 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -12,9 +12,9 @@ class Gem::Source include Gem::Text FILES = { # :nodoc: - :released => 'specs', - :latest => 'latest_specs', - :prerelease => 'prerelease_specs', + :released => "specs", + :latest => "latest_specs", + :prerelease => "prerelease_specs", }.freeze ## @@ -71,7 +71,7 @@ def ==(other) # :nodoc: # Returns a Set that can fetch specifications from this source. def dependency_resolver_set # :nodoc: - return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme + return Gem::Resolver::IndexSet.new self if "file" == uri.scheme fetch_uri = if uri.host == "rubygems.org" index_uri = uri.dup @@ -141,7 +141,7 @@ def fetch_spec(name_tuple) return spec if spec end - source_uri.path << '.rz' + source_uri.path << ".rz" spec = fetcher.fetch_path source_uri spec = Gem::Util.inflate spec @@ -150,7 +150,7 @@ def fetch_spec(name_tuple) require "fileutils" FileUtils.mkdir_p cache_dir - File.open local_spec, 'wb' do |io| + File.open local_spec, "wb" do |io| io.write spec end end @@ -209,13 +209,13 @@ def download(spec, dir=Dir.pwd) end def pretty_print(q) # :nodoc: - q.group 2, '[Remote:', ']' do + q.group 2, "[Remote:", "]" do q.breakable q.text @uri.to_s if api = uri q.breakable - q.text 'API URI: ' + q.text "API URI: " q.text api.to_s end end @@ -229,13 +229,13 @@ def typo_squatting?(host, distance_threshold=4) private def enforce_trailing_slash(uri) - uri.merge(uri.path.gsub(/\/+$/, '') + '/') + uri.merge(uri.path.gsub(/\/+$/, "") + "/") end end -require_relative 'source/git' -require_relative 'source/installed' -require_relative 'source/specific_file' -require_relative 'source/local' -require_relative 'source/lock' -require_relative 'source/vendor' +require_relative "source/git" +require_relative "source/installed" +require_relative "source/specific_file" +require_relative "source/local" +require_relative "source/lock" +require_relative "source/vendor" diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb index 1d964eb59aca..22355adcfa90 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -58,7 +58,7 @@ def initialize(name, repository, reference, submodules = false) @remote = true @root_dir = Gem.dir - @git = ENV['git'] || 'git' + @git = ENV["git"] || "git" end def <=>(other) @@ -92,18 +92,18 @@ def checkout # :nodoc: return false unless File.exist? repo_cache_dir unless File.exist? install_dir - system @git, 'clone', '--quiet', '--no-checkout', + system @git, "clone", "--quiet", "--no-checkout", repo_cache_dir, install_dir end Dir.chdir install_dir do - system @git, 'fetch', '--quiet', '--force', '--tags', install_dir + system @git, "fetch", "--quiet", "--force", "--tags", install_dir - success = system @git, 'reset', '--quiet', '--hard', rev_parse + success = system @git, "reset", "--quiet", "--hard", rev_parse if @need_submodules require "open3" - _, status = Open3.capture2e(@git, 'submodule', 'update', '--quiet', '--init', '--recursive') + _, status = Open3.capture2e(@git, "submodule", "update", "--quiet", "--init", "--recursive") success &&= status.success? end @@ -120,11 +120,11 @@ def cache # :nodoc: if File.exist? repo_cache_dir Dir.chdir repo_cache_dir do - system @git, 'fetch', '--quiet', '--force', '--tags', - @repository, 'refs/heads/*:refs/heads/*' + system @git, "fetch", "--quiet", "--force", "--tags", + @repository, "refs/heads/*:refs/heads/*" end else - system @git, 'clone', '--quiet', '--bare', '--no-hardlinks', + system @git, "clone", "--quiet", "--bare", "--no-hardlinks", @repository, repo_cache_dir end end @@ -133,7 +133,7 @@ def cache # :nodoc: # Directory where git gems get unpacked and so-forth. def base_dir # :nodoc: - File.join @root_dir, 'bundler' + File.join @root_dir, "bundler" end ## @@ -155,11 +155,11 @@ def download(full_spec, path) # :nodoc: def install_dir # :nodoc: return unless File.exist? repo_cache_dir - File.join base_dir, 'gems', "#{@name}-#{dir_shortref}" + File.join base_dir, "gems", "#{@name}-#{dir_shortref}" end def pretty_print(q) # :nodoc: - q.group 2, '[Git: ', ']' do + q.group 2, "[Git: ", "]" do q.breakable q.text @repository @@ -172,7 +172,7 @@ def pretty_print(q) # :nodoc: # The directory where the git gem's repository will be cached. def repo_cache_dir # :nodoc: - File.join @root_dir, 'cache', 'bundler', 'git', "#{@name}-#{uri_hash}" + File.join @root_dir, "cache", "bundler", "git", "#{@name}-#{uri_hash}" end ## @@ -182,7 +182,7 @@ def rev_parse # :nodoc: hash = nil Dir.chdir repo_cache_dir do - hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip + hash = Gem::Util.popen(@git, "rev-parse", @reference).strip end raise Gem::Exception, @@ -201,7 +201,7 @@ def specs return [] unless install_dir Dir.chdir install_dir do - Dir['{,*,*/*}.gemspec'].map do |spec_file| + Dir["{,*,*/*}.gemspec"].map do |spec_file| directory = File.dirname spec_file file = File.basename spec_file @@ -211,7 +211,7 @@ def specs spec.base_dir = base_dir spec.extension_dir = - File.join base_dir, 'extensions', Gem::Platform.local.to_s, + File.join base_dir, "extensions", Gem::Platform.local.to_s, Gem.extension_api_version, "#{name}-#{dir_shortref}" spec.full_gem_path = File.dirname spec.loaded_from if spec @@ -226,11 +226,11 @@ def specs # A hash for the git gem based on the git repository URI. def uri_hash # :nodoc: - require_relative '../openssl' + require_relative "../openssl" normalized = if @repository =~ %r{^\w+://(\w+@)?} - uri = URI(@repository).normalize.to_s.sub %r{/$},'' + uri = URI(@repository).normalize.to_s.sub %r{/$},"" uri.sub(/\A(\w+)/) { $1.downcase } else @repository diff --git a/lib/rubygems/source/installed.rb b/lib/rubygems/source/installed.rb index 7e1dd7af5a4d..786faab3e309 100644 --- a/lib/rubygems/source/installed.rb +++ b/lib/rubygems/source/installed.rb @@ -33,6 +33,6 @@ def download(spec, path) end def pretty_print(q) # :nodoc: - q.text '[Installed]' + q.text "[Installed]" end end diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb index 078b06203fb6..ec1a594238a2 100644 --- a/lib/rubygems/source/local.rb +++ b/lib/rubygems/source/local.rb @@ -29,7 +29,7 @@ def <=>(other) end def inspect # :nodoc: - keys = @specs ? @specs.keys.sort : 'NOT LOADED' + keys = @specs ? @specs.keys.sort : "NOT LOADED" "#<%s specs: %p>" % [self.class, keys] end @@ -121,7 +121,7 @@ def download(spec, cache_dir = nil) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[Local gems:', ']' do + q.group 2, "[Local gems:", "]" do q.breakable q.seplist @specs.keys do |v| q.text v.full_name diff --git a/lib/rubygems/source/specific_file.rb b/lib/rubygems/source/specific_file.rb index 24db1440dd7f..552aeba50f5c 100644 --- a/lib/rubygems/source/specific_file.rb +++ b/lib/rubygems/source/specific_file.rb @@ -42,7 +42,7 @@ def download(spec, dir = nil) # :nodoc: end def pretty_print(q) # :nodoc: - q.group 2, '[SpecificFile:', ']' do + q.group 2, "[SpecificFile:", "]" do q.breakable q.text @path end diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb index 4033e2efa325..43e7e05b63d6 100644 --- a/lib/rubygems/spec_fetcher.rb +++ b/lib/rubygems/spec_fetcher.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative 'remote_fetcher' -require_relative 'user_interaction' -require_relative 'errors' -require_relative 'text' -require_relative 'name_tuple' +require_relative "remote_fetcher" +require_relative "user_interaction" +require_relative "errors" +require_relative "text" +require_relative "name_tuple" ## # SpecFetcher handles metadata updates from remote gem repositories. @@ -171,19 +171,19 @@ def spec_for_dependency(dependency, matching_platform=true) # alternative gem names. def suggest_gems_from_name(gem_name, type = :latest, num_results = 5) - gem_name = gem_name.downcase.tr('_-', '') + gem_name = gem_name.downcase.tr("_-", "") max = gem_name.size / 2 names = available_specs(type).first.values.flatten(1) matches = names.map do |n| next unless n.match_platform? - [n.name, 0] if n.name.downcase.tr('_-', '').include?(gem_name) + [n.name, 0] if n.name.downcase.tr("_-", "").include?(gem_name) end.compact if matches.length < num_results matches += names.map do |n| next unless n.match_platform? - distance = levenshtein_distance gem_name, n.name.downcase.tr('_-', '') + distance = levenshtein_distance gem_name, n.name.downcase.tr("_-", "") next if distance >= max return [n.name] if distance == 0 [n.name, distance] diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index a8e52e58d5f8..f2e274002641 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -6,11 +6,11 @@ # See LICENSE.txt for permissions. #++ -require_relative 'deprecate' -require_relative 'basic_specification' -require_relative 'stub_specification' -require_relative 'platform' -require_relative 'util/list' +require_relative "deprecate" +require_relative "basic_specification" +require_relative "stub_specification" +require_relative "platform" +require_relative "util/list" ## # The Specification class contains the information for a gem. Typically @@ -74,20 +74,20 @@ class Gem::Specification < Gem::BasicSpecification # key should be equal to the CURRENT_SPECIFICATION_VERSION. SPECIFICATION_VERSION_HISTORY = { # :nodoc: - -1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'], + -1 => ["(RubyGems versions up to and including 0.7 did not have versioned specifications)"], 1 => [ 'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"', '"test_file=x" is a shortcut for "test_files=[x]"', ], 2 => [ 'Added "required_rubygems_version"', - 'Now forward-compatible with future versions', + "Now forward-compatible with future versions", ], 3 => [ - 'Added Fixnum validation to the specification_version', + "Added Fixnum validation to the specification_version", ], 4 => [ - 'Added sandboxed freeform metadata to the specification version.', + "Added sandboxed freeform metadata to the specification version.", ], }.freeze @@ -126,7 +126,7 @@ class Gem::Specification < Gem::BasicSpecification @@default_value = { :authors => [], :autorequire => nil, - :bindir => 'bin', + :bindir => "bin", :cert_chain => [], :date => nil, :dependencies => [], @@ -143,7 +143,7 @@ class Gem::Specification < Gem::BasicSpecification :platform => Gem::Platform::RUBY, :post_install_message => nil, :rdoc_options => [], - :require_paths => ['lib'], + :require_paths => ["lib"], :required_ruby_version => Gem::Requirement.default, :required_rubygems_version => Gem::Requirement.default, :requirements => [], @@ -489,12 +489,12 @@ def platform=(platform) # legacy constants when nil, Gem::Platform::RUBY then @new_platform = Gem::Platform::RUBY - when 'mswin32' then # was Gem::Platform::WIN32 - @new_platform = Gem::Platform.new 'x86-mswin32' - when 'i586-linux' then # was Gem::Platform::LINUX_586 - @new_platform = Gem::Platform.new 'x86-linux' - when 'powerpc-darwin' then # was Gem::Platform::DARWIN - @new_platform = Gem::Platform.new 'ppc-darwin' + when "mswin32" then # was Gem::Platform::WIN32 + @new_platform = Gem::Platform.new "x86-mswin32" + when "i586-linux" then # was Gem::Platform::LINUX_586 + @new_platform = Gem::Platform.new "x86-linux" + when "powerpc-darwin" then # was Gem::Platform::DARWIN + @new_platform = Gem::Platform.new "ppc-darwin" else @new_platform = Gem::Platform.new platform end @@ -1149,7 +1149,7 @@ def self.load(file) file = file.dup.tap(&Gem::UNTAINT) return unless File.file?(file) - code = Gem.open_file(file, 'r:UTF-8:-', &:read) + code = Gem.open_file(file, "r:UTF-8:-", &:read) code.tap(&Gem::UNTAINT) @@ -1390,7 +1390,7 @@ def _dump(limit) @required_rubygems_version, @original_platform, @dependencies, - '', # rubyforge_project + "", # rubyforge_project @email, @authors, @description, @@ -1608,7 +1608,7 @@ def build_extensions # :nodoc: return if default_gem? return if File.exist? gem_build_complete_path return if !File.writable?(base_dir) - return if !File.exist?(File.join(base_dir, 'extensions')) + return if !File.exist?(File.join(base_dir, "extensions")) begin # We need to require things in $LOAD_PATH without looking for the @@ -1616,9 +1616,9 @@ def build_extensions # :nodoc: unresolved_deps = Gem::Specification.unresolved_deps.dup Gem::Specification.unresolved_deps.clear - require_relative 'config_file' - require_relative 'ext' - require_relative 'user_interaction' + require_relative "config_file" + require_relative "ext" + require_relative "user_interaction" ui = Gem::SilentUI.new Gem::DefaultUserInteraction.use_ui ui do @@ -1837,7 +1837,7 @@ def development_dependencies # spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri" def doc_dir(type = nil) - @doc_dir ||= File.join base_dir, 'doc', full_name + @doc_dir ||= File.join base_dir, "doc", full_name if type File.join @doc_dir, type @@ -1849,17 +1849,17 @@ def doc_dir(type = nil) def encode_with(coder) # :nodoc: mark_version - coder.add 'name', @name - coder.add 'version', @version + coder.add "name", @name + coder.add "version", @version platform = case @original_platform - when nil, '' then - 'ruby' + when nil, "" then + "ruby" when String then @original_platform else @original_platform.to_s end - coder.add 'platform', platform + coder.add "platform", platform attributes = @@attributes.map(&:to_s) - %w[name version platform] attributes.each do |name| @@ -2229,7 +2229,7 @@ def platform end def pretty_print(q) # :nodoc: - q.group 2, 'Gem::Specification.new do |s|', 'end' do + q.group 2, "Gem::Specification.new do |s|", "end" do q.breakable attributes = @@attributes - [:name, :version] @@ -2324,7 +2324,7 @@ def respond_to_missing?(m, include_private = false) # :nodoc: # Returns the full path to this spec's ri directory. def ri_dir - @ri_dir ||= File.join base_dir, 'ri', full_name + @ri_dir ||= File.join base_dir, "ri", full_name end ## @@ -2334,13 +2334,13 @@ def ri_dir def ruby_code(obj) case obj when String then obj.dump + ".freeze" - when Array then '[' + obj.map {|x| ruby_code x }.join(", ") + ']' + when Array then "[" + obj.map {|x| ruby_code x }.join(", ") + "]" when Hash then seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" } "{ #{seg.join(', ')} }" when Gem::Version then obj.to_s.dump - when DateLike then obj.strftime('%Y-%m-%d').dump - when Time then obj.strftime('%Y-%m-%d').dump + when DateLike then obj.strftime("%Y-%m-%d").dump + when Time then obj.strftime("%Y-%m-%d").dump when Numeric then obj.inspect when true, false, nil then obj.inspect when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})" @@ -2562,14 +2562,14 @@ def to_yaml(opts = {}) # :nodoc: # back, we have to check again here to make sure that our # psych code was properly loaded, and load it if not. unless Gem.const_defined?(:NoAliasYAMLTree) - require_relative 'psych_tree' + require_relative "psych_tree" end builder = Gem::NoAliasYAMLTree.create builder << self ast = builder.tree - require 'stringio' + require "stringio" io = StringIO.new io.set_encoding Encoding::UTF_8 @@ -2656,7 +2656,7 @@ def version=(version) # skip to set required_ruby_version when pre-released rubygems. # It caused to raise CircularDependencyError if @version.prerelease? && (@name.nil? || @name.strip != "rubygems") - self.required_rubygems_version = '> 1.3.1' + self.required_rubygems_version = "> 1.3.1" end invalidate_memoized_attributes diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index 8b5d01dda298..332189ae9f4c 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -1,4 +1,4 @@ -require_relative 'user_interaction' +require_relative "user_interaction" class Gem::SpecificationPolicy include Gem::UserInteraction @@ -120,7 +120,7 @@ def validate_metadata metadata = @specification.metadata unless Hash === metadata - error 'metadata must be a hash' + error "metadata must be a hash" end metadata.each do |key, value| @@ -188,7 +188,7 @@ def validate_dependencies # :nodoc: prerelease_dep && !@specification.version.prerelease? open_ended = dep.requirement.requirements.all? do |op, version| - not version.prerelease? and (op == '>' or op == '>=') + not version.prerelease? and (op == ">" or op == ">=") end if open_ended @@ -198,12 +198,12 @@ def validate_dependencies # :nodoc: base = segments.first 2 - recommendation = if (op == '>' || op == '>=') && segments == [0] + recommendation = if (op == ">" || op == ">=") && segments == [0] " use a bounded requirement, such as '~> x.y'" else - bugfix = if op == '>' + bugfix = if op == ">" ", '> #{dep_version}'" - elsif op == '>=' and base != segments + elsif op == ">=" and base != segments ", '>= #{dep_version}'" end @@ -286,7 +286,7 @@ def validate_name def validate_require_paths return unless @specification.raw_require_paths.empty? - error 'specification must have at least one require_path' + error "specification must have at least one require_path" end def validate_non_files @@ -310,7 +310,7 @@ def validate_self_inclusion_in_files_list def validate_specification_version return if @specification.specification_version.is_a?(Integer) - error 'specification_version must be an Integer (did you mean version?)' + error "specification_version must be an Integer (did you mean version?)" end def validate_platform @@ -380,7 +380,7 @@ def validate_licenses WARNING end - LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '') + LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, "") LAZY_PATTERN = /\AFI XME|\ATO DO/x.freeze HOMEPAGE_URI_PATTERN = /\A[a-z][a-z\d+.-]*:/i.freeze @@ -405,7 +405,7 @@ def validate_lazy_metadata # Make sure a homepage is valid HTTP/HTTPS URI if homepage and not homepage.empty? - require 'uri' + require "uri" begin homepage_uri = URI.parse(homepage) unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class @@ -445,7 +445,7 @@ def validate_attribute_present(attribute) def validate_shebang_line_in(executable) executable_path = File.join(@specification.bindir, executable) - return if File.read(executable_path, 2) == '#!' + return if File.read(executable_path, 2) == "#!" warning "#{executable_path} is missing #! line" end @@ -457,11 +457,11 @@ def validate_removed_attributes # :nodoc: end def validate_extensions # :nodoc: - require_relative 'ext' + require_relative "ext" builder = Gem::Ext::Builder.new(@specification) rake_extension = @specification.extensions.any? {|s| builder.builder_for(s) == Gem::Ext::RakeBuilder } - rake_dependency = @specification.dependencies.any? {|d| d.name == 'rake' } + rake_dependency = @specification.dependencies.any? {|d| d.name == "rake" } warning <<-WARNING if rake_extension && !rake_dependency You have specified rake based extension, but rake is not added as dependency. It is recommended to add rake as a dependency in gemspec since there's no guarantee rake will be already installed. diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index b1dd7397ae6c..33b4f45b0a07 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -9,7 +9,7 @@ class Gem::StubSpecification < Gem::BasicSpecification PREFIX = "# stub: ".freeze # :nodoc: - OPEN_MODE = 'r:UTF-8:-'.freeze + OPEN_MODE = "r:UTF-8:-".freeze class StubLine # :nodoc: all attr_reader :name, :version, :platform, :require_paths, :extensions, @@ -19,9 +19,9 @@ class StubLine # :nodoc: all # These are common require paths. REQUIRE_PATHS = { # :nodoc: - 'lib' => 'lib'.freeze, - 'test' => 'test'.freeze, - 'ext' => 'ext'.freeze, + "lib" => "lib".freeze, + "test" => "test".freeze, + "ext" => "ext".freeze, }.freeze # These are common require path lists. This hash is used to optimize @@ -29,7 +29,7 @@ class StubLine # :nodoc: all # in their require paths, so lets take advantage of that by pre-allocating # a require path list for that case. REQUIRE_PATH_LIST = { # :nodoc: - 'lib' => ['lib'].freeze, + "lib" => ["lib"].freeze, }.freeze def initialize(data, extensions) diff --git a/lib/rubygems/tsort.rb b/lib/rubygems/tsort.rb index ebe7c3364b70..60ebe22e810c 100644 --- a/lib/rubygems/tsort.rb +++ b/lib/rubygems/tsort.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require_relative 'tsort/lib/tsort' +require_relative "tsort/lib/tsort" diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index a36c5cbe2bf9..1ae301a44de8 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -5,12 +5,12 @@ # See LICENSE.txt for permissions. #++ -require 'fileutils' -require_relative '../rubygems' -require_relative 'installer_uninstaller_utils' -require_relative 'dependency_list' -require_relative 'rdoc' -require_relative 'user_interaction' +require "fileutils" +require_relative "../rubygems" +require_relative "installer_uninstaller_utils" +require_relative "dependency_list" +require_relative "rdoc" +require_relative "user_interaction" ## # An Uninstaller. @@ -302,8 +302,8 @@ def regenerate_plugins # Is +spec+ in +gem_dir+? def path_ok?(gem_dir, spec) - full_path = File.join gem_dir, 'gems', spec.full_name - original_path = File.join gem_dir, 'gems', spec.original_name + full_path = File.join gem_dir, "gems", spec.full_name + original_path = File.join gem_dir, "gems", spec.original_name full_path == spec.full_gem_path || original_path == spec.full_gem_path end @@ -332,10 +332,10 @@ def abort_on_dependent? # :nodoc: # Asks if it is OK to remove +spec+. Returns true if it is OK. def ask_if_ok(spec) # :nodoc: - msg = [''] - msg << 'You have requested to uninstall the gem:' + msg = [""] + msg << "You have requested to uninstall the gem:" msg << "\t#{spec.full_name}" - msg << '' + msg << "" siblings = Gem::Specification.select do |s| s.name == spec.name && s.full_name != spec.full_name @@ -347,8 +347,8 @@ def ask_if_ok(spec) # :nodoc: end end - msg << 'If you remove this gem, these dependencies will not be met.' - msg << 'Continue with Uninstall?' + msg << "If you remove this gem, these dependencies will not be met." + msg << "Continue with Uninstall?" return ask_yes_no(msg.join("\n"), false) end @@ -360,7 +360,7 @@ def formatted_program_filename(filename) # :nodoc: # of what it did for us to find rather than trying to recreate # it again. if @format_executable - require_relative 'installer' + require_relative "installer" Gem::Installer.exec_format % File.basename(filename) else filename diff --git a/lib/rubygems/uri.rb b/lib/rubygems/uri.rb index 6acb9041f9d4..4b5d035aa09f 100644 --- a/lib/rubygems/uri.rb +++ b/lib/rubygems/uri.rb @@ -66,7 +66,7 @@ def to_s def redact_credentials_from(text) return text unless valid_uri? && password? && text.include?(to_s) - text.sub(password, 'REDACTED') + text.sub(password, "REDACTED") end def method_missing(method_name, *args, &blk) @@ -97,11 +97,11 @@ def parse(uri) end def with_redacted_user - clone.tap {|uri| uri.user = 'REDACTED' } + clone.tap {|uri| uri.user = "REDACTED" } end def with_redacted_password - clone.tap {|uri| uri.password = 'REDACTED' } + clone.tap {|uri| uri.password = "REDACTED" } end def valid_uri? @@ -113,7 +113,7 @@ def password? end def oauth_basic? - password == 'x-oauth-basic' + password == "x-oauth-basic" end def token? diff --git a/lib/rubygems/uri_formatter.rb b/lib/rubygems/uri_formatter.rb index 3bda896875bc..3f1d02d774bd 100644 --- a/lib/rubygems/uri_formatter.rb +++ b/lib/rubygems/uri_formatter.rb @@ -17,7 +17,7 @@ class Gem::UriFormatter # Creates a new URI formatter for +uri+. def initialize(uri) - require 'cgi' + require "cgi" @uri = uri end diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb index c726fd21c1fd..4b0a7c60bb6b 100644 --- a/lib/rubygems/user_interaction.rb +++ b/lib/rubygems/user_interaction.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'deprecate' -require_relative 'text' +require_relative "deprecate" +require_relative "text" ## # Module that defines the default UserInteraction. Any class including this @@ -148,7 +148,7 @@ def choose_from_list(question, list) ## # Displays the given +statement+ on the standard output (or equivalent). - def say(statement = '') + def say(statement = "") ui.say statement end @@ -259,11 +259,11 @@ def ask_yes_no(question, default=nil) default_answer = case default when nil - 'yn' + "yn" when true - 'Yn' + "Yn" else - 'yN' + "yN" end result = nil @@ -312,7 +312,7 @@ def ask_for_password(question) def require_io_console @require_io_console ||= begin begin - require 'io/console' + require "io/console" rescue LoadError end true @@ -472,7 +472,7 @@ class VerboseProgressReporter # and the +terminal_message+ when it is complete. def initialize(out_stream, size, initial_message, - terminal_message = 'complete') + terminal_message = "complete") @out = out_stream @total = size @count = 0 diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index 9fd78ab2bc90..356c46a5a175 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'deprecate' +require_relative "deprecate" ## # This module contains various utility methods as module methods. @@ -10,9 +10,9 @@ module Gem::Util # Zlib::GzipReader wrapper that unzips +data+. def self.gunzip(data) - require 'zlib' - require 'stringio' - data = StringIO.new(data, 'r') + require "zlib" + require "stringio" + data = StringIO.new(data, "r") gzip_reader = begin Zlib::GzipReader.new(data) @@ -29,9 +29,9 @@ def self.gunzip(data) # Zlib::GzipWriter wrapper that zips +data+. def self.gzip(data) - require 'zlib' - require 'stringio' - zipped = StringIO.new(String.new, 'w') + require "zlib" + require "stringio" + zipped = StringIO.new(String.new, "w") zipped.set_encoding Encoding::BINARY Zlib::GzipWriter.wrap zipped do |io| @@ -45,7 +45,7 @@ def self.gzip(data) # A Zlib::Inflate#inflate wrapper def self.inflate(data) - require 'zlib' + require "zlib" Zlib::Inflate.inflate data end @@ -86,7 +86,7 @@ def self.traverse_parents(directory, &block) loop do Dir.chdir here, &block rescue Errno::EACCES - new_here = File.expand_path('..', here) + new_here = File.expand_path("..", here) return if new_here == here # toplevel here = new_here end @@ -109,7 +109,7 @@ def self.glob_files_in_dir(glob, base_path) # comes with a leading slash. def self.correct_for_windows_path(path) - if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':' + if path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":" path[1..-1] else path diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb index 3f4178c6e054..96f47781c089 100644 --- a/lib/rubygems/util/licenses.rb +++ b/lib/rubygems/util/licenses.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative '../text' +require_relative "../text" class Gem::Licenses extend Gem::Text - NONSTANDARD = 'Nonstandard'.freeze - LICENSE_REF = 'LicenseRef-.+'.freeze + NONSTANDARD = "Nonstandard".freeze + LICENSE_REF = "LicenseRef-.+".freeze # Software Package Data Exchange (SPDX) standard open-source software # license identifiers diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb index 728595e7785c..60104a34d535 100644 --- a/lib/rubygems/validator.rb +++ b/lib/rubygems/validator.rb @@ -5,8 +5,8 @@ # See LICENSE.txt for permissions. #++ -require_relative 'package' -require_relative 'installer' +require_relative "package" +require_relative "installer" ## # Validator performs various gem file and gem database validation @@ -15,7 +15,7 @@ class Gem::Validator include Gem::UserInteraction def initialize # :nodoc: - require 'find' + require "find" end private @@ -110,11 +110,11 @@ def alien(gems=[]) begin next unless data # HACK `gem check -a mkrf` - source = File.join gem_directory, entry['path'] + source = File.join gem_directory, entry["path"] File.open source, Gem.binary_mode do |f| unless f.read == data - errors[gem_name][entry['path']] = "Modified from original" + errors[gem_name][entry["path"]] = "Modified from original" end end end diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index c57bf7d6d51b..03ae5ca17eb1 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -276,7 +276,7 @@ def marshal_load(array) end def yaml_initialize(tag, map) # :nodoc: - @version = map['version'] + @version = map["version"] @segments = nil @hash = nil end @@ -286,7 +286,7 @@ def to_yaml_properties # :nodoc: end def encode_with(coder) # :nodoc: - coder.add 'version', @version + coder.add "version", @version end ## @@ -311,7 +311,7 @@ def release @@release[self] ||= if prerelease? segments = self.segments segments.pop while segments.any? {|s| String === s } - self.class.new segments.join('.') + self.class.new segments.join(".") else self end diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb index 1db382fa7f98..a487a0bc24b2 100644 --- a/lib/rubygems/version_option.rb +++ b/lib/rubygems/version_option.rb @@ -5,7 +5,7 @@ # See LICENSE.txt for permissions. #++ -require_relative '../rubygems' +require_relative "../rubygems" ## # Mixin methods for --version and --platform Gem::Command options. @@ -24,7 +24,7 @@ def add_platform_option(task = command, *wrap) end end - add_option('--platform PLATFORM', Gem::Platform, + add_option("--platform PLATFORM", Gem::Platform, "Specify the platform of gem to #{task}", *wrap) do |value, options| unless options[:added_platform] @@ -55,7 +55,7 @@ def add_version_option(task = command, *wrap) Gem::Requirement.new(*value.split(/\s*,\s*/)) end - add_option('-v', '--version VERSION', Gem::Requirement, + add_option("-v", "--version VERSION", Gem::Requirement, "Specify version of gem to #{task}", *wrap) do |value, options| # Allow handling for multiple --version operators diff --git a/rubygems-update.gemspec b/rubygems-update.gemspec index db3243734aaf..923cf1c8d146 100644 --- a/rubygems-update.gemspec +++ b/rubygems-update.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.homepage = "https://rubygems.org" s.licenses = ["Ruby", "MIT"] - s.files = File.read('Manifest.txt').split + s.files = File.read("Manifest.txt").split s.executables = ["update_rubygems"] s.require_paths = ["hide_lib_for_update"] s.rdoc_options = ["--main", "README.md", "--title=RubyGems Update Documentation"] diff --git a/setup.rb b/setup.rb index cbda81bc5a20..1f4033aceb8b 100644 --- a/setup.rb +++ b/setup.rb @@ -7,27 +7,27 @@ #++ # Make sure rubygems isn't already loaded. -if ENV['RUBYOPT'] or defined? Gem - ENV.delete 'RUBYOPT' +if ENV["RUBYOPT"] or defined? Gem + ENV.delete "RUBYOPT" - require 'rbconfig' - cmd = [RbConfig.ruby, '--disable-gems', 'setup.rb', *ARGV] + require "rbconfig" + cmd = [RbConfig.ruby, "--disable-gems", "setup.rb", *ARGV] exec(*cmd) end Dir.chdir __dir__ -$:.unshift File.expand_path('lib') -require 'rubygems' -require 'rubygems/gem_runner' +$:.unshift File.expand_path("lib") +require "rubygems" +require "rubygems/gem_runner" Gem::CommandManager.instance.register_command :setup args = ARGV.clone if ENV["GEM_PREV_VER"] - args = [ '--previous-version', ENV["GEM_PREV_VER"] ] + args + args = [ "--previous-version", ENV["GEM_PREV_VER"] ] + args end -args.unshift 'setup' +args.unshift "setup" Gem::GemRunner.new.run args diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index 56d209307883..dab3cd4d4c4c 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'rubygems' +require "rubygems" # If bundler gemspec exists, add to stubs -bundler_gemspec = File.expand_path('../../bundler/bundler.gemspec', __dir__) +bundler_gemspec = File.expand_path("../../bundler/bundler.gemspec", __dir__) if File.exist?(bundler_gemspec) Gem::Specification.dirs.unshift File.dirname(bundler_gemspec) Gem::Specification.class_variable_set :@@stubs, nil @@ -12,32 +12,32 @@ end begin - gem 'test-unit', '~> 3.0' + gem "test-unit", "~> 3.0" rescue Gem::LoadError end if File.exist?(bundler_gemspec) - require_relative '../../bundler/lib/bundler' + require_relative "../../bundler/lib/bundler" else - require 'bundler' + require "bundler" end -require 'test/unit' +require "test/unit" ENV["JARS_SKIP"] = "true" if Gem.java_platform? # avoid unnecessary and noisy `jar-dependencies` post install hook -require 'rubygems/deprecate' +require "rubygems/deprecate" -require 'fileutils' -require 'pathname' -require 'pp' -require 'rubygems/package' -require 'shellwords' -require 'tmpdir' -require 'uri' -require 'zlib' -require 'benchmark' # stdlib -require 'rubygems/mock_gem_ui' +require "fileutils" +require "pathname" +require "pp" +require "rubygems/package" +require "shellwords" +require "tmpdir" +require "uri" +require "zlib" +require "benchmark" # stdlib +require "rubygems/mock_gem_ui" module Gem @@ -165,15 +165,15 @@ def capture_subprocess_io # the original value when the block ends def enable_shared(value) - enable_shared = RbConfig::CONFIG['ENABLE_SHARED'] - RbConfig::CONFIG['ENABLE_SHARED'] = value + enable_shared = RbConfig::CONFIG["ENABLE_SHARED"] + RbConfig::CONFIG["ENABLE_SHARED"] = value yield ensure if enable_shared - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + RbConfig::CONFIG["ENABLE_SHARED"] = enable_shared else - RbConfig::CONFIG.delete 'ENABLE_SHARED' + RbConfig::CONFIG.delete "ENABLE_SHARED" end end @@ -182,20 +182,20 @@ def enable_shared(value) # original value when the block ends # def vendordir(value) - vendordir = RbConfig::CONFIG['vendordir'] + vendordir = RbConfig::CONFIG["vendordir"] if value - RbConfig::CONFIG['vendordir'] = value + RbConfig::CONFIG["vendordir"] = value else - RbConfig::CONFIG.delete 'vendordir' + RbConfig::CONFIG.delete "vendordir" end yield ensure if vendordir - RbConfig::CONFIG['vendordir'] = vendordir + RbConfig::CONFIG["vendordir"] = vendordir else - RbConfig::CONFIG.delete 'vendordir' + RbConfig::CONFIG.delete "vendordir" end end @@ -205,21 +205,21 @@ def vendordir(value) # def bindir(value) with_clean_path_to_ruby do - bindir = RbConfig::CONFIG['bindir'] + bindir = RbConfig::CONFIG["bindir"] if value - RbConfig::CONFIG['bindir'] = value + RbConfig::CONFIG["bindir"] = value else - RbConfig::CONFIG.delete 'bindir' + RbConfig::CONFIG.delete "bindir" end begin yield ensure if bindir - RbConfig::CONFIG['bindir'] = bindir + RbConfig::CONFIG["bindir"] = bindir else - RbConfig::CONFIG.delete 'bindir' + RbConfig::CONFIG.delete "bindir" end end end @@ -230,20 +230,20 @@ def bindir(value) # original value when the block ends # def exeext(value) - exeext = RbConfig::CONFIG['EXEEXT'] + exeext = RbConfig::CONFIG["EXEEXT"] if value - RbConfig::CONFIG['EXEEXT'] = value + RbConfig::CONFIG["EXEEXT"] = value else - RbConfig::CONFIG.delete 'EXEEXT' + RbConfig::CONFIG.delete "EXEEXT" end yield ensure if exeext - RbConfig::CONFIG['EXEEXT'] = exeext + RbConfig::CONFIG["EXEEXT"] = exeext else - RbConfig::CONFIG.delete 'EXEEXT' + RbConfig::CONFIG.delete "EXEEXT" end end @@ -264,7 +264,7 @@ def parse_make_command_line_targets(line) end end - targets << '' if targets.empty? + targets << "" if targets.empty? targets end @@ -273,14 +273,14 @@ def assert_contains_make_command(target, output, msg = nil) if output.match(/\n/) msg = build_message(msg, "Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT" % [ - ('%s %s' % [make_command, target]).rstrip, + ("%s %s" % [make_command, target]).rstrip, output, ] ) else msg = build_message(msg, 'Expected make command "%s", but was "%s"' % [ - ('%s %s' % [make_command, target]).rstrip, + ("%s %s" % [make_command, target]).rstrip, output, ] ) @@ -317,13 +317,13 @@ def setup @tempdir = Dir.mktmpdir("test_rubygems_", @tmp) @tempdir.tap(&Gem::UNTAINT) - ENV['GEM_VENDOR'] = nil - ENV['GEMRC'] = nil - ENV['XDG_CACHE_HOME'] = nil - ENV['XDG_CONFIG_HOME'] = nil - ENV['XDG_DATA_HOME'] = nil - ENV['SOURCE_DATE_EPOCH'] = nil - ENV['BUNDLER_VERSION'] = nil + ENV["GEM_VENDOR"] = nil + ENV["GEMRC"] = nil + ENV["XDG_CACHE_HOME"] = nil + ENV["XDG_CONFIG_HOME"] = nil + ENV["XDG_DATA_HOME"] = nil + ENV["SOURCE_DATE_EPOCH"] = nil + ENV["BUNDLER_VERSION"] = nil @current_dir = Dir.pwd @fetcher = nil @@ -339,19 +339,19 @@ def setup @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE, - File.join(@tempdir, 'system-gemrc') + File.join(@tempdir, "system-gemrc") - @gemhome = File.join @tempdir, 'gemhome' - @userhome = File.join @tempdir, 'userhome' - ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache' + @gemhome = File.join @tempdir, "gemhome" + @userhome = File.join @tempdir, "userhome" + ENV["GEM_SPEC_CACHE"] = File.join @tempdir, "spec_cache" - @orig_ruby = if ENV['RUBY'] + @orig_ruby = if ENV["RUBY"] ruby = Gem.ruby - Gem.ruby = ENV['RUBY'] + Gem.ruby = ENV["RUBY"] ruby end - @git = ENV['GIT'] || (win_platform? ? 'git.exe' : 'git') + @git = ENV["GIT"] || (win_platform? ? "git.exe" : "git") Gem.ensure_gem_subdirectories @gemhome Gem.ensure_default_gem_subdirectories @gemhome @@ -372,7 +372,7 @@ def setup Dir.chdir @tempdir - ENV['HOME'] = @userhome + ENV["HOME"] = @userhome Gem.instance_variable_set :@config_file, nil Gem.instance_variable_set :@user_home, nil Gem.instance_variable_set :@config_home, nil @@ -384,12 +384,12 @@ def setup FileUtils.mkdir_p @userhome - ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = PRIVATE_KEY_PASSPHRASE + ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = PRIVATE_KEY_PASSPHRASE Gem.instance_variable_set(:@default_specifications_dir, nil) if Gem.java_platform? - @orig_default_gem_home = RbConfig::CONFIG['default_gem_home'] - RbConfig::CONFIG['default_gem_home'] = @gemhome + @orig_default_gem_home = RbConfig::CONFIG["default_gem_home"] + RbConfig::CONFIG["default_gem_home"] = @gemhome else Gem.instance_variable_set(:@default_dir, @gemhome) end @@ -425,12 +425,12 @@ def setup Gem.searcher = nil Gem::SpecFetcher.fetcher = nil - @orig_arch = RbConfig::CONFIG['arch'] + @orig_arch = RbConfig::CONFIG["arch"] if win_platform? - util_set_arch 'i386-mswin32' + util_set_arch "i386-mswin32" else - util_set_arch 'i686-darwin8.10.1' + util_set_arch "i686-darwin8.10.1" end %w[post_install_hooks done_installing_hooks post_uninstall_hooks pre_uninstall_hooks pre_install_hooks pre_reset_hooks post_reset_hooks post_build_hooks].each do |name| @@ -457,7 +457,7 @@ def teardown end end - RbConfig::CONFIG['arch'] = @orig_arch + RbConfig::CONFIG["arch"] = @orig_arch if defined? Gem::RemoteFetcher Gem::RemoteFetcher.fetcher = nil @@ -475,13 +475,13 @@ def teardown Gem.ruby = @orig_ruby if @orig_ruby - RbConfig::CONFIG['mandir'] = @orig_mandir - RbConfig::CONFIG['sitelibdir'] = @orig_sitelibdir - RbConfig::CONFIG['bindir'] = @orig_bindir + RbConfig::CONFIG["mandir"] = @orig_mandir + RbConfig::CONFIG["sitelibdir"] = @orig_sitelibdir + RbConfig::CONFIG["bindir"] = @orig_bindir Gem.instance_variable_set :@default_specifications_dir, nil if Gem.java_platform? - RbConfig::CONFIG['default_gem_home'] = @orig_default_gem_home + RbConfig::CONFIG["default_gem_home"] = @orig_default_gem_home else Gem.instance_variable_set :@default_dir, nil end @@ -497,9 +497,9 @@ def teardown end def credential_setup - @temp_cred = File.join(@userhome, '.gem', 'credentials') + @temp_cred = File.join(@userhome, ".gem", "credentials") FileUtils.mkdir_p File.dirname(@temp_cred) - File.write @temp_cred, ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' + File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97" File.chmod 0600, @temp_cred end @@ -554,10 +554,10 @@ def without_any_upwards_gemfiles # # Yields the +specification+ to the block, if given - def git_gem(name = 'a', version = 1) + def git_gem(name = "a", version = 1) have_git? - directory = File.join 'git', name + directory = File.join "git", name directory = File.expand_path directory git_spec = Gem::Specification.new name, version do |specification| @@ -568,22 +568,22 @@ def git_gem(name = 'a', version = 1) gemspec = "#{name}.gemspec" - File.open File.join(directory, gemspec), 'w' do |io| + File.open File.join(directory, gemspec), "w" do |io| io.write git_spec.to_ruby end head = nil Dir.chdir directory do - unless File.exist? '.git' - system @git, 'init', '--quiet' - system @git, 'config', 'user.name', 'RubyGems Tests' - system @git, 'config', 'user.email', 'rubygems@example' + unless File.exist? ".git" + system @git, "init", "--quiet" + system @git, "config", "user.name", "RubyGems Tests" + system @git, "config", "user.email", "rubygems@example" end - system @git, 'add', gemspec - system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet' - head = Gem::Util.popen(@git, 'rev-parse', 'master').strip + system @git, "add", gemspec + system @git, "commit", "-a", "-m", "a non-empty commit message", "--quiet" + head = Gem::Util.popen(@git, "rev-parse", "master").strip end return name, git_spec.version, directory, head @@ -595,13 +595,13 @@ def git_gem(name = 'a', version = 1) def have_git? return if in_path? @git - pend 'cannot find git executable, use GIT environment variable to set' + pend "cannot find git executable, use GIT environment variable to set" end def in_path?(executable) # :nodoc: return true if %r{\A([A-Z]:|/)} =~ executable and File.exist? executable - ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory| + ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory| File.exist? File.join directory, executable end end @@ -610,7 +610,7 @@ def in_path?(executable) # :nodoc: # Builds and installs the Gem::Specification +spec+ def install_gem(spec, options = {}) - require 'rubygems/installer' + require "rubygems/installer" gem = spec.cache_file @@ -637,7 +637,7 @@ def install_gem_user(spec) ## # Uninstalls the Gem::Specification +spec+ def uninstall_gem(spec) - require 'rubygems/uninstaller' + require "rubygems/uninstaller" Class.new(Gem::Uninstaller) do def ask_if_ok(spec) @@ -660,7 +660,7 @@ def mu_pp(obj) # Reads a Marshal file at +path+ def read_cache(path) - File.open path.dup.tap(&Gem::UNTAINT), 'rb' do |io| + File.open path.dup.tap(&Gem::UNTAINT), "rb" do |io| Marshal.load io.read end end @@ -680,7 +680,7 @@ def write_file(path) dir = File.dirname path FileUtils.mkdir_p dir unless File.directory? dir - File.open path, 'wb' do |io| + File.open path, "wb" do |io| yield io if block_given? end @@ -723,16 +723,16 @@ def all_spec_names # # Use this with #write_file to build an installed gem. - def quick_gem(name, version='2') - require 'rubygems/specification' + def quick_gem(name, version="2") + require "rubygems/specification" spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = name s.version = version - s.author = 'A User' - s.email = 'example@example.com' - s.homepage = 'http://example.com' + s.author = "A User" + s.email = "example@example.com" + s.homepage = "http://example.com" s.summary = "this is a summary" s.description = "This is a test description" @@ -763,7 +763,7 @@ def util_build_gem(spec) next if File.exist? file FileUtils.mkdir_p File.dirname(file) - File.open file, 'w' do |fp| + File.open file, "w" do |fp| fp.puts "# #{file}" end end @@ -855,9 +855,9 @@ def util_spec(name, version = 2, deps = nil, *files) # :yields: specification s.platform = Gem::Platform::RUBY s.name = name s.version = version - s.author = 'A User' - s.email = 'example@example.com' - s.homepage = 'http://example.com' + s.author = "A User" + s.email = "example@example.com" + s.homepage = "http://example.com" s.summary = "this is a summary" s.description = "This is a test description" @@ -868,7 +868,7 @@ def util_spec(name, version = 2, deps = nil, *files) # :yields: specification if deps deps.keys.each do |n| - spec.add_dependency n, (deps[n] || '>= 0') + spec.add_dependency n, (deps[n] || ">= 0") end end @@ -895,7 +895,7 @@ def util_gem(name, version, deps = nil, &block) if deps block = proc do |s| deps.keys.each do |n| - s.add_dependency n, (deps[n] || '>= 0') + s.add_dependency n, (deps[n] || ">= 0") end end end @@ -904,7 +904,7 @@ def util_gem(name, version, deps = nil, &block) util_build_gem spec - cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem" + cache_file = File.join @tempdir, "gems", "#{spec.original_name}.gem" FileUtils.mkdir_p File.dirname cache_file FileUtils.mv spec.cache_file, cache_file FileUtils.rm spec.spec_file @@ -946,11 +946,11 @@ def util_gzip(data) # TODO: nuke this and fix tests. this should speed up a lot def util_make_gems(prerelease = false) - @a1 = quick_gem 'a', '1' do |s| + @a1 = quick_gem "a", "1" do |s| s.files = %w[lib/code.rb] s.require_paths = %w[lib] s.date = Gem::Specification::TODAY - 86400 - s.homepage = 'http://a.example.com' + s.homepage = "http://a.example.com" s.email = %w[example@example.com example2@example.com] s.authors = %w[Example Example2] s.description = <<-DESC @@ -967,27 +967,27 @@ def util_make_gems(prerelease = false) s.require_paths = %w[lib] end - @a2 = quick_gem('a', '2', &init) - @a3a = quick_gem('a', '3.a', &init) - @a_evil9 = quick_gem('a_evil', '9', &init) - @b2 = quick_gem('b', '2', &init) - @c1_2 = quick_gem('c', '1.2', &init) - @x = quick_gem('x', '1', &init) - @dep_x = quick_gem('dep_x', '1') do |s| + @a2 = quick_gem("a", "2", &init) + @a3a = quick_gem("a", "3.a", &init) + @a_evil9 = quick_gem("a_evil", "9", &init) + @b2 = quick_gem("b", "2", &init) + @c1_2 = quick_gem("c", "1.2", &init) + @x = quick_gem("x", "1", &init) + @dep_x = quick_gem("dep_x", "1") do |s| s.files = %w[lib/code.rb] s.require_paths = %w[lib] - s.add_dependency 'x', '>= 1' + s.add_dependency "x", ">= 1" end - @pl1 = quick_gem 'pl', '1' do |s| # l for legacy + @pl1 = quick_gem "pl", "1" do |s| # l for legacy s.files = %w[lib/code.rb] s.require_paths = %w[lib] - s.platform = Gem::Platform.new 'i386-linux' - s.instance_variable_set :@original_platform, 'i386-linux' + s.platform = Gem::Platform.new "i386-linux" + s.instance_variable_set :@original_platform, "i386-linux" end if prerelease - @a2_pre = quick_gem('a', '2.a', &init) + @a2_pre = quick_gem("a", "2.a", &init) write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb]) util_build_gem @a2_pre end @@ -1013,7 +1013,7 @@ def util_make_gems(prerelease = false) # Set the platform to +arch+ def util_set_arch(arch) - RbConfig::CONFIG['arch'] = arch + RbConfig::CONFIG["arch"] = arch platform = Gem::Platform.new arch Gem.instance_variable_set :@platforms, nil @@ -1182,7 +1182,7 @@ def java_platform? # Borland) versus Cygwin, Mingw, etc. def self.vc_windows? - RUBY_PLATFORM.match('mswin') + RUBY_PLATFORM.match("mswin") end ## @@ -1190,7 +1190,7 @@ def self.vc_windows? # Borland) versus Cygwin, Mingw, etc. def vc_windows? - RUBY_PLATFORM.match('mswin') + RUBY_PLATFORM.match("mswin") end ## @@ -1207,7 +1207,7 @@ def ruby_repo? # other platforms, including Cygwin, it will return 'make'. def self.make_command - ENV["make"] || ENV["MAKE"] || (vc_windows? ? 'nmake' : 'make') + ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make") end ## @@ -1216,14 +1216,14 @@ def self.make_command # other platforms, including Cygwin, it will return 'make'. def make_command - ENV["make"] || ENV["MAKE"] || (vc_windows? ? 'nmake' : 'make') + ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make") end ## # Returns whether or not the nmake command could be found. def nmake_found? - system('nmake /? 1>NUL 2>&1') + system("nmake /? 1>NUL 2>&1") end # In case we're building docs in a background process, this method waits for @@ -1431,8 +1431,8 @@ def v(string) # # Yields the +specification+ to the block, if given - def vendor_gem(name = 'a', version = 1) - directory = File.join 'vendor', name + def vendor_gem(name = "a", version = 1) + directory = File.join "vendor", name FileUtils.mkdir_p directory @@ -1445,12 +1445,12 @@ def vendor_gem(name = 'a', version = 1) # # Yields the +specification+ to the block, if given - def save_gemspec(name = 'a', version = 1, directory = '.') + def save_gemspec(name = "a", version = 1, directory = ".") vendor_spec = Gem::Specification.new name, version do |specification| yield specification if block_given? end - File.open File.join(directory, "#{name}.gemspec"), 'w' do |io| + File.open File.join(directory, "#{name}.gemspec"), "w" do |io| io.write vendor_spec.to_ruby end @@ -1564,20 +1564,20 @@ def self.key_path(key_name) # :stopdoc: # only available in RubyGems tests - PRIVATE_KEY_PASSPHRASE = 'Foo bar'.freeze + PRIVATE_KEY_PASSPHRASE = "Foo bar".freeze begin - PRIVATE_KEY = load_key 'private' - PRIVATE_KEY_PATH = key_path 'private' + PRIVATE_KEY = load_key "private" + PRIVATE_KEY_PATH = key_path "private" # ENCRYPTED_PRIVATE_KEY is PRIVATE_KEY encrypted with PRIVATE_KEY_PASSPHRASE - ENCRYPTED_PRIVATE_KEY = load_key 'encrypted_private', PRIVATE_KEY_PASSPHRASE - ENCRYPTED_PRIVATE_KEY_PATH = key_path 'encrypted_private' + ENCRYPTED_PRIVATE_KEY = load_key "encrypted_private", PRIVATE_KEY_PASSPHRASE + ENCRYPTED_PRIVATE_KEY_PATH = key_path "encrypted_private" PUBLIC_KEY = PRIVATE_KEY.public_key - PUBLIC_CERT = load_cert 'public' - PUBLIC_CERT_PATH = cert_path 'public' + PUBLIC_CERT = load_cert "public" + PUBLIC_CERT_PATH = cert_path "public" rescue Errno::ENOENT PRIVATE_KEY = nil PUBLIC_KEY = nil @@ -1619,4 +1619,4 @@ def stub(name, val_or_callable, *block_args) end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition end -require_relative 'utilities' +require_relative "utilities" diff --git a/test/rubygems/installer_test_case.rb b/test/rubygems/installer_test_case.rb index 824ac53a82bd..6211cfff16c6 100644 --- a/test/rubygems/installer_test_case.rb +++ b/test/rubygems/installer_test_case.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/installer' +require_relative "helper" +require "rubygems/installer" class Gem::Installer ## @@ -133,7 +133,7 @@ def setup_base_gem # And returns it def setup_base_spec - quick_gem 'a' do |spec| + quick_gem "a" do |spec| util_make_exec spec end end @@ -154,7 +154,7 @@ def setup_base_spec # And returns a Gem::Installer for the @user_spec that installs into Gem.user_dir def setup_base_user_installer - @user_spec = quick_gem 'b' do |spec| + @user_spec = quick_gem "b" do |spec| util_make_exec spec end @@ -183,23 +183,23 @@ def util_setup_installer(&block) # ext/a/mkrf_conf.rb def util_setup_gem(ui = @ui, force = true) - @spec.files << File.join('lib', 'code.rb') - @spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb') + @spec.files << File.join("lib", "code.rb") + @spec.extensions << File.join("ext", "a", "mkrf_conf.rb") Dir.chdir @tempdir do - FileUtils.mkdir_p 'bin' - FileUtils.mkdir_p 'lib' - FileUtils.mkdir_p File.join('ext', 'a') + FileUtils.mkdir_p "bin" + FileUtils.mkdir_p "lib" + FileUtils.mkdir_p File.join("ext", "a") - File.open File.join('bin', 'executable'), 'w' do |f| + File.open File.join("bin", "executable"), "w" do |f| f.puts "raise 'ran executable'" end - File.open File.join('lib', 'code.rb'), 'w' do |f| - f.puts '1' + File.open File.join("lib", "code.rb"), "w" do |f| + f.puts "1" end - File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f| + File.open File.join("ext", "a", "mkrf_conf.rb"), "w" do |f| f << <<-EOF File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end EOF diff --git a/test/rubygems/package/tar_test_case.rb b/test/rubygems/package/tar_test_case.rb index 4517f407303e..6cee7f86dcf0 100644 --- a/test/rubygems/package/tar_test_case.rb +++ b/test/rubygems/package/tar_test_case.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../helper' -require 'rubygems/package' +require_relative "../helper" +require "rubygems/package" ## # A test case for Gem::Package::Tar* classes diff --git a/test/rubygems/plugin/exception/rubygems_plugin.rb b/test/rubygems/plugin/exception/rubygems_plugin.rb index 9a6f557b5ce3..f54e689d87ec 100644 --- a/test/rubygems/plugin/exception/rubygems_plugin.rb +++ b/test/rubygems/plugin/exception/rubygems_plugin.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true TestGem::TEST_PLUGIN_EXCEPTION = :loaded -raise Exception.new('boom') +raise Exception.new("boom") diff --git a/test/rubygems/plugin/standarderror/rubygems_plugin.rb b/test/rubygems/plugin/standarderror/rubygems_plugin.rb index 94cf4e8a52a9..0fcca287281e 100644 --- a/test/rubygems/plugin/standarderror/rubygems_plugin.rb +++ b/test/rubygems/plugin/standarderror/rubygems_plugin.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true TestGem::TEST_PLUGIN_STANDARDERROR = :loaded -raise StandardError.new('boom') +raise StandardError.new("boom") diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb index 2dc7836904b7..b538487bbfd2 100644 --- a/test/rubygems/rubygems_plugin.rb +++ b/test/rubygems/rubygems_plugin.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'rubygems/command_manager' +require "rubygems/command_manager" ## # This is an example of exactly what NOT to do. @@ -12,7 +12,7 @@ module Gem::Commands class Gem::Commands::InterruptCommand < Gem::Command def initialize - super('interrupt', 'Raises an Interrupt Exception', {}) + super("interrupt", "Raises an Interrupt Exception", {}) end def execute diff --git a/test/rubygems/specifications/rubyforge-0.0.1.gemspec b/test/rubygems/specifications/rubyforge-0.0.1.gemspec index c760a42073b1..e8d503032629 100644 --- a/test/rubygems/specifications/rubyforge-0.0.1.gemspec +++ b/test/rubygems/specifications/rubyforge-0.0.1.gemspec @@ -5,8 +5,8 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.summary = "A very bar gem" s.authors = ["unknown"] - s.license = 'MIT' - s.homepage = 'http://example.com' - s.files = ['README.md'] - s.rubyforge_project = 'abc' + s.license = "MIT" + s.homepage = "http://example.com" + s.files = ["README.md"] + s.rubyforge_project = "abc" end diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb index fff5904abaf8..b061666c7698 100644 --- a/test/rubygems/test_bundled_ca.rb +++ b/test/rubygems/test_bundled_ca.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative 'helper' -require 'net/http' -require 'rubygems/openssl' +require_relative "helper" +require "net/http" +require "rubygems/openssl" unless Gem::HAVE_OPENSSL - warn 'Skipping bundled certificates tests. openssl not found.' + warn "Skipping bundled certificates tests. openssl not found." end -require 'rubygems/request' +require "rubygems/request" # = Testing Bundled CA # @@ -31,7 +31,7 @@ def assert_https(host) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.cert_store = bundled_certificate_store - http.get('/') + http.get("/") rescue Errno::ENOENT, Errno::ETIMEDOUT, SocketError pend "#{host} seems offline, I can't tell whether ssl would work." rescue OpenSSL::SSL::SSLError => e @@ -43,18 +43,18 @@ def assert_https(host) end def test_accessing_rubygems - assert_https('rubygems.org') + assert_https("rubygems.org") end def test_accessing_www_rubygems - assert_https('www.rubygems.org') + assert_https("www.rubygems.org") end def test_accessing_staging - assert_https('staging.rubygems.org') + assert_https("staging.rubygems.org") end def test_accessing_new_index - assert_https('index.rubygems.org') + assert_https("index.rubygems.org") end end if Gem::HAVE_OPENSSL diff --git a/test/rubygems/test_config.rb b/test/rubygems/test_config.rb index fff539c8164e..d9e0f4dd9d81 100644 --- a/test/rubygems/test_config.rb +++ b/test/rubygems/test_config.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems' -require 'shellwords' +require_relative "helper" +require "rubygems" +require "shellwords" class TestConfig < Gem::TestCase def test_datadir diff --git a/test/rubygems/test_deprecate.rb b/test/rubygems/test_deprecate.rb index a619eccb37d9..dfcf8dea113e 100644 --- a/test/rubygems/test_deprecate.rb +++ b/test/rubygems/test_deprecate.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/deprecate' +require_relative "helper" +require "rubygems/deprecate" class TestDeprecate < Gem::TestCase def setup @@ -123,7 +123,7 @@ def test_deprecated_method_outputs_a_warning end def test_rubygems_deprecate_command - require 'rubygems/command' + require "rubygems/command" foo_command = Class.new(Gem::Command) do extend Gem::Deprecate diff --git a/test/rubygems/test_exit.rb b/test/rubygems/test_exit.rb index 9557fe5d0631..3986daa9929f 100644 --- a/test/rubygems/test_exit.rb +++ b/test/rubygems/test_exit.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems' +require_relative "helper" +require "rubygems" class TestExit < Gem::TestCase def test_exit diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 4d9644d5c9e3..bbb3e6dd0a1e 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1,16 +1,16 @@ # coding: US-ASCII -require_relative 'helper' -require 'rubygems' -require 'rubygems/command' -require 'rubygems/installer' -require 'pathname' -require 'tmpdir' -require 'rbconfig' +require_relative "helper" +require "rubygems" +require "rubygems/command" +require "rubygems/installer" +require "pathname" +require "tmpdir" +require "rbconfig" class TestGem < Gem::TestCase PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant - PROJECT_DIR = File.expand_path('../..', __dir__).tap(&Gem::UNTAINT) + PROJECT_DIR = File.expand_path("../..", __dir__).tap(&Gem::UNTAINT) def setup super @@ -89,32 +89,32 @@ def test_self_finish_resolve_respects_loaded_specs def test_self_install spec_fetcher do |f| - f.gem 'a', 1 - f.spec 'a', 2 + f.gem "a", 1 + f.spec "a", 2 end gemhome2 = "#{@gemhome}2" - installed = Gem.install 'a', '= 1', :install_dir => gemhome2 + installed = Gem.install "a", "= 1", :install_dir => gemhome2 assert_equal %w[a-1], installed.map {|spec| spec.full_name } - assert_path_exist File.join(gemhome2, 'gems', 'a-1') + assert_path_exist File.join(gemhome2, "gems", "a-1") end def test_self_install_in_rescue spec_fetcher do |f| - f.gem 'a', 1 - f.spec 'a', 2 + f.gem "a", 1 + f.spec "a", 2 end gemhome2 = "#{@gemhome}2" installed = begin - raise 'Error' + raise "Error" rescue StandardError - Gem.install 'a', '= 1', :install_dir => gemhome2 + Gem.install "a", "= 1", :install_dir => gemhome2 end assert_equal %w[a-1], installed.map {|spec| spec.full_name } end @@ -143,7 +143,7 @@ def test_self_install_permissions_with_format_executable def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name Gem::Installer.exec_format = nil - ruby_install_name 'ruby27' do + ruby_install_name "ruby27" do assert_self_install_permissions(format_executable: true) end ensure @@ -160,35 +160,35 @@ def assert_self_install_permissions(format_executable: false) :format_executable => format_executable, } Dir.chdir @tempdir do - Dir.mkdir 'bin' - Dir.mkdir 'data' + Dir.mkdir "bin" + Dir.mkdir "data" - File.write 'bin/foo', "#!/usr/bin/env ruby\n" - File.chmod 0755, 'bin/foo' + File.write "bin/foo", "#!/usr/bin/env ruby\n" + File.chmod 0755, "bin/foo" - File.write 'data/foo.txt', "blah\n" + File.write "data/foo.txt", "blah\n" spec_fetcher do |f| - f.gem 'foo', 1 do |s| - s.executables = ['foo'] + f.gem "foo", 1 do |s| + s.executables = ["foo"] s.files = %w[bin/foo data/foo.txt] end end - Gem.install 'foo', Gem::Requirement.default, options + Gem.install "foo", Gem::Requirement.default, options end prog_mode = (options[:prog_mode] & mask).to_s(8) dir_mode = (options[:dir_mode] & mask).to_s(8) data_mode = (options[:data_mode] & mask).to_s(8) - prog_name = 'foo' - prog_name = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'foo') if options[:format_executable] + prog_name = "foo" + prog_name = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "foo") if options[:format_executable] expected = { "bin/#{prog_name}" => prog_mode, - 'gems/foo-1' => dir_mode, - 'gems/foo-1/bin' => dir_mode, - 'gems/foo-1/data' => dir_mode, - 'gems/foo-1/bin/foo' => prog_mode, - 'gems/foo-1/data/foo.txt' => data_mode, + "gems/foo-1" => dir_mode, + "gems/foo-1/bin" => dir_mode, + "gems/foo-1/data" => dir_mode, + "gems/foo-1/bin/foo" => prog_mode, + "gems/foo-1/data/foo.txt" => data_mode, } # add Windows script expected["bin/#{prog_name}.bat"] = mask.to_s(8) if win_platform? @@ -200,7 +200,7 @@ def assert_self_install_permissions(format_executable: false) end assert_equal(expected, result) ensure - File.chmod(0755, *Dir.glob(@gemhome + '/gems/**/').map {|path| path.tap(&Gem::UNTAINT) }) + File.chmod(0755, *Dir.glob(@gemhome + "/gems/**/").map {|path| path.tap(&Gem::UNTAINT) }) end def test_require_missing @@ -222,57 +222,57 @@ def test_require_does_not_glob end def test_self_bin_path_active - a1 = util_spec 'a', '1' do |s| - s.executables = ['exec'] + a1 = util_spec "a", "1" do |s| + s.executables = ["exec"] end - util_spec 'a', '2' do |s| - s.executables = ['exec'] + util_spec "a", "2" do |s| + s.executables = ["exec"] end a1.activate - assert_match 'a-1/bin/exec', Gem.bin_path('a', 'exec', '>= 0') + assert_match "a-1/bin/exec", Gem.bin_path("a", "exec", ">= 0") end def test_self_bin_path_picking_newest - a1 = util_spec 'a', '1' do |s| - s.executables = ['exec'] + a1 = util_spec "a", "1" do |s| + s.executables = ["exec"] end - a2 = util_spec 'a', '2' do |s| - s.executables = ['exec'] + a2 = util_spec "a", "2" do |s| + s.executables = ["exec"] end install_specs a1, a2 - assert_match 'a-2/bin/exec', Gem.bin_path('a', 'exec', '>= 0') + assert_match "a-2/bin/exec", Gem.bin_path("a", "exec", ">= 0") end def test_self_activate_bin_path_no_exec_name e = assert_raise ArgumentError do - Gem.activate_bin_path 'a' + Gem.activate_bin_path "a" end - assert_equal 'you must supply exec_name', e.message + assert_equal "you must supply exec_name", e.message end def test_activate_bin_path_resolves_eagerly - a1 = util_spec 'a', '1' do |s| - s.executables = ['exec'] - s.add_dependency 'b' + a1 = util_spec "a", "1" do |s| + s.executables = ["exec"] + s.add_dependency "b" end - b1 = util_spec 'b', '1' do |s| - s.add_dependency 'c', '2' + b1 = util_spec "b", "1" do |s| + s.add_dependency "c", "2" end - b2 = util_spec 'b', '2' do |s| - s.add_dependency 'c', '1' + b2 = util_spec "b", "2" do |s| + s.add_dependency "c", "1" end - c1 = util_spec 'c', '1' - c2 = util_spec 'c', '2' + c1 = util_spec "c", "1" + c2 = util_spec "c", "2" install_specs c1, c2, b1, b2, a1 @@ -280,27 +280,27 @@ def test_activate_bin_path_resolves_eagerly # If we didn't eagerly resolve, this would activate c-2 and then the # finish_resolve would cause a conflict - gem 'c' + gem "c" Gem.finish_resolve assert_equal %w[a-1 b-2 c-1], loaded_spec_names end def test_activate_bin_path_does_not_error_if_a_gem_thats_not_finally_activated_has_orphaned_dependencies - a1 = util_spec 'a', '1' do |s| - s.executables = ['exec'] - s.add_dependency 'b' + a1 = util_spec "a", "1" do |s| + s.executables = ["exec"] + s.add_dependency "b" end - b1 = util_spec 'b', '1' do |s| - s.add_dependency 'c', '1' + b1 = util_spec "b", "1" do |s| + s.add_dependency "c", "1" end - b2 = util_spec 'b', '2' do |s| - s.add_dependency 'c', '2' + b2 = util_spec "b", "2" do |s| + s.add_dependency "c", "2" end - c2 = util_spec 'c', '2' + c2 = util_spec "c", "2" install_specs c2, b1, b2, a1 @@ -312,20 +312,20 @@ def test_activate_bin_path_does_not_error_if_a_gem_thats_not_finally_activated_h end def test_activate_bin_path_raises_a_meaningful_error_if_a_gem_thats_finally_activated_has_orphaned_dependencies - a1 = util_spec 'a', '1' do |s| - s.executables = ['exec'] - s.add_dependency 'b' + a1 = util_spec "a", "1" do |s| + s.executables = ["exec"] + s.add_dependency "b" end - b1 = util_spec 'b', '1' do |s| - s.add_dependency 'c', '1' + b1 = util_spec "b", "1" do |s| + s.add_dependency "c", "1" end - b2 = util_spec 'b', '2' do |s| - s.add_dependency 'c', '2' + b2 = util_spec "b", "2" do |s| + s.add_dependency "c", "2" end - c1 = util_spec 'c', '1' + c1 = util_spec "c", "1" install_specs c1, b1, b2, a1 @@ -339,8 +339,8 @@ def test_activate_bin_path_raises_a_meaningful_error_if_a_gem_thats_finally_acti end def test_activate_bin_path_in_debug_mode - a1 = util_spec 'a', '1' do |s| - s.executables = ['exec'] + a1 = util_spec "a", "1" do |s| + s.executables = ["exec"] end install_specs a1 @@ -355,12 +355,12 @@ def test_activate_bin_path_in_debug_mode end def test_activate_bin_path_selects_exact_bundler_version_if_present - bundler_latest = util_spec 'bundler', '2.0.1' do |s| - s.executables = ['bundle'] + bundler_latest = util_spec "bundler", "2.0.1" do |s| + s.executables = ["bundle"] end - bundler_previous = util_spec 'bundler', '2.0.0' do |s| - s.executables = ['bundle'] + bundler_previous = util_spec "bundler", "2.0.0" do |s| + s.executables = ["bundle"] end install_specs bundler_latest, bundler_previous @@ -389,12 +389,12 @@ def test_activate_bin_path_selects_exact_bundler_version_if_present end def test_activate_bin_path_respects_underscore_selection_if_given - bundler_latest = util_spec 'bundler', '2.0.1' do |s| - s.executables = ['bundle'] + bundler_latest = util_spec "bundler", "2.0.1" do |s| + s.executables = ["bundle"] end - bundler_previous = util_spec 'bundler', '1.17.3' do |s| - s.executables = ['bundle'] + bundler_previous = util_spec "bundler", "1.17.3" do |s| + s.executables = ["bundle"] end install_specs bundler_latest, bundler_previous @@ -450,57 +450,57 @@ def test_activate_bin_path_gives_proper_error_for_bundler_when_underscore_select def test_self_bin_path_no_exec_name e = assert_raise ArgumentError do - Gem.bin_path 'a' + Gem.bin_path "a" end - assert_equal 'you must supply exec_name', e.message + assert_equal "you must supply exec_name", e.message end def test_self_bin_path_bin_name install_specs util_exec_gem - assert_equal @abin_path, Gem.bin_path('a', 'abin') + assert_equal @abin_path, Gem.bin_path("a", "abin") end def test_self_bin_path_bin_name_version install_specs util_exec_gem - assert_equal @abin_path, Gem.bin_path('a', 'abin', '4') + assert_equal @abin_path, Gem.bin_path("a", "abin", "4") end def test_self_bin_path_nonexistent_binfile - util_spec 'a', '2' do |s| - s.executables = ['exec'] + util_spec "a", "2" do |s| + s.executables = ["exec"] end assert_raise(Gem::GemNotFoundException) do - Gem.bin_path('a', 'other', '2') + Gem.bin_path("a", "other", "2") end end def test_self_bin_path_no_bin_file - util_spec 'a', '1' + util_spec "a", "1" assert_raise(ArgumentError) do - Gem.bin_path('a', nil, '1') + Gem.bin_path("a", nil, "1") end end def test_self_bin_path_not_found assert_raise(Gem::GemNotFoundException) do - Gem.bin_path('non-existent', 'blah') + Gem.bin_path("non-existent", "blah") end end def test_self_bin_path_bin_file_gone_in_latest install_specs util_exec_gem - spec = util_spec 'a', '10' do |s| + spec = util_spec "a", "10" do |s| s.executables = [] end install_specs spec - assert_equal @abin_path, Gem.bin_path('a', 'abin') + assert_equal @abin_path, Gem.bin_path("a", "abin") end def test_self_bindir - assert_equal File.join(@gemhome, 'bin'), Gem.bindir - assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir) - assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Pathname.new(Gem.dir)) + assert_equal File.join(@gemhome, "bin"), Gem.bindir + assert_equal File.join(@gemhome, "bin"), Gem.bindir(Gem.dir) + assert_equal File.join(@gemhome, "bin"), Gem.bindir(Pathname.new(Gem.dir)) end def test_self_bindir_default_dir @@ -529,21 +529,21 @@ def test_self_datadir foo = nil Dir.chdir @tempdir do - FileUtils.mkdir_p 'data' - File.open File.join('data', 'foo.txt'), 'w' do |fp| - fp.puts 'blah' + FileUtils.mkdir_p "data" + File.open File.join("data", "foo.txt"), "w" do |fp| + fp.puts "blah" end - foo = util_spec 'foo' do |s| + foo = util_spec "foo" do |s| s.files = %w[data/foo.txt] end install_gem foo end - gem 'foo' + gem "foo" - expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo' + expected = File.join @gemhome, "gems", foo.full_name, "data", "foo" assert_equal expected, Gem::Specification.find_by_name("foo").datadir end @@ -555,25 +555,25 @@ def test_self_datadir_nonexistent_package end def test_self_default_exec_format - ruby_install_name 'ruby' do - assert_equal '%s', Gem.default_exec_format + ruby_install_name "ruby" do + assert_equal "%s", Gem.default_exec_format end end def test_self_default_exec_format_18 - ruby_install_name 'ruby18' do - assert_equal '%s18', Gem.default_exec_format + ruby_install_name "ruby18" do + assert_equal "%s18", Gem.default_exec_format end end def test_self_default_exec_format_jruby - ruby_install_name 'jruby' do - assert_equal 'j%s', Gem.default_exec_format + ruby_install_name "jruby" do + assert_equal "j%s", Gem.default_exec_format end end def test_default_path - vendordir(File.join(@tempdir, 'vendor')) do + vendordir(File.join(@tempdir, "vendor")) do FileUtils.rm_rf Gem.user_home expected = [Gem.default_dir] @@ -593,7 +593,7 @@ def test_default_path_missing_vendor end def test_default_path_user_home - vendordir(File.join(@tempdir, 'vendor')) do + vendordir(File.join(@tempdir, "vendor")) do expected = [Gem.user_dir, Gem.default_dir] assert_equal expected, Gem.default_path @@ -601,7 +601,7 @@ def test_default_path_user_home end def test_default_path_vendor_dir - vendordir(File.join(@tempdir, 'vendor')) do + vendordir(File.join(@tempdir, "vendor")) do FileUtils.mkdir_p Gem.vendor_dir FileUtils.rm_rf Gem.user_home @@ -617,14 +617,14 @@ def test_self_default_sources end def test_self_use_gemdeps - with_rubygems_gemdeps('-') do - FileUtils.mkdir_p 'detect/a/b' - FileUtils.mkdir_p 'detect/a/Isolate' + with_rubygems_gemdeps("-") do + FileUtils.mkdir_p "detect/a/b" + FileUtils.mkdir_p "detect/a/Isolate" - FileUtils.touch 'detect/Isolate' + FileUtils.touch "detect/Isolate" begin - Dir.chdir 'detect/a/b' + Dir.chdir "detect/a/b" Gem.use_gemdeps @@ -645,12 +645,12 @@ def test_self_ensure_gem_directories Gem.ensure_gem_subdirectories @gemhome - assert_path_exist File.join @gemhome, 'build_info' - assert_path_exist File.join @gemhome, 'cache' - assert_path_exist File.join @gemhome, 'doc' - assert_path_exist File.join @gemhome, 'extensions' - assert_path_exist File.join @gemhome, 'gems' - assert_path_exist File.join @gemhome, 'specifications' + assert_path_exist File.join @gemhome, "build_info" + assert_path_exist File.join @gemhome, "cache" + assert_path_exist File.join @gemhome, "doc" + assert_path_exist File.join @gemhome, "extensions" + assert_path_exist File.join @gemhome, "gems" + assert_path_exist File.join @gemhome, "specifications" end def test_self_ensure_gem_directories_permissions @@ -680,9 +680,9 @@ def test_self_ensure_gem_directories_safe_permissions end unless win_platform? def test_self_ensure_gem_directories_missing_parents - gemdir = File.join @tempdir, 'a/b/c/gemdir' - FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil - refute File.exist?(File.join(@tempdir, 'a')), + gemdir = File.join @tempdir, "a/b/c/gemdir" + FileUtils.rm_rf File.join(@tempdir, "a") rescue nil + refute File.exist?(File.join(@tempdir, "a")), "manually remove #{File.join @tempdir, 'a'}, tests are broken" Gem.use_paths gemdir @@ -725,19 +725,19 @@ def test_self_ensure_gem_directories_write_protected_parents end def test_self_ensure_gem_directories_non_existent_paths - Gem.ensure_gem_subdirectories '/proc/0123456789/bogus' # should not raise - Gem.ensure_gem_subdirectories 'classpath:/bogus/x' # JRuby embed scenario + Gem.ensure_gem_subdirectories "/proc/0123456789/bogus" # should not raise + Gem.ensure_gem_subdirectories "classpath:/bogus/x" # JRuby embed scenario end end def test_self_extension_dir_shared - enable_shared 'yes' do + enable_shared "yes" do assert_equal Gem.ruby_api_version, Gem.extension_api_version end end def test_self_extension_dir_static - enable_shared 'no' do + enable_shared "no" do assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version end end @@ -746,14 +746,14 @@ def test_self_find_files cwd = File.expand_path("test/rubygems", PROJECT_DIR) $LOAD_PATH.unshift cwd - discover_path = File.join 'lib', 'sff', 'discover.rb' + discover_path = File.join "lib", "sff", "discover.rb" foo1, foo2 = %w[1 2].map do |version| - spec = quick_gem 'sff', version do |s| + spec = quick_gem "sff", version do |s| s.files << discover_path end - write_file(File.join 'gems', spec.full_name, discover_path) do |fp| + write_file(File.join "gems", spec.full_name, discover_path) do |fp| fp.puts "# #{spec.full_name}" end @@ -763,13 +763,13 @@ def test_self_find_files Gem.refresh expected = [ - File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR), + File.expand_path("test/rubygems/sff/discover.rb", PROJECT_DIR), File.join(foo2.full_gem_path, discover_path), File.join(foo1.full_gem_path, discover_path), ] - assert_equal expected, Gem.find_files('sff/discover') - assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]' + assert_equal expected, Gem.find_files("sff/discover") + assert_equal expected, Gem.find_files("sff/**.rb"), "[ruby-core:31730]" ensure assert_equal cwd, $LOAD_PATH.shift end @@ -778,14 +778,14 @@ def test_self_find_files_with_gemfile cwd = File.expand_path("test/rubygems", PROJECT_DIR) actual_load_path = $LOAD_PATH.unshift(cwd).dup - discover_path = File.join 'lib', 'sff', 'discover.rb' + discover_path = File.join "lib", "sff", "discover.rb" foo1, _ = %w[1 2].map do |version| - spec = quick_gem 'sff', version do |s| + spec = quick_gem "sff", version do |s| s.files << discover_path end - write_file(File.join 'gems', spec.full_name, discover_path) do |fp| + write_file(File.join "gems", spec.full_name, discover_path) do |fp| fp.puts "# #{spec.full_name}" end @@ -793,19 +793,19 @@ def test_self_find_files_with_gemfile end Gem.refresh - write_file(File.join Dir.pwd, 'Gemfile') do |fp| + write_file(File.join Dir.pwd, "Gemfile") do |fp| fp.puts "source 'https://rubygems.org'" fp.puts "gem '#{foo1.name}', '#{foo1.version}'" end - Gem.use_gemdeps(File.join Dir.pwd, 'Gemfile') + Gem.use_gemdeps(File.join Dir.pwd, "Gemfile") expected = [ - File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR), + File.expand_path("test/rubygems/sff/discover.rb", PROJECT_DIR), File.join(foo1.full_gem_path, discover_path), ].sort - assert_equal expected, Gem.find_files('sff/discover').sort - assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]' + assert_equal expected, Gem.find_files("sff/discover").sort + assert_equal expected, Gem.find_files("sff/**.rb").sort, "[ruby-core:31730]" ensure assert_equal cwd, actual_load_path.shift unless Gem.java_platform? end @@ -814,14 +814,14 @@ def test_self_find_latest_files cwd = File.expand_path("test/rubygems", PROJECT_DIR) $LOAD_PATH.unshift cwd - discover_path = File.join 'lib', 'sff', 'discover.rb' + discover_path = File.join "lib", "sff", "discover.rb" _, foo2 = %w[1 2].map do |version| - spec = quick_gem 'sff', version do |s| + spec = quick_gem "sff", version do |s| s.files << discover_path end - write_file(File.join 'gems', spec.full_name, discover_path) do |fp| + write_file(File.join "gems", spec.full_name, discover_path) do |fp| fp.puts "# #{spec.full_name}" end @@ -831,30 +831,30 @@ def test_self_find_latest_files Gem.refresh expected = [ - File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR), + File.expand_path("test/rubygems/sff/discover.rb", PROJECT_DIR), File.join(foo2.full_gem_path, discover_path), ] - assert_equal expected, Gem.find_latest_files('sff/discover') - assert_equal expected, Gem.find_latest_files('sff/**.rb'), '[ruby-core:31730]' + assert_equal expected, Gem.find_latest_files("sff/discover") + assert_equal expected, Gem.find_latest_files("sff/**.rb"), "[ruby-core:31730]" ensure assert_equal cwd, $LOAD_PATH.shift end def test_self_latest_spec_for gems = spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '3.a' - fetcher.spec 'a', 2 + fetcher.spec "a", 1 + fetcher.spec "a", "3.a" + fetcher.spec "a", 2 end - spec = Gem.latest_spec_for 'a' + spec = Gem.latest_spec_for "a" - assert_equal gems['a-2'], spec + assert_equal gems["a-2"], spec end def test_self_latest_spec_for_multiple_sources - uri = 'https://example.sample.com/' + uri = "https://example.sample.com/" source = Gem::Source.new(uri) source_list = Gem::SourceList.new source_list << Gem::Source.new(@uri) @@ -862,44 +862,44 @@ def test_self_latest_spec_for_multiple_sources Gem.sources.replace source_list spec_fetcher(uri) do |fetcher| - fetcher.spec 'a', 1.1 + fetcher.spec "a", 1.1 end gems = spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '3.a' - fetcher.spec 'a', 2 + fetcher.spec "a", 1 + fetcher.spec "a", "3.a" + fetcher.spec "a", 2 end - spec = Gem.latest_spec_for 'a' - assert_equal gems['a-2'], spec + spec = Gem.latest_spec_for "a" + assert_equal gems["a-2"], spec end def test_self_latest_rubygems_version spec_fetcher do |fetcher| - fetcher.spec 'rubygems-update', '1.8.23' - fetcher.spec 'rubygems-update', '1.8.24' - fetcher.spec 'rubygems-update', '2.0.0.preview3' + fetcher.spec "rubygems-update", "1.8.23" + fetcher.spec "rubygems-update", "1.8.24" + fetcher.spec "rubygems-update", "2.0.0.preview3" end version = Gem.latest_rubygems_version - assert_equal Gem::Version.new('1.8.24'), version + assert_equal Gem::Version.new("1.8.24"), version end def test_self_latest_version_for spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" end - version = Gem.latest_version_for 'a' + version = Gem.latest_version_for "a" assert_equal Gem::Version.new(2), version end def test_self_latest_version_for_multiple_sources - uri = 'https://example.sample.com/' + uri = "https://example.sample.com/" source = Gem::Source.new(uri) source_list = Gem::SourceList.new source_list << Gem::Source.new(@uri) @@ -907,27 +907,27 @@ def test_self_latest_version_for_multiple_sources Gem.sources.replace source_list spec_fetcher(uri) do |fetcher| - fetcher.spec 'a', 1.1 + fetcher.spec "a", 1.1 end spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" end - version = Gem.latest_version_for 'a' + version = Gem.latest_version_for "a" assert_equal Gem::Version.new(2), version end def test_self_loaded_specs - foo = util_spec 'foo' + foo = util_spec "foo" install_gem foo foo.activate - assert_equal true, Gem.loaded_specs.keys.include?('foo') + assert_equal true, Gem.loaded_specs.keys.include?("foo") end def test_self_path @@ -947,7 +947,7 @@ def test_self_path_ENV_PATH path_count = Gem.path.size Gem.clear_paths - ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR) + ENV["GEM_PATH"] = @additional.join(File::PATH_SEPARATOR) assert_equal @additional, Gem.path[0,2] @@ -959,10 +959,10 @@ def test_self_path_ENV_PATH def test_self_path_duplicate Gem.clear_paths util_ensure_gem_dirs - dirs = @additional + [@gemhome] + [File.join(@tempdir, 'a')] + dirs = @additional + [@gemhome] + [File.join(@tempdir, "a")] - ENV['GEM_HOME'] = @gemhome - ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR + ENV["GEM_HOME"] = @gemhome + ENV["GEM_PATH"] = dirs.join File::PATH_SEPARATOR assert_equal @gemhome, Gem.dir @@ -974,8 +974,8 @@ def test_self_path_overlap Gem.clear_paths util_ensure_gem_dirs - ENV['GEM_HOME'] = @gemhome - ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR) + ENV["GEM_HOME"] = @gemhome + ENV["GEM_PATH"] = @additional.join(File::PATH_SEPARATOR) assert_equal @gemhome, Gem.dir @@ -992,38 +992,38 @@ def test_self_prefix end def test_self_prefix_libdir - orig_libdir = RbConfig::CONFIG['libdir'] - RbConfig::CONFIG['libdir'] = PROJECT_DIR + orig_libdir = RbConfig::CONFIG["libdir"] + RbConfig::CONFIG["libdir"] = PROJECT_DIR assert_nil Gem.prefix ensure - RbConfig::CONFIG['libdir'] = orig_libdir + RbConfig::CONFIG["libdir"] = orig_libdir end def test_self_prefix_sitelibdir - orig_sitelibdir = RbConfig::CONFIG['sitelibdir'] - RbConfig::CONFIG['sitelibdir'] = PROJECT_DIR + orig_sitelibdir = RbConfig::CONFIG["sitelibdir"] + RbConfig::CONFIG["sitelibdir"] = PROJECT_DIR assert_nil Gem.prefix ensure - RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir + RbConfig::CONFIG["sitelibdir"] = orig_sitelibdir end def test_self_read_binary - File.open 'test', 'w' do |io| + File.open "test", "w" do |io| io.write "\xCF\x80" end - assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a - pend 'chmod not supported' if Gem.win_platform? + pend "chmod not supported" if Gem.win_platform? begin - File.chmod 0444, 'test' + File.chmod 0444, "test" - assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a + assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a ensure - File.chmod 0644, 'test' + File.chmod 0644, "test" end end @@ -1084,72 +1084,72 @@ def test_self_ruby_path_without_spaces end def test_self_ruby_api_version - orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3' + orig_ruby_version, RbConfig::CONFIG["ruby_version"] = RbConfig::CONFIG["ruby_version"], "1.2.3" Gem.instance_variable_set :@ruby_api_version, nil - assert_equal '1.2.3', Gem.ruby_api_version + assert_equal "1.2.3", Gem.ruby_api_version ensure Gem.instance_variable_set :@ruby_api_version, nil - RbConfig::CONFIG['ruby_version'] = orig_ruby_version + RbConfig::CONFIG["ruby_version"] = orig_ruby_version end def test_self_env_requirement - ENV["GEM_REQUIREMENT_FOO"] = '>= 1.2.3' - ENV["GEM_REQUIREMENT_BAR"] = '1.2.3' - ENV["GEM_REQUIREMENT_BAZ"] = 'abcd' + ENV["GEM_REQUIREMENT_FOO"] = ">= 1.2.3" + ENV["GEM_REQUIREMENT_BAR"] = "1.2.3" + ENV["GEM_REQUIREMENT_BAZ"] = "abcd" - assert_equal Gem::Requirement.create('>= 1.2.3'), Gem.env_requirement('foo') - assert_equal Gem::Requirement.create('1.2.3'), Gem.env_requirement('bAr') - assert_raise(Gem::Requirement::BadRequirementError) { Gem.env_requirement('baz') } - assert_equal Gem::Requirement.default, Gem.env_requirement('qux') + assert_equal Gem::Requirement.create(">= 1.2.3"), Gem.env_requirement("foo") + assert_equal Gem::Requirement.create("1.2.3"), Gem.env_requirement("bAr") + assert_raise(Gem::Requirement::BadRequirementError) { Gem.env_requirement("baz") } + assert_equal Gem::Requirement.default, Gem.env_requirement("qux") end def test_self_ruby_version_with_non_mri_implementations - util_set_RUBY_VERSION '2.5.0', 0, 60928, 'jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]' + util_set_RUBY_VERSION "2.5.0", 0, 60928, "jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]" - assert_equal Gem::Version.new('2.5.0'), Gem.ruby_version + assert_equal Gem::Version.new("2.5.0"), Gem.ruby_version ensure util_restore_RUBY_VERSION end def test_self_ruby_version_with_svn_prerelease - util_set_RUBY_VERSION '2.6.0', -1, 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]' + util_set_RUBY_VERSION "2.6.0", -1, 63539, "ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]" - assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version + assert_equal Gem::Version.new("2.6.0.preview2"), Gem.ruby_version ensure util_restore_RUBY_VERSION end def test_self_ruby_version_with_git_prerelease - util_set_RUBY_VERSION '2.7.0', -1, 'b563439274a402e33541f5695b1bfd4ac1085638', 'ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]' + util_set_RUBY_VERSION "2.7.0", -1, "b563439274a402e33541f5695b1bfd4ac1085638", "ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]" - assert_equal Gem::Version.new('2.7.0.preview3'), Gem.ruby_version + assert_equal Gem::Version.new("2.7.0.preview3"), Gem.ruby_version ensure util_restore_RUBY_VERSION end def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility - util_set_RUBY_VERSION '2.6.0', -1, 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0' + util_set_RUBY_VERSION "2.6.0", -1, 63539, "weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]", "weirdjruby", "9.2.0.0" - assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version + assert_equal Gem::Version.new("2.6.0.preview2"), Gem.ruby_version ensure util_restore_RUBY_VERSION end def test_self_ruby_version_with_svn_trunk - util_set_RUBY_VERSION '1.9.2', -1, 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]' + util_set_RUBY_VERSION "1.9.2", -1, 23493, "ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]" - assert_equal Gem::Version.new('1.9.2.dev'), Gem.ruby_version + assert_equal Gem::Version.new("1.9.2.dev"), Gem.ruby_version ensure util_restore_RUBY_VERSION end def test_self_ruby_version_with_git_master - util_set_RUBY_VERSION '2.7.0', -1, '5de284ec78220e75643f89b454ce999da0c1c195', 'ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]' + util_set_RUBY_VERSION "2.7.0", -1, "5de284ec78220e75643f89b454ce999da0c1c195", "ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]" - assert_equal Gem::Version.new('2.7.0.dev'), Gem.ruby_version + assert_equal Gem::Version.new("2.7.0.dev"), Gem.ruby_version ensure util_restore_RUBY_VERSION end @@ -1159,7 +1159,7 @@ def test_self_rubygems_version end def test_self_paths_eq - other = File.join @tempdir, 'other' + other = File.join @tempdir, "other" path = [@userhome, other].join File::PATH_SEPARATOR # @@ -1172,12 +1172,12 @@ def test_self_paths_eq end def test_self_paths_eq_nonexistent_home - ENV['GEM_HOME'] = @gemhome + ENV["GEM_HOME"] = @gemhome Gem.clear_paths - other = File.join @tempdir, 'other' + other = File.join @tempdir, "other" - ENV['HOME'] = other + ENV["HOME"] = other Gem.paths = { "GEM_PATH" => other } @@ -1256,43 +1256,43 @@ def test_self_sources end def test_try_activate_returns_true_for_activated_specs - b = util_spec 'b', '1.0' do |spec| - spec.files << 'lib/b.rb' + b = util_spec "b", "1.0" do |spec| + spec.files << "lib/b.rb" end install_specs b - assert Gem.try_activate('b'), 'try_activate should return true' - assert Gem.try_activate('b'), 'try_activate should still return true' + assert Gem.try_activate("b"), "try_activate should return true" + assert Gem.try_activate("b"), "try_activate should still return true" end def test_spec_order_is_consistent - b1 = util_spec 'b', '1.0' - b2 = util_spec 'b', '2.0' - b3 = util_spec 'b', '3.0' + b1 = util_spec "b", "1.0" + b2 = util_spec "b", "2.0" + b3 = util_spec "b", "3.0" install_specs b1, b2, b3 - specs1 = Gem::Specification.stubs.find_all {|s| s.name == 'b' } + specs1 = Gem::Specification.stubs.find_all {|s| s.name == "b" } Gem::Specification.reset - specs2 = Gem::Specification.stubs_for('b') + specs2 = Gem::Specification.stubs_for("b") assert_equal specs1.map(&:version), specs2.map(&:version) end def test_self_try_activate_missing_dep - b = util_spec 'b', '1.0' - a = util_spec 'a', '1.0', 'b' => '>= 1.0' + b = util_spec "b", "1.0" + a = util_spec "a", "1.0", "b" => ">= 1.0" install_specs b, a uninstall_gem b - a_file = File.join a.gem_dir, 'lib', 'a_file.rb' + a_file = File.join a.gem_dir, "lib", "a_file.rb" write_file a_file do |io| - io.puts '# a_file.rb' + io.puts "# a_file.rb" end e = assert_raise Gem::MissingSpecError do - Gem.try_activate 'a_file' + Gem.try_activate "a_file" end assert_match %r{Could not find 'b' }, e.message @@ -1300,30 +1300,30 @@ def test_self_try_activate_missing_dep end def test_self_try_activate_missing_prerelease - b = util_spec 'b', '1.0rc1' - a = util_spec 'a', '1.0rc1', 'b' => '1.0rc1' + b = util_spec "b", "1.0rc1" + a = util_spec "a", "1.0rc1", "b" => "1.0rc1" install_specs b, a uninstall_gem b - a_file = File.join a.gem_dir, 'lib', 'a_file.rb' + a_file = File.join a.gem_dir, "lib", "a_file.rb" write_file a_file do |io| - io.puts '# a_file.rb' + io.puts "# a_file.rb" end e = assert_raise Gem::MissingSpecError do - Gem.try_activate 'a_file' + Gem.try_activate "a_file" end assert_match %r{Could not find 'b' \(= 1.0rc1\)}, e.message end def test_self_try_activate_missing_extensions - spec = util_spec 'ext', '1' do |s| + spec = util_spec "ext", "1" do |s| s.extensions = %w[ext/extconf.rb] s.mark_version - s.installed_by_version = v('2.2') + s.installed_by_version = v("2.2") end # write the spec without install to simulate a failed install @@ -1332,7 +1332,7 @@ def test_self_try_activate_missing_extensions end _, err = capture_output do - refute Gem.try_activate 'nonexistent' + refute Gem.try_activate "nonexistent" end unless Gem.java_platform? @@ -1344,43 +1344,43 @@ def test_self_try_activate_missing_extensions end def test_self_use_paths_with_nils - orig_home = ENV.delete 'GEM_HOME' - orig_path = ENV.delete 'GEM_PATH' + orig_home = ENV.delete "GEM_HOME" + orig_path = ENV.delete "GEM_PATH" Gem.use_paths nil, nil assert_equal Gem.default_dir, Gem.paths.home path = (Gem.default_path + [Gem.paths.home]).uniq assert_equal path, Gem.paths.path ensure - ENV['GEM_HOME'] = orig_home - ENV['GEM_PATH'] = orig_path + ENV["GEM_HOME"] = orig_home + ENV["GEM_PATH"] = orig_path end def test_setting_paths_does_not_warn_about_unknown_keys stdout, stderr = capture_output do - Gem.paths = { 'foo' => [], - 'bar' => Object.new, - 'GEM_HOME' => Gem.paths.home, - 'GEM_PATH' => 'foo' } + Gem.paths = { "foo" => [], + "bar" => Object.new, + "GEM_HOME" => Gem.paths.home, + "GEM_PATH" => "foo" } end - assert_equal ['foo', Gem.paths.home], Gem.paths.path - assert_equal '', stderr - assert_equal '', stdout + assert_equal ["foo", Gem.paths.home], Gem.paths.path + assert_equal "", stderr + assert_equal "", stdout end def test_setting_paths_does_not_mutate_parameter_object - Gem.paths = { 'GEM_HOME' => Gem.paths.home, - 'GEM_PATH' => 'foo' }.freeze - assert_equal ['foo', Gem.paths.home], Gem.paths.path + Gem.paths = { "GEM_HOME" => Gem.paths.home, + "GEM_PATH" => "foo" }.freeze + assert_equal ["foo", Gem.paths.home], Gem.paths.path end def test_deprecated_paths= stdout, stderr = capture_output do - Gem.paths = { 'GEM_HOME' => Gem.paths.home, - 'GEM_PATH' => [Gem.paths.home, 'foo'] } + Gem.paths = { "GEM_HOME" => Gem.paths.home, + "GEM_PATH" => [Gem.paths.home, "foo"] } end - assert_equal [Gem.paths.home, 'foo'], Gem.paths.path + assert_equal [Gem.paths.home, "foo"], Gem.paths.path assert_match(/Array values in the parameter to `Gem.paths=` are deprecated.\nPlease use a String or nil/m, stderr) - assert_equal '', stdout + assert_equal "", stdout end def test_self_use_paths @@ -1393,8 +1393,8 @@ def test_self_use_paths end def test_self_user_dir - parts = [@userhome, '.gem', Gem.ruby_engine] - parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty? + parts = [@userhome, ".gem", Gem.ruby_engine] + parts << RbConfig::CONFIG["ruby_version"] unless RbConfig::CONFIG["ruby_version"].empty? FileUtils.mkdir_p File.join(parts) @@ -1402,10 +1402,10 @@ def test_self_user_dir end def test_self_user_home - if ENV['HOME'] - assert_equal ENV['HOME'], Gem.user_home + if ENV["HOME"] + assert_equal ENV["HOME"], Gem.user_home else - assert true, 'count this test' + assert true, "count this test" end end @@ -1430,7 +1430,7 @@ def test_self_needs_picks_up_unresolved_deps a = util_spec "a", "1" b = util_spec "b", "1", "c" => nil c = util_spec "c", "2" - d = util_spec "d", "1", { 'e' => '= 1' }, "lib/d#{$$}.rb" + d = util_spec "d", "1", { "e" => "= 1" }, "lib/d#{$$}.rb" e = util_spec "e", "1" install_specs a, c, b, e, d @@ -1451,35 +1451,35 @@ def test_self_gunzip output = Gem::Util.gunzip input - assert_equal 'hello', output + assert_equal "hello", output assert_equal Encoding::BINARY, output.encoding end def test_self_gzip - input = 'hello' + input = "hello" output = Gem::Util.gzip input zipped = StringIO.new output - assert_equal 'hello', Zlib::GzipReader.new(zipped).read + assert_equal "hello", Zlib::GzipReader.new(zipped).read assert_equal Encoding::BINARY, output.encoding end def test_self_vendor_dir - vendordir(File.join(@tempdir, 'vendor')) do + vendordir(File.join(@tempdir, "vendor")) do expected = - File.join RbConfig::CONFIG['vendordir'], 'gems', - RbConfig::CONFIG['ruby_version'] + File.join RbConfig::CONFIG["vendordir"], "gems", + RbConfig::CONFIG["ruby_version"] assert_equal expected, Gem.vendor_dir end end def test_self_vendor_dir_ENV_GEM_VENDOR - ENV['GEM_VENDOR'] = File.join @tempdir, 'vendor', 'gems' + ENV["GEM_VENDOR"] = File.join @tempdir, "vendor", "gems" - assert_equal ENV['GEM_VENDOR'], Gem.vendor_dir + assert_equal ENV["GEM_VENDOR"], Gem.vendor_dir refute Gem.vendor_dir.frozen? end @@ -1493,18 +1493,18 @@ def test_load_plugins plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do - FileUtils.mkdir_p 'lib' + FileUtils.mkdir_p "lib" File.open plugin_path, "w" do |fp| fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end" end - foo1 = util_spec 'foo', '1' do |s| + foo1 = util_spec "foo", "1" do |s| s.files << plugin_path end install_gem foo1 - foo2 = util_spec 'foo', '2' do |s| + foo2 = util_spec "foo", "2" do |s| s.files << plugin_path end @@ -1513,7 +1513,7 @@ def test_load_plugins Gem::Specification.reset - gem 'foo' + gem "foo" Gem.load_plugins @@ -1524,12 +1524,12 @@ def test_load_user_installed_plugins plugin_path = File.join "lib", "rubygems_plugin.rb" Dir.chdir @tempdir do - FileUtils.mkdir_p 'lib' + FileUtils.mkdir_p "lib" File.open plugin_path, "w" do |fp| fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end" end - foo = util_spec 'foo', '1' do |s| + foo = util_spec "foo", "1" do |s| s.files << plugin_path end @@ -1538,7 +1538,7 @@ def test_load_user_installed_plugins Gem.paths = { "GEM_PATH" => [Gem.dir, Gem.user_dir].join(File::PATH_SEPARATOR) } - gem 'foo' + gem "foo" Gem.load_plugins @@ -1546,30 +1546,30 @@ def test_load_user_installed_plugins end def test_load_env_plugins - with_plugin('load') { Gem.load_env_plugins } + with_plugin("load") { Gem.load_env_plugins } assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil util_remove_interrupt_command # Should attempt to cause a StandardError - with_plugin('standarderror') { Gem.load_env_plugins } + with_plugin("standarderror") { Gem.load_env_plugins } assert_equal :loaded, TEST_PLUGIN_STANDARDERROR rescue nil util_remove_interrupt_command # Should attempt to cause an Exception - with_plugin('exception') { Gem.load_env_plugins } + with_plugin("exception") { Gem.load_env_plugins } assert_equal :loaded, TEST_PLUGIN_EXCEPTION rescue nil end def test_gem_path_ordering refute_equal Gem.dir, Gem.user_dir - write_file File.join(@tempdir, 'lib', "g.rb") {|fp| fp.puts "" } - write_file File.join(@tempdir, 'lib', 'm.rb') {|fp| fp.puts "" } + write_file File.join(@tempdir, "lib", "g.rb") {|fp| fp.puts "" } + write_file File.join(@tempdir, "lib", "m.rb") {|fp| fp.puts "" } - g = util_spec 'g', '1', nil, "lib/g.rb" - m = util_spec 'm', '1', nil, "lib/m.rb" + g = util_spec "g", "1", nil, "lib/g.rb" + m = util_spec "m", "1", nil, "lib/m.rb" install_gem g, :install_dir => Gem.dir m0 = install_gem m, :install_dir => Gem.dir @@ -1588,15 +1588,15 @@ def test_gem_path_ordering Gem::Specification.reset Gem.searcher = nil - assert_equal Gem::Dependency.new('m','1').to_specs, - Gem::Dependency.new('m','1').to_specs.sort + assert_equal Gem::Dependency.new("m","1").to_specs, + Gem::Dependency.new("m","1").to_specs.sort assert_equal \ [expected.gem_dir], - Gem::Dependency.new('m','1').to_specs.map(&:gem_dir).sort, + Gem::Dependency.new("m","1").to_specs.map(&:gem_dir).sort, "Wrong specs for #{_name}" - spec = Gem::Dependency.new('m','1').to_spec + spec = Gem::Dependency.new("m","1").to_spec assert_equal \ File.join(_paths.first, "gems", "m-1"), @@ -1606,7 +1606,7 @@ def test_gem_path_ordering gem "m" - spec = Gem::Dependency.new('m','1').to_spec + spec = Gem::Dependency.new("m","1").to_spec assert spec.activated?, "dependency not activated for #{_name}" assert_equal \ @@ -1621,11 +1621,11 @@ def test_gem_path_ordering end def test_gem_path_ordering_short - write_file File.join(@tempdir, 'lib', "g.rb") {|fp| fp.puts "" } - write_file File.join(@tempdir, 'lib', 'm.rb') {|fp| fp.puts "" } + write_file File.join(@tempdir, "lib", "g.rb") {|fp| fp.puts "" } + write_file File.join(@tempdir, "lib", "m.rb") {|fp| fp.puts "" } - g = util_spec 'g', '1', nil, "lib/g.rb" - m = util_spec 'm', '1', nil, "lib/m.rb" + g = util_spec "g", "1", nil, "lib/g.rb" + m = util_spec "m", "1", nil, "lib/m.rb" install_gem g, :install_dir => Gem.dir install_gem m, :install_dir => Gem.dir @@ -1635,7 +1635,7 @@ def test_gem_path_ordering_short assert_equal \ File.join(Gem.dir, "gems", "m-1"), - Gem::Dependency.new('m','1').to_spec.gem_dir, + Gem::Dependency.new("m","1").to_spec.gem_dir, "Wrong spec selected" end @@ -1702,7 +1702,7 @@ def test_looks_for_gemdeps_files_automatically_from_binstubs s.bindir = "exe" end - write_file File.join(@tempdir, 'exe', 'foo') do |fp| + write_file File.join(@tempdir, "exe", "foo") do |fp| fp.puts "puts Gem.loaded_specs.values.map(&:full_name).sort" end @@ -1716,7 +1716,7 @@ def test_looks_for_gemdeps_files_automatically_from_binstubs install_gem b, :install_dir => path install_gem c, :install_dir => path - ENV['GEM_PATH'] = path + ENV["GEM_PATH"] = path with_rubygems_gemdeps("-") do new_PATH = [File.join(path, "bin"), ENV["PATH"]].join(File::PATH_SEPARATOR) @@ -1751,7 +1751,7 @@ def test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir s.bindir = "exe" end - write_file File.join(@tempdir, 'exe', 'foo') do |fp| + write_file File.join(@tempdir, "exe", "foo") do |fp| fp.puts "puts Gem.loaded_specs.values.map(&:full_name).sort" end @@ -1765,7 +1765,7 @@ def test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir install_gem b, :install_dir => path install_gem c, :install_dir => path - ENV['GEM_PATH'] = path + ENV["GEM_PATH"] = path with_rubygems_gemdeps("-") do Dir.mkdir "sub1" @@ -1837,14 +1837,14 @@ def test_register_default_spec_old_style_with_folder_starting_with_lib end def test_use_gemdeps - gem_deps_file = 'gem.deps.rb'.tap(&Gem::UNTAINT) - spec = util_spec 'a', 1 + gem_deps_file = "gem.deps.rb".tap(&Gem::UNTAINT) + spec = util_spec "a", 1 install_specs spec spec = Gem::Specification.find {|s| s == spec } refute spec.activated? - File.open gem_deps_file, 'w' do |io| + File.open gem_deps_file, "w" do |io| io.write 'gem "a"' end @@ -1858,11 +1858,11 @@ def test_use_gemdeps def test_use_gemdeps_ENV with_rubygems_gemdeps(nil) do - spec = util_spec 'a', 1 + spec = util_spec "a", 1 refute spec.activated? - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.write 'gem "a"' end @@ -1874,33 +1874,33 @@ def test_use_gemdeps_ENV def test_use_gemdeps_argument_missing e = assert_raise ArgumentError do - Gem.use_gemdeps 'gem.deps.rb' + Gem.use_gemdeps "gem.deps.rb" end - assert_equal 'Unable to find gem dependencies file at gem.deps.rb', + assert_equal "Unable to find gem dependencies file at gem.deps.rb", e.message end def test_use_gemdeps_argument_missing_match_ENV - with_rubygems_gemdeps('gem.deps.rb') do + with_rubygems_gemdeps("gem.deps.rb") do e = assert_raise ArgumentError do - Gem.use_gemdeps 'gem.deps.rb' + Gem.use_gemdeps "gem.deps.rb" end - assert_equal 'Unable to find gem dependencies file at gem.deps.rb', + assert_equal "Unable to find gem dependencies file at gem.deps.rb", e.message end end def test_use_gemdeps_automatic - with_rubygems_gemdeps('-') do - spec = util_spec 'a', 1 + with_rubygems_gemdeps("-") do + spec = util_spec "a", 1 install_specs spec spec = Gem::Specification.find {|s| s == spec } refute spec.activated? - File.open 'Gemfile', 'w' do |io| + File.open "Gemfile", "w" do |io| io.write 'gem "a"' end @@ -1911,7 +1911,7 @@ def test_use_gemdeps_automatic end def test_use_gemdeps_automatic_missing - with_rubygems_gemdeps('-') do + with_rubygems_gemdeps("-") do Gem.use_gemdeps assert true # count @@ -1919,12 +1919,12 @@ def test_use_gemdeps_automatic_missing end def test_use_gemdeps_disabled - with_rubygems_gemdeps('') do - spec = util_spec 'a', 1 + with_rubygems_gemdeps("") do + spec = util_spec "a", 1 refute spec.activated? - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.write 'gem "a"' end @@ -1935,8 +1935,8 @@ def test_use_gemdeps_disabled end def test_use_gemdeps_missing_gem - with_rubygems_gemdeps('x') do - File.open 'x', 'w' do |io| + with_rubygems_gemdeps("x") do + File.open "x", "w" do |io| io.write 'gem "a"' end @@ -1957,14 +1957,14 @@ def test_use_gemdeps_missing_gem end def test_use_gemdeps_specific - with_rubygems_gemdeps('x') do - spec = util_spec 'a', 1 + with_rubygems_gemdeps("x") do + spec = util_spec "a", 1 install_specs spec spec = Gem::Specification.find {|s| s == spec } refute spec.activated? - File.open 'x', 'w' do |io| + File.open "x", "w" do |io| io.write 'gem "a"' end @@ -1991,8 +1991,8 @@ def test_platform_defaults # Ensure that `Gem.source_date_epoch` is consistent even if # $SOURCE_DATE_EPOCH has not been set. def test_default_source_date_epoch_doesnt_change - old_epoch = ENV['SOURCE_DATE_EPOCH'] - ENV['SOURCE_DATE_EPOCH'] = nil + old_epoch = ENV["SOURCE_DATE_EPOCH"] + ENV["SOURCE_DATE_EPOCH"] = nil # Unfortunately, there is no real way to test this aside from waiting # enough for `Time.now.to_i` to change -- which is a whole second. @@ -2003,23 +2003,23 @@ def test_default_source_date_epoch_doesnt_change b = Gem.source_date_epoch assert_equal a, b ensure - ENV['SOURCE_DATE_EPOCH'] = old_epoch + ENV["SOURCE_DATE_EPOCH"] = old_epoch end private def ruby_install_name(name) with_clean_path_to_ruby do - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = name + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["ruby_install_name"] = name begin yield ensure if orig_RUBY_INSTALL_NAME - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME + RbConfig::CONFIG["ruby_install_name"] = orig_RUBY_INSTALL_NAME else - RbConfig::CONFIG.delete 'ruby_install_name' + RbConfig::CONFIG.delete "ruby_install_name" end end end @@ -2074,12 +2074,12 @@ def util_ensure_gem_dirs end def util_exec_gem - spec, _ = util_spec 'a', '4' do |s| - s.executables = ['exec', 'abin'] + spec, _ = util_spec "a", "4" do |s| + s.executables = ["exec", "abin"] end - @exec_path = File.join spec.full_gem_path, spec.bindir, 'exec' - @abin_path = File.join spec.full_gem_path, spec.bindir, 'abin' + @exec_path = File.join spec.full_gem_path, spec.bindir, "exec" + @abin_path = File.join spec.full_gem_path, spec.bindir, "abin" spec end @@ -2093,20 +2093,20 @@ def util_cache_dir end def with_path_and_rubyopt(path_value, rubyopt_value) - path, ENV['PATH'] = ENV['PATH'], path_value - rubyopt, ENV['RUBYOPT'] = ENV['RUBYOPT'], rubyopt_value + path, ENV["PATH"] = ENV["PATH"], path_value + rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], rubyopt_value yield ensure - ENV['PATH'] = path - ENV['RUBYOPT'] = rubyopt + ENV["PATH"] = path + ENV["RUBYOPT"] = rubyopt end def with_rubygems_gemdeps(value) - rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], value + rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], value yield ensure - ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps + ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps end end diff --git a/test/rubygems/test_gem_available_set.rb b/test/rubygems/test_gem_available_set.rb index c4164d77f210..576f3f42212f 100644 --- a/test/rubygems/test_gem_available_set.rb +++ b/test/rubygems/test_gem_available_set.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/available_set' -require 'rubygems/security' +require_relative "helper" +require "rubygems/available_set" +require "rubygems/security" class TestGemAvailableSet < Gem::TestCase def setup @@ -11,7 +11,7 @@ def setup end def test_add_and_empty - a1, _ = util_gem 'a', '1' + a1, _ = util_gem "a", "1" set = Gem::AvailableSet.new assert set.empty? @@ -24,8 +24,8 @@ def test_add_and_empty end def test_find_all - a1, a1_gem = util_gem 'a', 1 - a1a, a1a_gem = util_gem 'a', '1.a' + a1, a1_gem = util_gem "a", 1 + a1a, a1a_gem = util_gem "a", "1.a" a1_source = Gem::Source::SpecificFile.new a1_gem a1a_source = Gem::Source::SpecificFile.new a1a_gem @@ -34,26 +34,26 @@ def test_find_all set.add a1, a1_source set.add a1a, a1a_source - dep = Gem::Resolver::DependencyRequest.new dep('a'), nil + dep = Gem::Resolver::DependencyRequest.new dep("a"), nil assert_equal %w[a-1], set.find_all(dep).map {|spec| spec.full_name } - dep = Gem::Resolver::DependencyRequest.new dep('a', '>= 0.a'), nil + dep = Gem::Resolver::DependencyRequest.new dep("a", ">= 0.a"), nil assert_equal %w[a-1 a-1.a], set.find_all(dep).map {|spec| spec.full_name }.sort end def test_match_platform - a1, _ = util_gem 'a', '1' do |g| + a1, _ = util_gem "a", "1" do |g| g.platform = "something-weird-yep" end - a1c, _ = util_gem 'a', '2' do |g| + a1c, _ = util_gem "a", "2" do |g| g.platform = Gem::Platform.local end - a2, _ = util_gem 'a', '2' + a2, _ = util_gem "a", "2" set = Gem::AvailableSet.new set.add a1, @source @@ -66,8 +66,8 @@ def test_match_platform end def test_best - a1, _ = util_gem 'a', '1' - a2, _ = util_gem 'a', '2' + a1, _ = util_gem "a", "1" + a2, _ = util_gem "a", "2" set = Gem::AvailableSet.new set.add a1, @source @@ -79,7 +79,7 @@ def test_best end def test_remove_installed_bang - a1, _ = util_spec 'a', '1' + a1, _ = util_spec "a", "1" install_specs a1 a1.activate @@ -95,8 +95,8 @@ def test_remove_installed_bang end def test_sorted_normal_versions - a1, _ = util_gem 'a', '1' - a2, _ = util_gem 'a', '2' + a1, _ = util_gem "a", "1" + a2, _ = util_gem "a", "2" set = Gem::AvailableSet.new set.add a1, @source @@ -109,11 +109,11 @@ def test_sorted_normal_versions end def test_sorted_respect_pre - a1a, _ = util_gem 'a', '1.a' - a1, _ = util_gem 'a', '1' - a2a, _ = util_gem 'a', '2.a' - a2, _ = util_gem 'a', '2' - a3a, _ = util_gem 'a', '3.a' + a1a, _ = util_gem "a", "1.a" + a1, _ = util_gem "a", "1" + a2a, _ = util_gem "a", "2.a" + a2, _ = util_gem "a", "2" + a3a, _ = util_gem "a", "3.a" set = Gem::AvailableSet.new set.add a1, @source diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb index 7494a94d6e8e..0e21e460f69b 100644 --- a/test/rubygems/test_gem_bundler_version_finder.rb +++ b/test/rubygems/test_gem_bundler_version_finder.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemBundlerVersionFinder < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb index 65b9b040b77e..99fa89364dca 100644 --- a/test/rubygems/test_gem_command.rb +++ b/test/rubygems/test_gem_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/command' +require_relative "helper" +require "rubygems/command" class Gem::Command public :parser @@ -15,13 +15,13 @@ def setup @common_options = Gem::Command.common_options.dup Gem::Command.common_options.clear Gem::Command.common_options << [ - ['-x', '--exe', 'Execute'], lambda do |*a| + ["-x", "--exe", "Execute"], lambda do |*a| @xopt = true end ] - @cmd_name = 'doit' - @cmd = Gem::Command.new @cmd_name, 'summary' + @cmd_name = "doit" + @cmd = Gem::Command.new @cmd_name, "summary" end def teardown @@ -31,7 +31,7 @@ def teardown def test_self_add_specific_extra_args added_args = %w[--all] - @cmd.add_option('--all') {|v,o| } + @cmd.add_option("--all") {|v,o| } Gem::Command.add_specific_extra_args @cmd_name, added_args @@ -86,7 +86,7 @@ def test_common_option_in_class end def test_defaults - @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options| + @cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options| options[:help] = value end @@ -119,7 +119,7 @@ def test_invoke_with_bad_options @cmd.when_invoked { true } ex = assert_raise Gem::OptionParser::InvalidOption do - @cmd.invoke('-zzz') + @cmd.invoke("-zzz") end assert_match(/invalid option:/, ex.message) @@ -151,12 +151,12 @@ def test_invoke_with_help done = false use_ui @ui do - @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options| + @cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options| options[:help] = true done = true end - @cmd.invoke('--help') + @cmd.invoke("--help") assert done end @@ -174,7 +174,7 @@ def test_invoke_with_help end def test_invoke_with_options - @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options| + @cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options| options[:help] = true end @@ -183,7 +183,7 @@ def test_invoke_with_options end use_ui @ui do - @cmd.invoke '-h' + @cmd.invoke "-h" end assert_match %r{Usage: gem doit}, @ui.output @@ -191,40 +191,40 @@ def test_invoke_with_options def test_add_option assert_nothing_raised RuntimeError do - @cmd.add_option('--force', 'skip validation of the spec') {|v,o| } + @cmd.add_option("--force", "skip validation of the spec") {|v,o| } end end def test_add_option_with_empty assert_raise RuntimeError, "Do not pass an empty string in opts" do - @cmd.add_option('', 'skip validation of the spec') {|v,o| } + @cmd.add_option("", "skip validation of the spec") {|v,o| } end end def test_option_recognition - @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options| + @cmd.add_option("-h", "--help [COMMAND]", "Get help on COMMAND") do |value, options| options[:help] = true end - @cmd.add_option('-f', '--file FILE', 'File option') do |value, options| + @cmd.add_option("-f", "--file FILE", "File option") do |value, options| options[:help] = true end - @cmd.add_option('--silent', 'Silence RubyGems output') do |value, options| + @cmd.add_option("--silent", "Silence RubyGems output") do |value, options| options[:silent] = true end - assert @cmd.handles?(['-x']) - assert @cmd.handles?(['-h']) - assert @cmd.handles?(['-h', 'command']) - assert @cmd.handles?(['--help', 'command']) - assert @cmd.handles?(['-f', 'filename']) - assert @cmd.handles?(['--file=filename']) - assert @cmd.handles?(['--silent']) - refute @cmd.handles?(['-z']) - refute @cmd.handles?(['-f']) - refute @cmd.handles?(['--toothpaste']) - - args = ['-h', 'command'] + assert @cmd.handles?(["-x"]) + assert @cmd.handles?(["-h"]) + assert @cmd.handles?(["-h", "command"]) + assert @cmd.handles?(["--help", "command"]) + assert @cmd.handles?(["-f", "filename"]) + assert @cmd.handles?(["--file=filename"]) + assert @cmd.handles?(["--silent"]) + refute @cmd.handles?(["-z"]) + refute @cmd.handles?(["-f"]) + refute @cmd.handles?(["--toothpaste"]) + + args = ["-h", "command"] @cmd.handles?(args) - assert_equal ['-h', 'command'], args + assert_equal ["-h", "command"], args end def test_deprecate_option @@ -234,13 +234,13 @@ def test_deprecate_option testCommand = Class.new(Gem::Command) do def initialize - super('test', 'Gem::Command instance for testing') + super("test", "Gem::Command instance for testing") - add_option('-t', '--test', 'Test command') do |value, options| + add_option("-t", "--test", "Test command") do |value, options| options[:test] = true end - deprecate_option('--test', version: '3.1') + deprecate_option("--test", version: "3.1") end def execute @@ -263,13 +263,13 @@ def test_deprecate_option_no_version testCommand = Class.new(Gem::Command) do def initialize - super('test', 'Gem::Command instance for testing') + super("test", "Gem::Command instance for testing") - add_option('-t', '--test', 'Test command') do |value, options| + add_option("-t", "--test", "Test command") do |value, options| options[:test] = true end - deprecate_option('--test') + deprecate_option("--test") end def execute @@ -292,13 +292,13 @@ def test_deprecate_option_extra_message testCommand = Class.new(Gem::Command) do def initialize - super('test', 'Gem::Command instance for testing') + super("test", "Gem::Command instance for testing") - add_option('-t', '--test', 'Test command') do |value, options| + add_option("-t", "--test", "Test command") do |value, options| options[:test] = true end - deprecate_option('--test', version: '3.1', extra_msg: 'Whether you set `--test` mode or not, this dummy app always runs in test mode.') + deprecate_option("--test", version: "3.1", extra_msg: "Whether you set `--test` mode or not, this dummy app always runs in test mode.") end def execute @@ -321,13 +321,13 @@ def test_deprecate_option_extra_message_and_no_version testCommand = Class.new(Gem::Command) do def initialize - super('test', 'Gem::Command instance for testing') + super("test", "Gem::Command instance for testing") - add_option('-t', '--test', 'Test command') do |value, options| + add_option("-t", "--test", "Test command") do |value, options| options[:test] = true end - deprecate_option('--test', extra_msg: 'Whether you set `--test` mode or not, this dummy app always runs in test mode.') + deprecate_option("--test", extra_msg: "Whether you set `--test` mode or not, this dummy app always runs in test mode.") end def execute @@ -364,11 +364,11 @@ def test_show_lookup_failure_suggestions_local def test_show_lookup_failure_suggestions_none spec_fetcher do |fetcher| - fetcher.spec 'correct', 2 + fetcher.spec "correct", 2 end use_ui @ui do - @cmd.show_lookup_failure 'other', Gem::Requirement.default, [], :remote + @cmd.show_lookup_failure "other", Gem::Requirement.default, [], :remote end expected = <<-EXPECTED diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb index 00197d10f7b3..b8f35192ae2f 100644 --- a/test/rubygems/test_gem_command_manager.rb +++ b/test/rubygems/test_gem_command_manager.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/command_manager' +require_relative "helper" +require "rubygems/command_manager" class TestGemCommandManager < Gem::TestCase - PROJECT_DIR = File.expand_path('../..', __dir__).tap(&Gem::UNTAINT) + PROJECT_DIR = File.expand_path("../..", __dir__).tap(&Gem::UNTAINT) def setup super @@ -12,38 +12,38 @@ def setup end def test_find_command - command = @command_manager.find_command 'install' + command = @command_manager.find_command "install" assert_kind_of Gem::Commands::InstallCommand, command - command = @command_manager.find_command 'ins' + command = @command_manager.find_command "ins" assert_kind_of Gem::Commands::InstallCommand, command end def test_find_command_ambiguous e = assert_raise Gem::CommandLineError do - @command_manager.find_command 'u' + @command_manager.find_command "u" end - assert_equal 'Ambiguous command u matches [uninstall, unpack, update]', + assert_equal "Ambiguous command u matches [uninstall, unpack, update]", e.message end def test_find_alias_command - command = @command_manager.find_command 'i' + command = @command_manager.find_command "i" assert_kind_of Gem::Commands::InstallCommand, command end def test_find_login_alias_command - command = @command_manager.find_command 'login' + command = @command_manager.find_command "login" assert_kind_of Gem::Commands::SigninCommand, command end def test_find_logout_alias_comamnd - command = @command_manager.find_command 'logout' + command = @command_manager.find_command "logout" assert_kind_of Gem::Commands::SignoutCommand, command end @@ -54,7 +54,7 @@ def test_find_command_ambiguous_exact @command_manager.register_command :ins - command = @command_manager.find_command 'ins' + command = @command_manager.find_command "ins" assert_kind_of ins_command, command ensure @@ -63,18 +63,18 @@ def test_find_command_ambiguous_exact def test_find_command_unknown e = assert_raise Gem::UnknownCommandError do - @command_manager.find_command 'xyz' + @command_manager.find_command "xyz" end - assert_equal 'Unknown command xyz', e.message + assert_equal "Unknown command xyz", e.message end def test_find_command_unknown_suggestions e = assert_raise Gem::UnknownCommandError do - @command_manager.find_command 'pish' + @command_manager.find_command "pish" end - message = 'Unknown command pish'.dup + message = "Unknown command pish".dup if RUBY_VERSION >= "2.4" && defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable) message << "\nDid you mean? \"push\"" @@ -100,7 +100,7 @@ def test_run_interrupt assert_raise Gem::MockGemUi::TermError do @command_manager.run %w[interrupt] end - assert_equal '', ui.output + assert_equal "", ui.output assert_equal "ERROR: Interrupted\n", ui.error end ensure @@ -117,7 +117,7 @@ def test_run_crash_command assert_raise Gem::MockGemUi::TermError do @command_manager.run %w[crash] end - assert_equal '', ui.output + assert_equal "", ui.output err = ui.error.split("\n").first assert_equal "ERROR: Loading command: crash (RuntimeError)", err end @@ -141,7 +141,7 @@ def test_process_args_install #capture all install options use_ui @ui do check_options = nil - @command_manager['install'].when_invoked do |options| + @command_manager["install"].when_invoked do |options| check_options = options true end @@ -166,7 +166,7 @@ def test_process_args_install assert_equal true, check_options[:force] assert_equal :local, check_options[:domain] assert_equal false, check_options[:wrappers] - assert_equal Gem::Requirement.new('3.0'), check_options[:version] + assert_equal Gem::Requirement.new("3.0"), check_options[:version] assert_equal Dir.pwd, check_options[:install_dir] assert_equal Dir.pwd, check_options[:bin_dir] @@ -191,7 +191,7 @@ def test_process_args_install def test_process_args_uninstall #capture all uninstall options check_options = nil - @command_manager['uninstall'].when_invoked do |options| + @command_manager["uninstall"].when_invoked do |options| check_options = options true end @@ -204,14 +204,14 @@ def test_process_args_uninstall check_options = nil @command_manager.process_args %w[uninstall foobar --version 3.0] assert_equal "foobar", check_options[:args].first - assert_equal Gem::Requirement.new('3.0'), check_options[:version] + assert_equal Gem::Requirement.new("3.0"), check_options[:version] end # HACK move to check command test def test_process_args_check #capture all check options check_options = nil - @command_manager['check'].when_invoked do |options| + @command_manager["check"].when_invoked do |options| check_options = options true end @@ -230,7 +230,7 @@ def test_process_args_check def test_process_args_build #capture all build options check_options = nil - @command_manager['build'].when_invoked do |options| + @command_manager["build"].when_invoked do |options| check_options = options true end @@ -242,14 +242,14 @@ def test_process_args_build #check settings check_options = nil @command_manager.process_args %w[build foobar.rb] - assert_equal 'foobar.rb', check_options[:args].first + assert_equal "foobar.rb", check_options[:args].first end # HACK move to query command test def test_process_args_query #capture all query options check_options = nil - @command_manager['query'].when_invoked do |options| + @command_manager["query"].when_invoked do |options| check_options = options true end @@ -290,25 +290,25 @@ def test_process_args_query def test_process_args_update #capture all update options check_options = nil - @command_manager['update'].when_invoked do |options| + @command_manager["update"].when_invoked do |options| check_options = options true end #check defaults @command_manager.process_args %w[update] - assert_includes check_options[:document], 'ri' + assert_includes check_options[:document], "ri" #check settings check_options = nil @command_manager.process_args %w[update --force --document=ri --install-dir .] - assert_includes check_options[:document], 'ri' + assert_includes check_options[:document], "ri" assert_equal true, check_options[:force] assert_equal Dir.pwd, check_options[:install_dir] end def test_deprecated_command - require 'rubygems/command' + require "rubygems/command" foo_command = Class.new(Gem::Command) do extend Gem::Deprecate diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index 1304beb58060..1edb30f221fd 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -1,32 +1,32 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/build_command' -require 'rubygems/package' +require_relative "helper" +require "rubygems/commands/build_command" +require "rubygems/package" class TestGemCommandsBuildCommand < Gem::TestCase - CERT_FILE = cert_path 'public3072' - SIGNING_KEY = key_path 'private3072' + CERT_FILE = cert_path "public3072" + SIGNING_KEY = key_path "private3072" - EXPIRED_CERT_FILE = cert_path 'expired' - PRIVATE_KEY_FILE = key_path 'private' + EXPIRED_CERT_FILE = cert_path "expired" + PRIVATE_KEY_FILE = key_path "private" def setup super - readme_file = File.join(@tempdir, 'README.md') + readme_file = File.join(@tempdir, "README.md") begin umask_orig = File.umask(2) - File.open readme_file, 'w' do |f| - f.write 'My awesome gem' + File.open readme_file, "w" do |f| + f.write "My awesome gem" end ensure File.umask(umask_orig) end - @gem = util_spec 'some_gem' do |s| - s.license = 'AGPL-3.0' - s.files = ['README.md'] + @gem = util_spec "some_gem" do |s| + s.license = "AGPL-3.0" + s.files = ["README.md"] end @cmd = Gem::Commands::BuildCommand.new @@ -44,7 +44,7 @@ def test_handle_options def test_options_filename gemspec_file = File.join(@tempdir, @gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -79,7 +79,7 @@ def test_handle_options_defaults def test_execute gemspec_file = File.join(@tempdir, @gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -91,7 +91,7 @@ def test_execute def test_execute_platform gemspec_file = File.join(@tempdir, @gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -110,15 +110,15 @@ def test_execute_platform def test_execute_bad_name [".", "-", "_"].each do |special_char| - gem = util_spec 'some_gem_with_bad_name' do |s| + gem = util_spec "some_gem_with_bad_name" do |s| s.name = "#{special_char}bad_gem_name" - s.license = 'AGPL-3.0' - s.files = ['README.md'] + s.license = "AGPL-3.0" + s.files = ["README.md"] end gemspec_file = File.join(@tempdir, gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write gem.to_ruby end @@ -137,7 +137,7 @@ def test_execute_bad_name def test_execute_strict_without_warnings gemspec_file = File.join(@tempdir, @gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -165,13 +165,13 @@ def test_execute_rubyforge_project_warning end def test_execute_strict_with_warnings - bad_gem = util_spec 'some_bad_gem' do |s| - s.files = ['README.md'] + bad_gem = util_spec "some_bad_gem" do |s| + s.files = ["README.md"] end gemspec_file = File.join(@tempdir, bad_gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write bad_gem.to_ruby end @@ -201,7 +201,7 @@ def test_execute_bad_spec gemspec_file = File.join(@tempdir, @gem.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby.sub(/11-08/, "11-8") end @@ -218,7 +218,7 @@ def test_execute_bad_spec assert_equal "", out assert_match(/invalid date format in specification/, err) - assert_equal '', @ui.output + assert_equal "", @ui.output assert_equal "ERROR: Error loading gemspec. Aborting.\n", @ui.error end @@ -230,22 +230,22 @@ def test_execute_missing_file end end - assert_equal '', @ui.output + assert_equal "", @ui.output assert_equal "ERROR: Couldn't find a gemspec file matching 'some_gem' in #{@tempdir}\n", @ui.error end def test_execute_outside_dir - gemspec_dir = File.join @tempdir, 'build_command_gem' + gemspec_dir = File.join @tempdir, "build_command_gem" gemspec_file = File.join gemspec_dir, @gem.spec_name - readme_file = File.join gemspec_dir, 'README.md' + readme_file = File.join gemspec_dir, "README.md" FileUtils.mkdir_p gemspec_dir - File.open readme_file, 'w' do |f| + File.open readme_file, "w" do |f| f.write "My awesome gem" end - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -273,17 +273,17 @@ def test_execute_outside_dir end def test_execute_outside_dir_with_glob_argument - gemspec_dir = File.join @tempdir, 'build_command_gem' + gemspec_dir = File.join @tempdir, "build_command_gem" gemspec_file = File.join gemspec_dir, @gem.spec_name - readme_file = File.join gemspec_dir, 'README.md' + readme_file = File.join gemspec_dir, "README.md" FileUtils.mkdir_p gemspec_dir - File.open readme_file, 'w' do |f| + File.open readme_file, "w" do |f| f.write "My awesome gem" end - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -311,17 +311,17 @@ def test_execute_outside_dir_with_glob_argument end def test_execute_outside_dir_no_gemspec_present - gemspec_dir = File.join @tempdir, 'build_command_gem' + gemspec_dir = File.join @tempdir, "build_command_gem" gemspec_file = File.join @tempdir, @gem.spec_name - readme_file = File.join gemspec_dir, 'README.md' + readme_file = File.join gemspec_dir, "README.md" FileUtils.mkdir_p gemspec_dir - File.open readme_file, 'w' do |f| + File.open readme_file, "w" do |f| f.write "My awesome gem" end - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -342,14 +342,14 @@ def test_execute_outside_dir_no_gemspec_present end def test_execute_outside_dir_without_gem_name - gemspec_dir = File.join(@tempdir, 'build_command_gem') + gemspec_dir = File.join(@tempdir, "build_command_gem") gemspec_file = File.join(gemspec_dir, @gem.spec_name) - readme_file = File.join gemspec_dir, 'README.md' + readme_file = File.join gemspec_dir, "README.md" FileUtils.mkdir_p(gemspec_dir) - File.open readme_file, 'w' do |f| + File.open readme_file, "w" do |f| f.write "My awesome gem" end @@ -383,20 +383,20 @@ def test_execute_outside_dir_without_gem_name end def test_execute_outside_dir_with_external_gemspec - gemspec_dir = File.join @tempdir, 'gemspec_dir' + gemspec_dir = File.join @tempdir, "gemspec_dir" gemspec_file = File.join gemspec_dir, @gem.spec_name - gemcode_dir = File.join @tempdir, 'build_command_gem' - readme_file = File.join gemcode_dir, 'README.md' + gemcode_dir = File.join @tempdir, "build_command_gem" + readme_file = File.join gemcode_dir, "README.md" FileUtils.mkdir_p gemspec_dir FileUtils.mkdir_p gemcode_dir - File.open readme_file, 'w' do |f| + File.open readme_file, "w" do |f| f.write "My awesome gem in nested directory" end - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -424,20 +424,20 @@ def test_execute_outside_dir_with_external_gemspec end def test_execute_outside_dir_with_external_relative_gemspec - gemspec_dir = File.join @tempdir, 'gemspec_dir' + gemspec_dir = File.join @tempdir, "gemspec_dir" gemspec_file = File.join gemspec_dir, @gem.spec_name - gemcode_dir = File.join @tempdir, 'build_command_gem' - readme_file = File.join gemcode_dir, 'README.md' + gemcode_dir = File.join @tempdir, "build_command_gem" + readme_file = File.join gemcode_dir, "README.md" FileUtils.mkdir_p gemspec_dir FileUtils.mkdir_p gemcode_dir - File.open readme_file, 'w' do |f| + File.open readme_file, "w" do |f| f.write "My awesome gem in nested directory" end - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -467,7 +467,7 @@ def test_execute_outside_dir_with_external_relative_gemspec def test_can_find_gemspecs_without_dot_gemspec gemspec_file = File.join(@tempdir, @gem.name) - File.open gemspec_file + ".gemspec", 'w' do |gs| + File.open gemspec_file + ".gemspec", "w" do |gs| gs.write @gem.to_ruby end @@ -571,7 +571,7 @@ def test_execute_force @gem.send :remove_instance_variable, :@rubygems_version - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write @gem.to_ruby end @@ -582,18 +582,18 @@ def test_execute_force end def test_build_signed_gem - pend 'openssl is missing' unless Gem::HAVE_OPENSSL && !java_platform? + pend "openssl is missing" unless Gem::HAVE_OPENSSL && !java_platform? trust_dir = Gem::Security.trust_dir - spec = util_spec 'some_gem' do |s| + spec = util_spec "some_gem" do |s| s.signing_key = SIGNING_KEY s.cert_chain = [CERT_FILE] end gemspec_file = File.join(@tempdir, spec.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write spec.to_ruby end @@ -609,7 +609,7 @@ def test_build_signed_gem end def test_build_signed_gem_with_cert_expiration_length_days - pend 'openssl is missing' unless Gem::HAVE_OPENSSL && !java_platform? + pend "openssl is missing" unless Gem::HAVE_OPENSSL && !java_platform? gem_path = File.join Gem.user_home, ".gem" Dir.mkdir gem_path @@ -622,14 +622,14 @@ def test_build_signed_gem_with_cert_expiration_length_days tmp_private_key_file = File.join gem_path, "gem-private_key.pem" File.write(tmp_private_key_file, File.read(PRIVATE_KEY_FILE)) - spec = util_spec 'some_gem' do |s| + spec = util_spec "some_gem" do |s| s.signing_key = tmp_private_key_file s.cert_chain = [tmp_expired_cert_file] end gemspec_file = File.join(@tempdir, spec.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write spec.to_ruby end @@ -653,7 +653,7 @@ def test_build_signed_gem_with_cert_expiration_length_days end def test_build_auto_resign_cert - pend 'openssl is missing' unless Gem::HAVE_OPENSSL && !java_platform? + pend "openssl is missing" unless Gem::HAVE_OPENSSL && !java_platform? gem_path = File.join Gem.user_home, ".gem" Dir.mkdir gem_path @@ -666,14 +666,14 @@ def test_build_auto_resign_cert tmp_private_key_file = File.join gem_path, "gem-private_key.pem" File.write(tmp_private_key_file, File.read(PRIVATE_KEY_FILE)) - spec = util_spec 'some_gem' do |s| + spec = util_spec "some_gem" do |s| s.signing_key = tmp_private_key_file s.cert_chain = [tmp_expired_cert_file] end gemspec_file = File.join(@tempdir, spec.spec_name) - File.open gemspec_file, 'w' do |gs| + File.open gemspec_file, "w" do |gs| gs.write spec.to_ruby end diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index 95b2fdf0ee12..ffcc14ffbba2 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/cert_command' +require_relative "helper" +require "rubygems/commands/cert_command" unless Gem::HAVE_OPENSSL - warn 'Skipping `gem cert` tests. openssl not found.' + warn "Skipping `gem cert` tests. openssl not found." end if Gem.java_platform? - warn 'Skipping `gem cert` tests on jruby.' + warn "Skipping `gem cert` tests on jruby." end class TestGemCommandsCertCommand < Gem::TestCase - ALTERNATE_CERT = load_cert 'alternate' - EXPIRED_PUBLIC_CERT = load_cert 'expired' + ALTERNATE_CERT = load_cert "alternate" + EXPIRED_PUBLIC_CERT = load_cert "expired" - ALTERNATE_KEY_FILE = key_path 'alternate' - PRIVATE_KEY_FILE = key_path 'private' - PRIVATE_EC_KEY_FILE = key_path 'private_ec' - PUBLIC_KEY_FILE = key_path 'public' + ALTERNATE_KEY_FILE = key_path "alternate" + PRIVATE_KEY_FILE = key_path "private" + PRIVATE_EC_KEY_FILE = key_path "private_ec" + PUBLIC_KEY_FILE = key_path "public" - ALTERNATE_CERT_FILE = cert_path 'alternate' - CHILD_CERT_FILE = cert_path 'child' - PUBLIC_CERT_FILE = cert_path 'public' - EXPIRED_PUBLIC_CERT_FILE = cert_path 'expired' + ALTERNATE_CERT_FILE = cert_path "alternate" + CHILD_CERT_FILE = cert_path "child" + PUBLIC_CERT_FILE = cert_path "public" + EXPIRED_PUBLIC_CERT_FILE = cert_path "expired" def setup super @@ -44,7 +44,7 @@ def test_certificates_matching @trust_dir.trust_cert PUBLIC_CERT @trust_dir.trust_cert ALTERNATE_CERT - matches = @cmd.certificates_matching '' + matches = @cmd.certificates_matching "" # HACK OpenSSL::X509::Certificate#== is Object#==, so do this the hard way match = matches.next @@ -64,7 +64,7 @@ def test_certificates_matching_filter @trust_dir.trust_cert PUBLIC_CERT @trust_dir.trust_cert ALTERNATE_CERT - matches = @cmd.certificates_matching 'alternate' + matches = @cmd.certificates_matching "alternate" match = matches.next assert_equal ALTERNATE_CERT.to_pem, match.first.to_pem @@ -91,7 +91,7 @@ def test_execute_add end def test_execute_add_twice - self.class.cert_path 'alternate' + self.class.cert_path "alternate" @cmd.handle_options %W[ --add #{PUBLIC_CERT_FILE} @@ -112,7 +112,7 @@ def test_execute_add_twice end def test_execute_build - passphrase = 'Foo bar' + passphrase = "Foo bar" @cmd.handle_options %W[--build nobody@example.com] @@ -139,12 +139,12 @@ def test_execute_build assert_empty output assert_empty @build_ui.error - assert_path_exist File.join(@tempdir, 'gem-private_key.pem') - assert_path_exist File.join(@tempdir, 'gem-public_cert.pem') + assert_path_exist File.join(@tempdir, "gem-private_key.pem") + assert_path_exist File.join(@tempdir, "gem-public_cert.pem") end def test_execute_build_key_algorithm_ec_key - passphrase = 'Foo bar' + passphrase = "Foo bar" @cmd.handle_options %W[--build nobody@example.com --key-algorithm ec] @@ -171,16 +171,16 @@ def test_execute_build_key_algorithm_ec_key assert_empty output assert_empty @build_ui.error - assert_path_exist File.join(@tempdir, 'gem-private_key.pem') + assert_path_exist File.join(@tempdir, "gem-private_key.pem") - cert_path = File.join(@tempdir, 'gem-public_cert.pem') + cert_path = File.join(@tempdir, "gem-public_cert.pem") assert_path_exist cert_path cert = OpenSSL::X509::Certificate.new(File.read(cert_path)) assert cert.public_key.is_a? OpenSSL::PKey::EC end def test_execute_build_bad_email_address - passphrase = 'Foo bar' + passphrase = "Foo bar" email = "nobody@" @cmd.handle_options %W[--build #{email}] @@ -195,13 +195,13 @@ def test_execute_build_bad_email_address assert_equal "Invalid email address #{email}", e.message - assert_path_not_exist File.join(@tempdir, 'gem-private_key.pem') - assert_path_not_exist File.join(@tempdir, 'gem-public_cert.pem') + assert_path_not_exist File.join(@tempdir, "gem-private_key.pem") + assert_path_not_exist File.join(@tempdir, "gem-public_cert.pem") end end def test_execute_build_expiration_days - passphrase = 'Foo bar' + passphrase = "Foo bar" @cmd.handle_options %W[ --build nobody@example.com @@ -231,8 +231,8 @@ def test_execute_build_expiration_days assert_empty output assert_empty @build_ui.error - assert_path_exist File.join(@tempdir, 'gem-private_key.pem') - assert_path_exist File.join(@tempdir, 'gem-public_cert.pem') + assert_path_exist File.join(@tempdir, "gem-private_key.pem") + assert_path_exist File.join(@tempdir, "gem-public_cert.pem") pem = File.read("#{@tempdir}/gem-public_cert.pem") cert = OpenSSL::X509::Certificate.new(pem) @@ -242,8 +242,8 @@ def test_execute_build_expiration_days end def test_execute_build_bad_passphrase_confirmation - passphrase = 'Foo bar' - passphrase_confirmation = 'Fu bar' + passphrase = "Foo bar" + passphrase_confirmation = "Fu bar" @cmd.handle_options %W[--build nobody@example.com] @@ -267,8 +267,8 @@ def test_execute_build_bad_passphrase_confirmation e.message end - assert_path_not_exist File.join(@tempdir, 'gem-private_key.pem') - assert_path_not_exist File.join(@tempdir, 'gem-public_cert.pem') + assert_path_not_exist File.join(@tempdir, "gem-private_key.pem") + assert_path_not_exist File.join(@tempdir, "gem-public_cert.pem") end def test_execute_build_key @@ -289,8 +289,8 @@ def test_execute_build_key assert_empty output assert_empty @ui.error - assert_path_exist File.join(@tempdir, 'gem-public_cert.pem') - assert_path_not_exist File.join(@tempdir, 'gem-private_key.pem') + assert_path_exist File.join(@tempdir, "gem-public_cert.pem") + assert_path_not_exist File.join(@tempdir, "gem-private_key.pem") end def test_execute_build_encrypted_key @@ -311,7 +311,7 @@ def test_execute_build_encrypted_key assert_empty output assert_empty @ui.error - assert_path_exist File.join(@tempdir, 'gem-public_cert.pem') + assert_path_exist File.join(@tempdir, "gem-public_cert.pem") end def test_execute_build_ec_key @@ -332,8 +332,8 @@ def test_execute_build_ec_key assert_empty output assert_empty @ui.error - assert_path_exist File.join(@tempdir, 'gem-public_cert.pem') - assert_path_not_exist File.join(@tempdir, 'gem-private_key.pem') + assert_path_exist File.join(@tempdir, "gem-public_cert.pem") + assert_path_not_exist File.join(@tempdir, "gem-private_key.pem") end def test_execute_certificate @@ -341,8 +341,8 @@ def test_execute_certificate @cmd.handle_options %W[--certificate #{PUBLIC_CERT_FILE}] end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error assert_equal PUBLIC_CERT.to_pem, @cmd.options[:issuer_cert].to_pem end @@ -381,8 +381,8 @@ def test_execute_private_key @cmd.send :handle_options, %W[--private-key #{PRIVATE_KEY_FILE}] end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error assert_equal PRIVATE_KEY.to_pem, @cmd.options[:key].to_pem end @@ -392,8 +392,8 @@ def test_execute_encrypted_private_key @cmd.send :handle_options, %W[--private-key #{ENCRYPTED_PRIVATE_KEY_PATH}] end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error assert_equal ENCRYPTED_PRIVATE_KEY.to_pem, @cmd.options[:key].to_pem end @@ -412,7 +412,7 @@ def test_execute_remove end assert_equal "Removed '/CN=nobody/DC=example'\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error assert_path_not_exist cert_path end @@ -439,7 +439,7 @@ def test_execute_remove_multiple EXPECTED assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error assert_path_not_exist public_path assert_path_not_exist alternate_path @@ -467,17 +467,17 @@ def test_execute_remove_twice EXPECTED assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error assert_path_not_exist public_path assert_path_not_exist alternate_path end def test_execute_sign - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write ALTERNATE_CERT, path, 0600 - assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s + assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s @cmd.handle_options %W[ --private-key #{PRIVATE_KEY_FILE} @@ -490,12 +490,12 @@ def test_execute_sign @cmd.execute end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error cert = OpenSSL::X509::Certificate.new File.read path - assert_equal '/CN=nobody/DC=example', cert.issuer.to_s + assert_equal "/CN=nobody/DC=example", cert.issuer.to_s mask = 0100600 & (~File.umask) @@ -503,10 +503,10 @@ def test_execute_sign end def test_execute_sign_encrypted_key - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write ALTERNATE_CERT, path, 0600 - assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s + assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s @cmd.handle_options %W[ --private-key #{ENCRYPTED_PRIVATE_KEY_PATH} @@ -519,12 +519,12 @@ def test_execute_sign_encrypted_key @cmd.execute end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error cert = OpenSSL::X509::Certificate.new File.read path - assert_equal '/CN=nobody/DC=example', cert.issuer.to_s + assert_equal "/CN=nobody/DC=example", cert.issuer.to_s mask = 0100600 & (~File.umask) @@ -532,18 +532,18 @@ def test_execute_sign_encrypted_key end def test_execute_sign_default - FileUtils.mkdir_p File.join Gem.user_home, '.gem' + FileUtils.mkdir_p File.join Gem.user_home, ".gem" - private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' + private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" Gem::Security.write PRIVATE_KEY, private_key_path - public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" Gem::Security.write PUBLIC_CERT, public_cert_path - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write ALTERNATE_CERT, path, 0600 - assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s + assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s @cmd.handle_options %W[--sign #{path}] @@ -551,12 +551,12 @@ def test_execute_sign_default @cmd.execute end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error cert = OpenSSL::X509::Certificate.new File.read path - assert_equal '/CN=nobody/DC=example', cert.issuer.to_s + assert_equal "/CN=nobody/DC=example", cert.issuer.to_s mask = 0100600 & (~File.umask) @@ -564,18 +564,18 @@ def test_execute_sign_default end def test_execute_sign_default_encrypted_key - FileUtils.mkdir_p File.join(Gem.user_home, '.gem') + FileUtils.mkdir_p File.join(Gem.user_home, ".gem") - private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' + private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" Gem::Security.write ENCRYPTED_PRIVATE_KEY, private_key_path, 0600, PRIVATE_KEY_PASSPHRASE - public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" Gem::Security.write PUBLIC_CERT, public_cert_path - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write ALTERNATE_CERT, path, 0600 - assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s + assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s @cmd.handle_options %W[--sign #{path}] @@ -583,12 +583,12 @@ def test_execute_sign_default_encrypted_key @cmd.execute end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error cert = OpenSSL::X509::Certificate.new File.read path - assert_equal '/CN=nobody/DC=example', cert.issuer.to_s + assert_equal "/CN=nobody/DC=example", cert.issuer.to_s mask = 0100600 & (~File.umask) @@ -596,15 +596,15 @@ def test_execute_sign_default_encrypted_key end def test_execute_sign_no_cert - FileUtils.mkdir_p File.join Gem.user_home, '.gem' + FileUtils.mkdir_p File.join Gem.user_home, ".gem" - private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' + private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" Gem::Security.write PRIVATE_KEY, private_key_path - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write ALTERNATE_CERT, path, 0600 - assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s + assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s @cmd.handle_options %W[--sign #{path}] @@ -614,7 +614,7 @@ def test_execute_sign_no_cert end end - assert_equal '', @ui.output + assert_equal "", @ui.output expected = <<-EXPECTED ERROR: --certificate not specified and ~/.gem/gem-public_cert.pem does not exist @@ -624,15 +624,15 @@ def test_execute_sign_no_cert end def test_execute_sign_no_key - FileUtils.mkdir_p File.join Gem.user_home, '.gem' + FileUtils.mkdir_p File.join Gem.user_home, ".gem" - public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" Gem::Security.write PUBLIC_CERT, public_cert_path - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write ALTERNATE_CERT, path, 0600 - assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s + assert_equal "/CN=alternate/DC=example", ALTERNATE_CERT.issuer.to_s @cmd.handle_options %W[--sign #{path}] @@ -642,7 +642,7 @@ def test_execute_sign_no_key end end - assert_equal '', @ui.output + assert_equal "", @ui.output expected = <<-EXPECTED ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exist @@ -655,10 +655,10 @@ def test_execute_re_sign gem_path = File.join Gem.user_home, ".gem" Dir.mkdir gem_path - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 - assert_equal '/CN=nobody/DC=example', EXPIRED_PUBLIC_CERT.issuer.to_s + assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s tmp_expired_cert_file = File.join(Dir.tmpdir, File.basename(EXPIRED_PUBLIC_CERT_FILE)) @cleanup << tmp_expired_cert_file @@ -680,17 +680,17 @@ def test_execute_re_sign /INFO: Your certificate #{tmp_expired_cert_file} has been re-signed\nINFO: Your expired certificate will be located at: #{expected_path}\.[0-9]+/, @ui.output ) - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_re_sign_with_cert_expiration_length_days gem_path = File.join Gem.user_home, ".gem" Dir.mkdir gem_path - path = File.join @tempdir, 'cert.pem' + path = File.join @tempdir, "cert.pem" Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 - assert_equal '/CN=nobody/DC=example', EXPIRED_PUBLIC_CERT.issuer.to_s + assert_equal "/CN=nobody/DC=example", EXPIRED_PUBLIC_CERT.issuer.to_s tmp_expired_cert_file = File.join(Dir.tmpdir, File.basename(EXPIRED_PUBLIC_CERT_FILE)) @cleanup << tmp_expired_cert_file @@ -712,7 +712,7 @@ def test_execute_re_sign_with_cert_expiration_length_days cert_days_to_expire = (re_signed_cert.not_after - re_signed_cert.not_before).to_i / (24 * 60 * 60) assert_equal(28, cert_days_to_expire) - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_handle_options @@ -738,11 +738,11 @@ def test_handle_options assert_equal %w[nobody@example other@example], @cmd.options[:build].map {|name| name.to_s } - assert_equal ['', 'example'], @cmd.options[:list] + assert_equal ["", "example"], @cmd.options[:list] end def test_handle_options_add_bad - nonexistent = File.join @tempdir, 'nonexistent' + nonexistent = File.join @tempdir, "nonexistent" e = assert_raise Gem::OptionParser::InvalidArgument do @cmd.handle_options %W[--add #{nonexistent}] end @@ -750,7 +750,7 @@ def test_handle_options_add_bad assert_equal "invalid argument: --add #{nonexistent}: does not exist", e.message - bad = File.join @tempdir, 'bad' + bad = File.join @tempdir, "bad" FileUtils.touch bad e = assert_raise Gem::OptionParser::InvalidArgument do @@ -762,7 +762,7 @@ def test_handle_options_add_bad end def test_handle_options_certificate - nonexistent = File.join @tempdir, 'nonexistent' + nonexistent = File.join @tempdir, "nonexistent" e = assert_raise Gem::OptionParser::InvalidArgument do @cmd.handle_options %W[--certificate #{nonexistent}] end @@ -770,7 +770,7 @@ def test_handle_options_certificate assert_equal "invalid argument: --certificate #{nonexistent}: does not exist", e.message - bad = File.join @tempdir, 'bad' + bad = File.join @tempdir, "bad" FileUtils.touch bad e = assert_raise Gem::OptionParser::InvalidArgument do @@ -783,7 +783,7 @@ def test_handle_options_certificate end def test_handle_options_key_bad - nonexistent = File.join @tempdir, 'nonexistent' + nonexistent = File.join @tempdir, "nonexistent" e = assert_raise Gem::OptionParser::InvalidArgument do @cmd.handle_options %W[--private-key #{nonexistent}] end @@ -792,7 +792,7 @@ def test_handle_options_key_bad "--private-key #{nonexistent}: does not exist", e.message - bad = File.join @tempdir, 'bad' + bad = File.join @tempdir, "bad" FileUtils.touch bad e = assert_raise Gem::OptionParser::InvalidArgument do @@ -848,7 +848,7 @@ def test_handle_options_sign_encrypted_key end def test_handle_options_sign_nonexistent - nonexistent = File.join @tempdir, 'nonexistent' + nonexistent = File.join @tempdir, "nonexistent" e = assert_raise Gem::OptionParser::InvalidArgument do @cmd.handle_options %W[ --private-key #{ALTERNATE_KEY_FILE} diff --git a/test/rubygems/test_gem_commands_check_command.rb b/test/rubygems/test_gem_commands_check_command.rb index f280b060c414..9233f7b5cefc 100644 --- a/test/rubygems/test_gem_commands_check_command.rb +++ b/test/rubygems/test_gem_commands_check_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/check_command' +require_relative "helper" +require "rubygems/commands/check_command" class TestGemCommandsCheckCommand < Gem::TestCase def setup @@ -45,8 +45,8 @@ def test_handle_options_defaults end def test_doctor - gem 'a' - b = gem 'b' + gem "a" + b = gem "b" FileUtils.rm b.spec_file diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb index fc989980123a..51d59df58c9d 100644 --- a/test/rubygems/test_gem_commands_cleanup_command.rb +++ b/test/rubygems/test_gem_commands_cleanup_command.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/cleanup_command' -require 'rubygems/installer' +require_relative "helper" +require "rubygems/commands/cleanup_command" +require "rubygems/installer" class TestGemCommandsCleanupCommand < Gem::TestCase def setup @@ -9,8 +9,8 @@ def setup @cmd = Gem::Commands::CleanupCommand.new - @a_1 = util_spec 'a', 1 - @a_2 = util_spec 'a', 2 + @a_1 = util_spec "a", 1 + @a_2 = util_spec "a", 2 install_gem @a_1 install_gem @a_2 @@ -66,12 +66,12 @@ def test_execute end def test_execute_all_dependencies - @b_1 = util_spec 'b', 1 do |s| - s.add_dependency 'a', '1' + @b_1 = util_spec "b", 1 do |s| + s.add_dependency "a", "1" end - @b_2 = util_spec 'b', 2 do |s| - s.add_dependency 'a', '2' + @b_2 = util_spec "b", 2 do |s| + s.add_dependency "a", "2" end install_gem @b_1 @@ -86,12 +86,12 @@ def test_execute_all_dependencies end def test_execute_dev_dependencies - @b_1 = util_spec 'b', 1 do |s| - s.add_development_dependency 'a', '1' + @b_1 = util_spec "b", 1 do |s| + s.add_development_dependency "a", "1" end - @c_1 = util_spec 'c', 1 do |s| - s.add_development_dependency 'a', '2' + @c_1 = util_spec "c", 1 do |s| + s.add_development_dependency "a", "2" end install_gem @b_1 @@ -105,12 +105,12 @@ def test_execute_dev_dependencies end def test_execute_without_dev_dependencies - @b_1 = util_spec 'b', 1 do |s| - s.add_development_dependency 'a', '1' + @b_1 = util_spec "b", 1 do |s| + s.add_development_dependency "a", "1" end - @c_1 = util_spec 'c', 1 do |s| - s.add_development_dependency 'a', '2' + @c_1 = util_spec "c", 1 do |s| + s.add_development_dependency "a", "2" end install_gem @b_1 @@ -124,14 +124,14 @@ def test_execute_without_dev_dependencies end def test_execute_all - gemhome2 = File.join @tempdir, 'gemhome2' + gemhome2 = File.join @tempdir, "gemhome2" Gem.ensure_gem_subdirectories gemhome2 Gem.use_paths @gemhome, gemhome2 - @b_1 = util_spec 'b', 1 - @b_2 = util_spec 'b', 2 + @b_1 = util_spec "b", 1 + @b_2 = util_spec "b", 2 install_gem @b_1 install_gem @b_2 @@ -140,15 +140,15 @@ def test_execute_all @cmd.execute - assert_equal @gemhome, Gem.dir, 'GEM_HOME' - assert_equal [@gemhome, gemhome2], Gem.path.sort, 'GEM_PATH' + assert_equal @gemhome, Gem.dir, "GEM_HOME" + assert_equal [@gemhome, gemhome2], Gem.path.sort, "GEM_PATH" assert_path_not_exist @a_1.gem_dir assert_path_not_exist @b_1.gem_dir end def test_execute_all_user - @a_1_1, = util_gem 'a', '1.1' + @a_1_1, = util_gem "a", "1.1" @a_1_1 = install_gem @a_1_1 # pick up user install path Gem::Specification.dirs = [Gem.dir, Gem.user_dir] @@ -167,7 +167,7 @@ def test_execute_all_user def test_execute_all_user_no_sudo FileUtils.chmod 0555, @gemhome - @a_1_1, = util_gem 'a', '1.1' + @a_1_1, = util_gem "a", "1.1" @a_1_1 = install_gem @a_1_1, :user_install => true # pick up user install path Gem::Specification.dirs = [Gem.dir, Gem.user_dir] @@ -195,11 +195,11 @@ def test_execute_dry_run end def test_execute_keeps_older_versions_with_deps - @b_1 = util_spec 'b', 1 - @b_2 = util_spec 'b', 2 + @b_1 = util_spec "b", 1 + @b_2 = util_spec "b", 2 - @c = util_spec 'c', 1 do |s| - s.add_dependency 'b', '1' + @c = util_spec "c", 1 do |s| + s.add_dependency "b", "1" end install_gem @b_1 @@ -216,9 +216,9 @@ def test_execute_keeps_older_versions_with_deps def test_execute_ignore_default_gem_verbose Gem.configuration.verbose = :really - @b_1 = util_spec 'b', 1 + @b_1 = util_spec "b", 1 @b_default = new_default_spec "b", "2" - @b_2 = util_spec 'b', 3 + @b_2 = util_spec "b", 3 install_gem @b_1 install_default_gems @b_default @@ -235,12 +235,12 @@ def test_execute_ignore_default_gem_verbose end def test_execute_remove_gem_home_only - c_1, = util_gem 'c', '1' - c_2, = util_gem 'c', '2' - d_1, = util_gem 'd', '1' - d_2, = util_gem 'd', '2' - e_1, = util_gem 'e', '1' - e_2, = util_gem 'e', '2' + c_1, = util_gem "c", "1" + c_2, = util_gem "c", "2" + d_1, = util_gem "d", "1" + d_2, = util_gem "d", "2" + e_1, = util_gem "e", "1" + e_2, = util_gem "e", "2" c_1 = install_gem c_1, :user_install => true # pick up user install path c_2 = install_gem c_2 @@ -263,11 +263,11 @@ def test_execute_remove_gem_home_only end def test_execute_user_install - c_1, = util_gem 'c', '1.0' - c_2, = util_gem 'c', '1.1' + c_1, = util_gem "c", "1.0" + c_2, = util_gem "c", "1.1" - d_1, = util_gem 'd', '1.0' - d_2, = util_gem 'd', '1.1' + d_1, = util_gem "d", "1.0" + d_2, = util_gem "d", "1.1" c_1 = install_gem c_1, :user_install => true # pick up user install path c_2 = install_gem c_2, :user_install => true # pick up user install path diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index cf93d81e7eac..1b9da8a92e08 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/contents_command' +require_relative "helper" +require "rubygems/commands/contents_command" class TestGemCommandsContentsCommand < Gem::TestCase def setup @@ -20,7 +20,7 @@ def gem(name, version = 2) def test_execute @cmd.options[:args] = %w[foo] - gem 'foo' + gem "foo" use_ui @ui do @cmd.execute @@ -34,8 +34,8 @@ def test_execute def test_execute_all @cmd.options[:all] = true - gem 'foo' - gem 'bar' + gem "foo" + gem "bar" use_ui @ui do @cmd.execute @@ -63,8 +63,8 @@ def test_execute_bad_gem def test_execute_exact_match @cmd.options[:args] = %w[foo] - gem 'foo' - gem 'bar' + gem "foo" + gem "bar" use_ui @ui do @cmd.execute @@ -79,7 +79,7 @@ def test_execute_lib_only @cmd.options[:args] = %w[foo] @cmd.options[:lib_only] = true - gem 'foo' + gem "foo" use_ui @ui do @cmd.execute @@ -106,9 +106,9 @@ def test_execute_missing_single def test_execute_missing_version @cmd.options[:args] = %w[foo] - @cmd.options[:version] = Gem::Requirement.new '= 2' + @cmd.options[:version] = Gem::Requirement.new "= 2" - gem 'foo', 1 + gem "foo", 1 assert_raise Gem::MockGemUi::TermError do use_ui @ui do @@ -123,7 +123,7 @@ def test_execute_missing_version def test_execute_missing_multiple @cmd.options[:args] = %w[foo bar] - gem 'foo' + gem "foo" use_ui @ui do @cmd.execute @@ -138,8 +138,8 @@ def test_execute_missing_multiple def test_execute_multiple @cmd.options[:args] = %w[foo bar] - gem 'foo' - gem 'bar' + gem "foo" + gem "bar" use_ui @ui do @cmd.execute @@ -155,13 +155,13 @@ def test_execute_show_install_dir @cmd.options[:args] = %w[foo] @cmd.options[:show_install_dir] = true - gem 'foo' + gem "foo" use_ui @ui do @cmd.execute end - expected = File.join @gemhome, 'gems', 'foo-2' + expected = File.join @gemhome, "gems", "foo-2" assert_equal "#{expected}\n", @ui.output assert_equal "", @ui.error @@ -171,14 +171,14 @@ def test_execute_show_install_dir_latest_version @cmd.options[:args] = %w[foo] @cmd.options[:show_install_dir] = true - gem 'foo', 1 - gem 'foo', 2 + gem "foo", 1 + gem "foo", 2 use_ui @ui do @cmd.execute end - expected = File.join @gemhome, 'gems', 'foo-2' + expected = File.join @gemhome, "gems", "foo-2" assert_equal "#{expected}\n", @ui.output assert_equal "", @ui.error @@ -187,16 +187,16 @@ def test_execute_show_install_dir_latest_version def test_execute_show_install_dir_version @cmd.options[:args] = %w[foo] @cmd.options[:show_install_dir] = true - @cmd.options[:version] = Gem::Requirement.new '= 1' + @cmd.options[:version] = Gem::Requirement.new "= 1" - gem 'foo', 1 - gem 'foo', 2 + gem "foo", 1 + gem "foo", 2 use_ui @ui do @cmd.execute end - expected = File.join @gemhome, 'gems', 'foo-1' + expected = File.join @gemhome, "gems", "foo-1" assert_equal "#{expected}\n", @ui.output assert_equal "", @ui.error @@ -206,7 +206,7 @@ def test_execute_no_prefix @cmd.options[:args] = %w[foo] @cmd.options[:prefix] = false - gem 'foo' + gem "foo" use_ui @ui do @cmd.execute @@ -236,9 +236,9 @@ def test_execute_default_gem end expected = [ - [RbConfig::CONFIG['bindir'], 'default_command'], - [RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'], - [RbConfig::CONFIG['archdir'], 'default_gem.so'], + [RbConfig::CONFIG["bindir"], "default_command"], + [RbConfig::CONFIG["rubylibdir"], "default/gem.rb"], + [RbConfig::CONFIG["archdir"], "default_gem.so"], ].sort.map {|a|File.join a }.join "\n" assert_equal expected, @ui.output.chomp @@ -264,7 +264,7 @@ def test_handle_options assert @cmd.options[:lib_only] refute @cmd.options[:prefix] assert_equal %w[foo], @cmd.options[:specdirs] - assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version] + assert_equal Gem::Requirement.new("0.0.2"), @cmd.options[:version] assert @cmd.options[:show_install_dir] end end diff --git a/test/rubygems/test_gem_commands_dependency_command.rb b/test/rubygems/test_gem_commands_dependency_command.rb index 13c7c065b524..d9571275cb5a 100644 --- a/test/rubygems/test_gem_commands_dependency_command.rb +++ b/test/rubygems/test_gem_commands_dependency_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/dependency_command' +require_relative "helper" +require "rubygems/commands/dependency_command" class TestGemCommandsDependencyCommand < Gem::TestCase def setup @@ -11,9 +11,9 @@ def setup end def test_execute - quick_gem 'foo' do |gem| - gem.add_dependency 'bar', '> 1' - gem.add_dependency 'baz', '> 1' + quick_gem "foo" do |gem| + gem.add_dependency "bar", "> 1" + gem.add_dependency "baz", "> 1" end @cmd.options[:args] = %w[foo] @@ -24,16 +24,16 @@ def test_execute assert_equal "Gem foo-2\n bar (> 1)\n baz (> 1)\n\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_no_args - install_specs util_spec 'x', '2' + install_specs util_spec "x", "2" spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'dep_x', 1, 'x' => '>= 1' + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "dep_x", 1, "x" => ">= 1" fetcher.legacy_platform end @@ -58,7 +58,7 @@ def test_execute_no_args EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_no_match @@ -71,14 +71,14 @@ def test_execute_no_match end assert_equal "No gems found matching foo (>= 0)\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_pipe_format - spec = util_spec 'foo' do |gem| - gem.add_dependency 'bar', '> 1' + spec = util_spec "foo" do |gem| + gem.add_dependency "bar", "> 1" end - install_specs util_spec 'bar', 2 + install_specs util_spec "bar", 2 install_specs spec @cmd.options[:args] = %w[foo] @@ -89,15 +89,15 @@ def test_execute_pipe_format end assert_equal "bar --version '> 1'\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_regexp spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'a_evil', 9 - fetcher.spec 'b', 2 + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "a_evil", 9 + fetcher.spec "b", 2 end @cmd.options[:args] = %w[[ab]] @@ -118,17 +118,17 @@ def test_execute_regexp EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_reverse # FIX: this shouldn't need to write out, but fails if you switch it - quick_gem 'foo' do |gem| - gem.add_dependency 'bar', '> 1' + quick_gem "foo" do |gem| + gem.add_dependency "bar", "> 1" end - quick_gem 'baz' do |gem| - gem.add_dependency 'foo' + quick_gem "baz" do |gem| + gem.add_dependency "foo" end @cmd.options[:args] = %w[foo] @@ -147,7 +147,7 @@ def test_execute_reverse EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_reverse_remote @@ -165,15 +165,15 @@ def test_execute_reverse_remote ERROR: Only reverse dependencies for local gems are supported. EOF - assert_equal '', @stub_ui.output + assert_equal "", @stub_ui.output assert_equal expected, @stub_ui.error end def test_execute_remote - install_specs util_spec 'bar', '2' + install_specs util_spec "bar", "2" spec_fetcher do |fetcher| - fetcher.spec 'foo', 2, 'bar' => '> 1' + fetcher.spec "foo", 2, "bar" => "> 1" end @cmd.options[:args] = %w[foo] @@ -184,7 +184,7 @@ def test_execute_remote end assert_equal "Gem foo-2\n bar (> 1)\n\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_remote_version @@ -192,25 +192,25 @@ def test_execute_remote_version Gem::RemoteFetcher.fetcher = @fetcher spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 + fetcher.spec "a", 1 + fetcher.spec "a", 2 end @cmd.options[:args] = %w[a] @cmd.options[:domain] = :remote - @cmd.options[:version] = req '= 1' + @cmd.options[:version] = req "= 1" use_ui @stub_ui do @cmd.execute end assert_equal "Gem a-1\n\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_prerelease spec_fetcher do |fetcher| - fetcher.spec 'a', '2.a' + fetcher.spec "a", "2.a" end @cmd.options[:args] = %w[a] @@ -222,6 +222,6 @@ def test_execute_prerelease end assert_equal "Gem a-2.a\n\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end end diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index eeddb2befec9..91ed774cb64d 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/environment_command' +require_relative "helper" +require "rubygems/commands/environment_command" class TestGemCommandsEnvironmentCommand < Gem::TestCase def setup @@ -11,9 +11,9 @@ def setup def test_execute orig_sources = Gem.sources.dup - orig_path, ENV['PATH'] = ENV['PATH'], %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR) + orig_path, ENV["PATH"] = ENV["PATH"], %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR) Gem.sources.replace %w[http://gems.example.com] - Gem.configuration['gemcutter_key'] = 'blah' + Gem.configuration["gemcutter_key"] = "blah" @cmd.send :handle_options, %w[] @@ -51,7 +51,7 @@ def test_execute ensure Gem.sources.replace orig_sources - ENV['PATH'] = orig_path + ENV["PATH"] = orig_path end def test_execute_gemdir @@ -62,7 +62,7 @@ def test_execute_gemdir end assert_equal "#{@gemhome}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_user_gemdir @@ -73,7 +73,7 @@ def test_execute_user_gemdir end assert_equal "#{Gem.user_dir}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_user_gemhome @@ -84,7 +84,7 @@ def test_execute_user_gemhome end assert_equal "#{Gem.user_dir}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_gempath @@ -95,13 +95,13 @@ def test_execute_gempath end assert_equal "#{@gemhome}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_gempath_multiple Gem.clear_paths path = [@gemhome, "#{@gemhome}2"].join File::PATH_SEPARATOR - ENV['GEM_PATH'] = path + ENV["GEM_PATH"] = path @cmd.send :handle_options, %w[gempath] @@ -110,7 +110,7 @@ def test_execute_gempath_multiple end assert_equal "#{Gem.path.join File::PATH_SEPARATOR}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_remotesources @@ -124,7 +124,7 @@ def test_execute_remotesources end assert_equal "http://gems.example.com\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error ensure Gem.sources.replace orig_sources @@ -139,8 +139,8 @@ def test_execute_unknown end end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error end def test_execute_version @@ -151,7 +151,7 @@ def test_execute_version end assert_equal "#{Gem::VERSION}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_platform @@ -162,6 +162,6 @@ def test_execute_platform end assert_equal "#{Gem.platforms.join File::PATH_SEPARATOR}\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end end diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb index 7d4c77afaa38..f2a4464c7dc4 100644 --- a/test/rubygems/test_gem_commands_fetch_command.rb +++ b/test/rubygems/test_gem_commands_fetch_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/package' -require 'rubygems/security' -require 'rubygems/commands/fetch_command' +require_relative "helper" +require "rubygems/package" +require "rubygems/security" +require "rubygems/commands/fetch_command" class TestGemCommandsFetchCommand < Gem::TestCase def setup @@ -13,10 +13,10 @@ def setup def test_execute specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end - assert_path_not_exist File.join(@tempdir, 'cache'), 'sanity check' + assert_path_not_exist File.join(@tempdir, "cache"), "sanity check" @cmd.options[:args] = %w[a] @@ -26,24 +26,24 @@ def test_execute end end - a2 = specs['a-2'] + a2 = specs["a-2"] assert_path_exist(File.join(@tempdir, a2.file_name), "#{a2.full_name} not fetched") - assert_path_not_exist File.join(@tempdir, 'cache'), - 'gem repository directories must not be created' + assert_path_not_exist File.join(@tempdir, "cache"), + "gem repository directories must not be created" end def test_execute_latest specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 + fetcher.gem "a", 1 + fetcher.gem "a", 2 end - assert_path_not_exist File.join(@tempdir, 'cache'), 'sanity check' + assert_path_not_exist File.join(@tempdir, "cache"), "sanity check" @cmd.options[:args] = %w[a] - @cmd.options[:version] = req('>= 0.1') + @cmd.options[:version] = req(">= 0.1") use_ui @ui do Dir.chdir @tempdir do @@ -51,17 +51,17 @@ def test_execute_latest end end - a2 = specs['a-2'] + a2 = specs["a-2"] assert_path_exist(File.join(@tempdir, a2.file_name), "#{a2.full_name} not fetched") - assert_path_not_exist File.join(@tempdir, 'cache'), - 'gem repository directories must not be created' + assert_path_not_exist File.join(@tempdir, "cache"), + "gem repository directories must not be created" end def test_execute_prerelease specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 - fetcher.gem 'a', '2.a' + fetcher.gem "a", 2 + fetcher.gem "a", "2.a" end @cmd.options[:args] = %w[a] @@ -73,7 +73,7 @@ def test_execute_prerelease end end - a2 = specs['a-2'] + a2 = specs["a-2"] assert_path_exist(File.join(@tempdir, a2.file_name), "#{a2.full_name} not fetched") @@ -83,7 +83,7 @@ def test_execute_platform a2_spec, a2 = util_gem("a", "2") a2_universal_darwin_spec, a2_universal_darwin = util_gem("a", "2") do |s| - s.platform = 'universal-darwin' + s.platform = "universal-darwin" end Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new @@ -103,7 +103,7 @@ def test_execute_platform @fetcher.data["#{@gem_repo}gems/#{a2_universal_darwin_spec.file_name}"] = Gem.read_binary(a2_universal_darwin) FileUtils.cp a2_universal_darwin, a2_universal_darwin_spec.cache_file - util_set_arch 'arm64-darwin20' do + util_set_arch "arm64-darwin20" do use_ui @ui do Dir.chdir @tempdir do @cmd.execute @@ -117,8 +117,8 @@ def test_execute_platform def test_execute_specific_prerelease specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 - fetcher.gem 'a', '2.a' + fetcher.gem "a", 2 + fetcher.gem "a", "2.a" end @cmd.options[:args] = %w[a] @@ -131,7 +131,7 @@ def test_execute_specific_prerelease end end - a2_pre = specs['a-2.a'] + a2_pre = specs["a-2.a"] assert_path_exist(File.join(@tempdir, a2_pre.file_name), "#{a2_pre.full_name} not fetched") @@ -139,12 +139,12 @@ def test_execute_specific_prerelease def test_execute_version specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 + fetcher.gem "a", 1 + fetcher.gem "a", 2 end @cmd.options[:args] = %w[a] - @cmd.options[:version] = Gem::Requirement.new '1' + @cmd.options[:version] = Gem::Requirement.new "1" use_ui @ui do Dir.chdir @tempdir do @@ -152,7 +152,7 @@ def test_execute_version end end - a1 = specs['a-1'] + a1 = specs["a-1"] assert_path_exist(File.join(@tempdir, a1.file_name), "#{a1.full_name} not fetched") @@ -160,7 +160,7 @@ def test_execute_version def test_execute_version_specified_by_colon specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 + fetcher.gem "a", 1 end @cmd.options[:args] = %w[a:1] @@ -171,7 +171,7 @@ def test_execute_version_specified_by_colon end end - a1 = specs['a-1'] + a1 = specs["a-1"] assert_path_exist(File.join(@tempdir, a1.file_name), "#{a1.full_name} not fetched") @@ -179,7 +179,7 @@ def test_execute_version_specified_by_colon def test_execute_two_version @cmd.options[:args] = %w[a b] - @cmd.options[:version] = Gem::Requirement.new '1' + @cmd.options[:version] = Gem::Requirement.new "1" use_ui @ui do assert_raise Gem::MockGemUi::TermError, @ui.error do @@ -196,8 +196,8 @@ def test_execute_two_version def test_execute_two_version_specified_by_colon specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'b', 1 + fetcher.gem "a", 1 + fetcher.gem "b", 1 end @cmd.options[:args] = %w[a:1 b:1] @@ -208,8 +208,8 @@ def test_execute_two_version_specified_by_colon end end - a1 = specs['a-1'] - b1 = specs['b-1'] + a1 = specs["a-1"] + b1 = specs["b-1"] assert_path_exist(File.join(@tempdir, a1.file_name), "#{a1.full_name} not fetched") @@ -219,7 +219,7 @@ def test_execute_two_version_specified_by_colon def test_execute_version_nonexistent spec_fetcher do |fetcher| - fetcher.spec 'foo', 1 + fetcher.spec "foo", 1 end @cmd.options[:args] = %w[foo:2] @@ -238,7 +238,7 @@ def test_execute_version_nonexistent def test_execute_nonexistent_hint_disabled spec_fetcher do |fetcher| - fetcher.spec 'foo', 1 + fetcher.spec "foo", 1 end @cmd.options[:args] = %w[foo:2] diff --git a/test/rubygems/test_gem_commands_generate_index_command.rb b/test/rubygems/test_gem_commands_generate_index_command.rb index 5b7b37a44687..c0e18119eda8 100644 --- a/test/rubygems/test_gem_commands_generate_index_command.rb +++ b/test/rubygems/test_gem_commands_generate_index_command.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/indexer' -require 'rubygems/commands/generate_index_command' +require_relative "helper" +require "rubygems/indexer" +require "rubygems/commands/generate_index_command" class TestGemCommandsGenerateIndexCommand < Gem::TestCase def setup @@ -35,21 +35,21 @@ def test_execute_no_modern def test_handle_options_directory return if win_platform? - refute_equal '/nonexistent', @cmd.options[:directory] + refute_equal "/nonexistent", @cmd.options[:directory] @cmd.handle_options %w[--directory /nonexistent] - assert_equal '/nonexistent', @cmd.options[:directory] + assert_equal "/nonexistent", @cmd.options[:directory] end def test_handle_options_directory_windows return unless win_platform? - refute_equal '/nonexistent', @cmd.options[:directory] + refute_equal "/nonexistent", @cmd.options[:directory] @cmd.handle_options %w[--directory C:/nonexistent] - assert_equal 'C:/nonexistent', @cmd.options[:directory] + assert_equal "C:/nonexistent", @cmd.options[:directory] end def test_handle_options_update diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb index 98e5b62be098..b84bc4f7ef9a 100644 --- a/test/rubygems/test_gem_commands_help_command.rb +++ b/test/rubygems/test_gem_commands_help_command.rb @@ -11,41 +11,41 @@ def setup @cmd = Gem::Commands::HelpCommand.new - load File.expand_path('rubygems_plugin.rb', __dir__) unless Gem::Commands.const_defined? :InterruptCommand + load File.expand_path("rubygems_plugin.rb", __dir__) unless Gem::Commands.const_defined? :InterruptCommand end def test_gem_help_bad - util_gem 'bad' do |out, err| - assert_equal('', out) + util_gem "bad" do |out, err| + assert_equal("", out) assert_match "Unknown command bad", err end end def test_gem_help_gem_dependencies - util_gem 'gem_dependencies' do |out, err| - assert_match 'gem.deps.rb', out - assert_equal '', err + util_gem "gem_dependencies" do |out, err| + assert_match "gem.deps.rb", out + assert_equal "", err end end def test_gem_help_platforms - util_gem 'platforms' do |out, err| + util_gem "platforms" do |out, err| assert_match(/x86-freebsd/, out) - assert_equal '', err + assert_equal "", err end end def test_gem_help_build - util_gem 'build' do |out, err| + util_gem "build" do |out, err| assert_match(/-C PATH *Run as if gem build was started in /, out) - assert_equal '', err + assert_equal "", err end end def test_gem_help_commands mgr = Gem::CommandManager.new - util_gem 'commands' do |out, err| + util_gem "commands" do |out, err| mgr.command_names.each do |cmd| unless mgr[cmd].deprecated? assert_match(/\s+#{cmd}\s+\S+/, out) @@ -63,7 +63,7 @@ def test_gem_help_commands def test_gem_help_commands_omits_deprecated_commands mgr = Gem::CommandManager.new - util_gem 'commands' do |out, err| + util_gem "commands" do |out, err| deprecated_commands = mgr.command_names.select {|cmd| mgr[cmd].deprecated? } deprecated_commands.each do |cmd| refute_match(/\A\s+#{cmd}\s+\S+\z/, out) @@ -75,7 +75,7 @@ def test_gem_no_args_shows_help util_gem do |out, err| assert_match(/Usage:/, out) assert_match(/gem install/, out) - assert_equal '', err + assert_equal "", err end end diff --git a/test/rubygems/test_gem_commands_info_command.rb b/test/rubygems/test_gem_commands_info_command.rb index 462075f98c50..b18b405da60a 100644 --- a/test/rubygems/test_gem_commands_info_command.rb +++ b/test/rubygems/test_gem_commands_info_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/info_command' +require_relative "helper" +require "rubygems/commands/info_command" class TestGemCommandsInfoCommand < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 6127fcc1240d..7a58bcd7cb91 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/install_command' -require 'rubygems/request_set' -require 'rubygems/rdoc' +require_relative "helper" +require "rubygems/commands/install_command" +require "rubygems/request_set" +require "rubygems/rdoc" class TestGemCommandsInstallCommand < Gem::TestCase def setup @@ -30,8 +30,8 @@ def teardown def test_execute_exclude_prerelease spec_fetcher do |fetcher| - fetcher.gem 'a', 2 - fetcher.gem 'a', '2.pre' + fetcher.gem "a", 2 + fetcher.gem "a", "2.pre" end @cmd.options[:args] = %w[a] @@ -47,13 +47,13 @@ def test_execute_exclude_prerelease def test_execute_explicit_version_includes_prerelease specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 - fetcher.gem 'a', '2.a' + fetcher.gem "a", 2 + fetcher.gem "a", "2.a" end - a2_pre = specs['a-2.a'] + a2_pre = specs["a-2.a"] - @cmd.handle_options [a2_pre.name, '--version', a2_pre.version.to_s, + @cmd.handle_options [a2_pre.name, "--version", a2_pre.version.to_s, "--no-document"] assert @cmd.options[:prerelease] assert @cmd.options[:version].satisfied_by?(a2_pre.version) @@ -69,12 +69,12 @@ def test_execute_explicit_version_includes_prerelease def test_execute_local specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:domain] = :local - FileUtils.mv specs['a-2'].cache_file, @tempdir + FileUtils.mv specs["a-2"].cache_file, @tempdir @cmd.options[:args] = %w[a] @@ -97,14 +97,14 @@ def test_execute_local def test_execute_local_dependency_nonexistent specs = spec_fetcher do |fetcher| - fetcher.gem 'foo', 2, 'bar' => '0.5' + fetcher.gem "foo", 2, "bar" => "0.5" end @cmd.options[:domain] = :local - FileUtils.mv specs['foo-2'].cache_file, @tempdir + FileUtils.mv specs["foo-2"].cache_file, @tempdir - @cmd.options[:args] = ['foo'] + @cmd.options[:args] = ["foo"] use_ui @ui do orig_dir = Dir.pwd @@ -128,15 +128,15 @@ def test_execute_local_dependency_nonexistent def test_execute_local_dependency_nonexistent_ignore_dependencies specs = spec_fetcher do |fetcher| - fetcher.gem 'foo', 2, 'bar' => '0.5' + fetcher.gem "foo", 2, "bar" => "0.5" end @cmd.options[:domain] = :local @cmd.options[:ignore_dependencies] = true - FileUtils.mv specs['foo-2'].cache_file, @tempdir + FileUtils.mv specs["foo-2"].cache_file, @tempdir - @cmd.options[:args] = ['foo'] + @cmd.options[:args] = ["foo"] use_ui @ui do orig_dir = Dir.pwd @@ -155,16 +155,16 @@ def test_execute_local_dependency_nonexistent_ignore_dependencies def test_execute_local_transitive_prerelease specs = spec_fetcher do |fetcher| - fetcher.download 'a', 2, 'b' => "2.a", 'c' => '3' - fetcher.download 'b', '2.a' - fetcher.download 'c', '3' + fetcher.download "a", 2, "b" => "2.a", "c" => "3" + fetcher.download "b", "2.a" + fetcher.download "c", "3" end @cmd.options[:domain] = :local - FileUtils.mv specs['a-2'].cache_file, @tempdir - FileUtils.mv specs['b-2.a'].cache_file, @tempdir - FileUtils.mv specs['c-3'].cache_file, @tempdir + FileUtils.mv specs["a-2"].cache_file, @tempdir + FileUtils.mv specs["b-2.a"].cache_file, @tempdir + FileUtils.mv specs["c-3"].cache_file, @tempdir @cmd.options[:args] = %w[a] @@ -187,16 +187,16 @@ def test_execute_local_transitive_prerelease end def test_execute_no_user_install - pend 'skipped on MS Windows (chmod has no effect)' if win_platform? - pend 'skipped in root privilege' if Process.uid.zero? + pend "skipped on MS Windows (chmod has no effect)" if win_platform? + pend "skipped in root privilege" if Process.uid.zero? specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:user_install] = false - FileUtils.mv specs['a-2'].cache_file, @tempdir + FileUtils.mv specs["a-2"].cache_file, @tempdir @cmd.options[:args] = %w[a] @@ -295,10 +295,10 @@ def test_execute_nonexistent_force def test_execute_dependency_nonexistent spec_fetcher do |fetcher| - fetcher.spec 'foo', 2, 'bar' => '0.5' + fetcher.spec "foo", 2, "bar" => "0.5" end - @cmd.options[:args] = ['foo'] + @cmd.options[:args] = ["foo"] use_ui @ui do e = assert_raise Gem::MockGemUi::TermError do @@ -451,8 +451,8 @@ def test_execute_conflicting_install_options def test_execute_prerelease_skipped_when_no_flag_set spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', '3.a' + fetcher.gem "a", 1 + fetcher.gem "a", "3.a" end @cmd.options[:prerelease] = false @@ -469,8 +469,8 @@ def test_execute_prerelease_skipped_when_no_flag_set def test_execute_prerelease_wins_over_previous_ver spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', '2.a' + fetcher.download "a", 1 + fetcher.download "a", "2.a" end @cmd.options[:prerelease] = true @@ -487,8 +487,8 @@ def test_execute_prerelease_wins_over_previous_ver def test_execute_with_version_specified_by_colon spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 + fetcher.download "a", 1 + fetcher.download "a", 2 end @cmd.options[:args] = %w[a:1] @@ -504,8 +504,8 @@ def test_execute_with_version_specified_by_colon def test_execute_prerelease_skipped_when_non_pre_available spec_fetcher do |fetcher| - fetcher.gem 'a', '2.pre' - fetcher.gem 'a', 2 + fetcher.gem "a", "2.pre" + fetcher.gem "a", 2 end @cmd.options[:prerelease] = true @@ -525,15 +525,15 @@ def test_execute_required_ruby_version local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.download 'a', 2 do |s| + fetcher.download "a", 2 + fetcher.download "a", 2 do |s| s.required_ruby_version = "< #{RUBY_VERSION}.a" s.platform = local end - fetcher.download 'a', 3 do |s| + fetcher.download "a", 3 do |s| s.required_ruby_version = ">= #{next_ruby}" end - fetcher.download 'a', 3 do |s| + fetcher.download "a", 3 do |s| s.required_ruby_version = ">= #{next_ruby}" s.platform = local end @@ -553,8 +553,8 @@ def test_execute_required_ruby_version def test_execute_required_ruby_version_upper_bound local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.gem 'a', 2.0 - fetcher.gem 'a', 2.0 do |s| + fetcher.gem "a", 2.0 + fetcher.gem "a", 2.0 do |s| s.required_ruby_version = "< #{RUBY_VERSION}.a" s.platform = local end @@ -573,8 +573,8 @@ def test_execute_required_ruby_version_upper_bound def test_execute_required_ruby_version_specific_not_met spec_fetcher do |fetcher| - fetcher.gem 'a', '1.0' do |s| - s.required_ruby_version = '= 1.4.6' + fetcher.gem "a", "1.0" do |s| + s.required_ruby_version = "= 1.4.6" end end @@ -593,8 +593,8 @@ def test_execute_required_ruby_version_specific_not_met def test_execute_required_ruby_version_specific_prerelease_met spec_fetcher do |fetcher| - fetcher.gem 'a', '1.0' do |s| - s.required_ruby_version = '>= 1.4.6.preview2' + fetcher.gem "a", "1.0" do |s| + s.required_ruby_version = ">= 1.4.6.preview2" end end @@ -613,7 +613,7 @@ def test_execute_required_ruby_version_specific_prerelease_not_met next_ruby_pre = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".") + ".a" spec_fetcher do |fetcher| - fetcher.gem 'a', '1.0' do |s| + fetcher.gem "a", "1.0" do |s| s.required_ruby_version = "> #{next_ruby_pre}" end end @@ -633,8 +633,8 @@ def test_execute_required_ruby_version_specific_prerelease_not_met def test_execute_required_rubygems_version_wrong spec_fetcher do |fetcher| - fetcher.gem 'a', '1.0' do |s| - s.required_rubygems_version = '< 0' + fetcher.gem "a", "1.0" do |s| + s.required_rubygems_version = "< 0" end end @@ -653,7 +653,7 @@ def test_execute_required_rubygems_version_wrong def test_execute_rdoc specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end Gem.done_installing(&Gem::RDoc.method(:generation_hook)) @@ -661,7 +661,7 @@ def test_execute_rdoc @cmd.options[:document] = %w[rdoc ri] @cmd.options[:domain] = :local - a2 = specs['a-2'] + a2 = specs["a-2"] FileUtils.mv a2.cache_file, @tempdir @cmd.options[:args] = %w[a] @@ -683,22 +683,22 @@ def test_execute_rdoc wait_for_child_process_to_exit - assert_path_exist File.join(a2.doc_dir, 'ri') - assert_path_exist File.join(a2.doc_dir, 'rdoc') + assert_path_exist File.join(a2.doc_dir, "ri") + assert_path_exist File.join(a2.doc_dir, "rdoc") end def test_execute_rdoc_with_path specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end Gem.done_installing(&Gem::RDoc.method(:generation_hook)) @cmd.options[:document] = %w[rdoc ri] @cmd.options[:domain] = :local - @cmd.options[:install_dir] = 'whatever' + @cmd.options[:install_dir] = "whatever" - a2 = specs['a-2'] + a2 = specs["a-2"] FileUtils.mv a2.cache_file, @tempdir @cmd.options[:args] = %w[a] @@ -720,19 +720,19 @@ def test_execute_rdoc_with_path wait_for_child_process_to_exit - assert_path_exist 'whatever/doc/a-2', 'documentation not installed' + assert_path_exist "whatever/doc/a-2", "documentation not installed" end def test_execute_saves_build_args specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end args = %w[--with-awesome=true --more-awesome=yes] Gem::Command.build_args = args - a2 = specs['a-2'] + a2 = specs["a-2"] FileUtils.mv a2.cache_file, @tempdir @cmd.options[:domain] = :local @@ -762,7 +762,7 @@ def test_execute_saves_build_args def test_execute_remote spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:args] = %w[a] @@ -782,7 +782,7 @@ def test_execute_with_invalid_gem_file FileUtils.touch("a.gem") spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:args] = %w[a] @@ -800,7 +800,7 @@ def test_execute_with_invalid_gem_file def test_execute_remote_truncates_existing_gemspecs spec_fetcher do |fetcher| - fetcher.gem 'a', 1 + fetcher.gem "a", 1 end @cmd.options[:domain] = :remote @@ -816,7 +816,7 @@ def test_execute_remote_truncates_existing_gemspecs assert_equal %w[a-1], @cmd.installed_specs.map {|spec| spec.full_name } assert_match "1 gem installed", @ui.output - a1_gemspec = File.join(@gemhome, 'specifications', "a-1.gemspec") + a1_gemspec = File.join(@gemhome, "specifications", "a-1.gemspec") initial_a1_gemspec_content = File.read(a1_gemspec) modified_a1_gemspec_content = initial_a1_gemspec_content + "\n # AAAAAAA\n" @@ -833,14 +833,14 @@ def test_execute_remote_truncates_existing_gemspecs def test_execute_remote_ignores_files specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 + fetcher.gem "a", 1 + fetcher.gem "a", 2 end @cmd.options[:domain] = :remote - a1 = specs['a-1'] - a2 = specs['a-2'] + a1 = specs["a-1"] + a2 = specs["a-2"] FileUtils.mv a2.cache_file, @tempdir @@ -849,7 +849,7 @@ def test_execute_remote_ignores_files @cmd.options[:args] = [a2.name] - gemdir = File.join @gemhome, 'specifications' + gemdir = File.join @gemhome, "specifications" a2_gemspec = File.join(gemdir, "a-2.gemspec") a1_gemspec = File.join(gemdir, "a-1.gemspec") @@ -878,12 +878,12 @@ def test_execute_remote_ignores_files def test_execute_two specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 - fetcher.gem 'b', 2 + fetcher.gem "a", 2 + fetcher.gem "b", 2 end - FileUtils.mv specs['a-2'].cache_file, @tempdir - FileUtils.mv specs['b-2'].cache_file, @tempdir + FileUtils.mv specs["a-2"].cache_file, @tempdir + FileUtils.mv specs["b-2"].cache_file, @tempdir @cmd.options[:domain] = :local @@ -929,10 +929,10 @@ def test_execute_two_version def test_execute_two_version_specified_by_colon spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 - fetcher.gem 'b', 1 - fetcher.gem 'b', 2 + fetcher.gem "a", 1 + fetcher.gem "a", 2 + fetcher.gem "b", 1 + fetcher.gem "b", 2 end @cmd.options[:args] = %w[a:1 b:1] @@ -948,9 +948,9 @@ def test_execute_two_version_specified_by_colon def test_execute_conservative spec_fetcher do |fetcher| - fetcher.download 'b', 2 + fetcher.download "b", 2 - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:conservative] = true @@ -981,7 +981,7 @@ def test_install_gem_ignore_dependencies_both done_installing = true end - spec = util_spec 'a', 2 + spec = util_spec "a", 2 util_build_gem spec @@ -989,21 +989,21 @@ def test_install_gem_ignore_dependencies_both @cmd.options[:ignore_dependencies] = true - @cmd.install_gem 'a', '>= 0' + @cmd.install_gem "a", ">= 0" assert_equal %w[a-2], @cmd.installed_specs.map {|s| s.full_name } - assert done_installing, 'documentation was not generated' + assert done_installing, "documentation was not generated" end def test_install_gem_ignore_dependencies_remote spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:ignore_dependencies] = true - @cmd.install_gem 'a', '>= 0' + @cmd.install_gem "a", ">= 0" assert_equal %w[a-2], @cmd.installed_specs.map {|spec| spec.full_name } end @@ -1011,22 +1011,22 @@ def test_install_gem_ignore_dependencies_remote def test_install_gem_ignore_dependencies_remote_platform_local local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.gem 'a', 3 + fetcher.gem "a", 3 - fetcher.gem 'a', 3 do |s| + fetcher.gem "a", 3 do |s| s.platform = local end end @cmd.options[:ignore_dependencies] = true - @cmd.install_gem 'a', '>= 0' + @cmd.install_gem "a", ">= 0" assert_equal %W[a-3-#{local}], @cmd.installed_specs.map {|spec| spec.full_name } end def test_install_gem_ignore_dependencies_specific_file - spec = util_spec 'a', 2 + spec = util_spec "a", 2 util_build_gem spec @@ -1041,8 +1041,8 @@ def test_install_gem_ignore_dependencies_specific_file def test_parses_requirement_from_gemname spec_fetcher do |fetcher| - fetcher.gem 'a', 2 - fetcher.gem 'b', 2 + fetcher.gem "a", 2 + fetcher.gem "b", 2 end @cmd.options[:domain] = :local @@ -1088,12 +1088,12 @@ def test_show_errors_on_failure assert_equal 2, e.exit_code - assert_match 'Unable to download data', @ui.error + assert_match "Unable to download data", @ui.error end def test_show_source_problems_even_on_success spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 end Gem.sources << "http://nonexistent.example" @@ -1118,7 +1118,7 @@ def test_show_source_problems_even_on_success def test_redact_credentials_from_uri_on_warning spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 end Gem.sources << "http://username:SECURE_TOKEN@nonexistent.example" @@ -1143,7 +1143,7 @@ def test_redact_credentials_from_uri_on_warning def test_execute_uses_from_a_gemdeps spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end File.open @gemdeps, "w" do |f| @@ -1166,7 +1166,7 @@ def test_execute_uses_from_a_gemdeps def test_execute_uses_from_a_gemdeps_with_no_lock spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end File.open @gemdeps, "w" do |f| @@ -1190,8 +1190,8 @@ def test_execute_uses_from_a_gemdeps_with_no_lock def test_execute_installs_from_a_gemdeps_with_conservative spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.gem 'a', 1 + fetcher.download "a", 2 + fetcher.gem "a", 1 end File.open @gemdeps, "w" do |f| @@ -1214,7 +1214,7 @@ def test_execute_installs_from_a_gemdeps_with_conservative def test_execute_installs_from_a_gemdeps spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 end File.open @gemdeps, "w" do |f| @@ -1236,8 +1236,8 @@ def test_execute_installs_from_a_gemdeps def test_execute_installs_deps_a_gemdeps spec_fetcher do |fetcher| - fetcher.download 'q', '1.0' - fetcher.download 'r', '2.0', 'q' => nil + fetcher.download "q", "1.0" + fetcher.download "r", "2.0", "q" => nil end File.open @gemdeps, "w" do |f| @@ -1262,9 +1262,9 @@ def test_execute_installs_deps_a_gemdeps def test_execute_uses_deps_a_gemdeps spec_fetcher do |fetcher| - fetcher.download 'r', '2.0', 'q' => nil + fetcher.download "r", "2.0", "q" => nil - fetcher.spec 'q', '1.0' + fetcher.spec "q", "1.0" end File.open @gemdeps, "w" do |f| @@ -1289,8 +1289,8 @@ def test_execute_uses_deps_a_gemdeps def test_execute_installs_deps_a_gemdeps_into_a_path spec_fetcher do |fetcher| - fetcher.download 'q', '1.0' - fetcher.download 'r', '2.0', 'q' => nil + fetcher.download "q", "1.0" + fetcher.download "r", "2.0", "q" => nil end File.open @gemdeps, "w" do |f| @@ -1319,11 +1319,11 @@ def test_execute_installs_deps_a_gemdeps_into_a_path def test_execute_with_gemdeps_path_ignores_system specs = spec_fetcher do |fetcher| - fetcher.download 'q', '1.0' - fetcher.download 'r', '2.0', 'q' => nil + fetcher.download "q", "1.0" + fetcher.download "r", "2.0", "q" => nil end - install_specs specs['q-1.0'] + install_specs specs["q-1.0"] File.open @gemdeps, "w" do |f| f << "gem 'r'" @@ -1351,11 +1351,11 @@ def test_execute_with_gemdeps_path_ignores_system def test_execute_uses_deps_a_gemdeps_with_a_path specs = spec_fetcher do |fetcher| - fetcher.gem 'q', '1.0' - fetcher.gem 'r', '2.0', 'q' => nil + fetcher.gem "q", "1.0" + fetcher.gem "r", "2.0", "q" => nil end - i = Gem::Installer.at specs['q-1.0'].cache_file, :install_dir => "gf-path" + i = Gem::Installer.at specs["q-1.0"].cache_file, :install_dir => "gf-path" i.install assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed" @@ -1382,39 +1382,39 @@ def test_execute_uses_deps_a_gemdeps_with_a_path end def test_handle_options_file - FileUtils.touch 'Gemfile' + FileUtils.touch "Gemfile" @cmd.handle_options %w[-g Gemfile] - assert_equal 'Gemfile', @cmd.options[:gemdeps] + assert_equal "Gemfile", @cmd.options[:gemdeps] - FileUtils.rm 'Gemfile' + FileUtils.rm "Gemfile" - FileUtils.touch 'gem.deps.rb' + FileUtils.touch "gem.deps.rb" @cmd.handle_options %w[--file gem.deps.rb] - assert_equal 'gem.deps.rb', @cmd.options[:gemdeps] + assert_equal "gem.deps.rb", @cmd.options[:gemdeps] - FileUtils.rm 'gem.deps.rb' + FileUtils.rm "gem.deps.rb" - FileUtils.touch 'Isolate' + FileUtils.touch "Isolate" @cmd.handle_options %w[-g] - assert_equal 'Isolate', @cmd.options[:gemdeps] + assert_equal "Isolate", @cmd.options[:gemdeps] - FileUtils.touch 'Gemfile' + FileUtils.touch "Gemfile" @cmd.handle_options %w[-g] - assert_equal 'Gemfile', @cmd.options[:gemdeps] + assert_equal "Gemfile", @cmd.options[:gemdeps] - FileUtils.touch 'gem.deps.rb' + FileUtils.touch "gem.deps.rb" @cmd.handle_options %w[-g] - assert_equal 'gem.deps.rb', @cmd.options[:gemdeps] + assert_equal "gem.deps.rb", @cmd.options[:gemdeps] end def test_handle_options_suggest @@ -1442,9 +1442,9 @@ def test_handle_options_without def test_explain_platform_local local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 - fetcher.spec 'a', 2 do |s| + fetcher.spec "a", 2 do |s| s.platform = local end end @@ -1468,9 +1468,9 @@ def test_explain_platform_local def test_explain_platform_local_ignore_dependencies local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.spec 'a', 3 + fetcher.spec "a", 3 - fetcher.spec 'a', 3 do |s| + fetcher.spec "a", 3 do |s| s.platform = local end end @@ -1495,9 +1495,9 @@ def test_explain_platform_local_ignore_dependencies def test_explain_platform_ruby local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 - fetcher.spec 'a', 2 do |s| + fetcher.spec "a", 2 do |s| s.platform = local end end @@ -1524,9 +1524,9 @@ def test_explain_platform_ruby def test_explain_platform_ruby_ignore_dependencies local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.spec 'a', 3 + fetcher.spec "a", 3 - fetcher.spec 'a', 3 do |s| + fetcher.spec "a", 3 do |s| s.platform = local end end diff --git a/test/rubygems/test_gem_commands_list_command.rb b/test/rubygems/test_gem_commands_list_command.rb index d8cffce7a3d2..ec3f2517bff3 100644 --- a/test/rubygems/test_gem_commands_list_command.rb +++ b/test/rubygems/test_gem_commands_list_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/list_command' +require_relative "helper" +require "rubygems/commands/list_command" class TestGemCommandsListCommand < Gem::TestCase def setup @@ -9,7 +9,7 @@ def setup @cmd = Gem::Commands::ListCommand.new spec_fetcher do |fetcher| - fetcher.spec 'c', 1 + fetcher.spec "c", 1 end @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do @@ -27,6 +27,6 @@ def test_execute_installed end assert_equal "true\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end end diff --git a/test/rubygems/test_gem_commands_lock_command.rb b/test/rubygems/test_gem_commands_lock_command.rb index f8afca1e29a3..b785cbcfdd91 100644 --- a/test/rubygems/test_gem_commands_lock_command.rb +++ b/test/rubygems/test_gem_commands_lock_command.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/lock_command' +require_relative "helper" +require "rubygems/commands/lock_command" class TestGemCommandsLockCommand < Gem::TestCase def setup super - @a1 = quick_gem 'a', '1' - @b1 = quick_gem 'b', '1' do |s| - s.add_runtime_dependency 'a' + @a1 = quick_gem "a", "1" + @b1 = quick_gem "b", "1" do |s| + s.add_runtime_dependency "a" end - @d1 = quick_gem 'd', '1' do |s| - s.add_runtime_dependency 'z' + @d1 = quick_gem "d", "1" do |s| + s.add_runtime_dependency "z" end @cmd = Gem::Commands::LockCommand.new @@ -32,7 +32,7 @@ def test_execute EXPECTED assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_missing_dependency @@ -49,7 +49,7 @@ def test_execute_missing_dependency EXPECTED assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_strict @@ -61,6 +61,6 @@ def test_execute_strict end end - assert_equal 'Could not find gem c-1, try using the full name', e.message + assert_equal "Could not find gem c-1, try using the full name", e.message end end diff --git a/test/rubygems/test_gem_commands_mirror.rb b/test/rubygems/test_gem_commands_mirror.rb index 470f1c30fa82..423aba265649 100644 --- a/test/rubygems/test_gem_commands_mirror.rb +++ b/test/rubygems/test_gem_commands_mirror.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/mirror_command' +require_relative "helper" +require "rubygems/commands/mirror_command" class TestGemCommandsMirrorCommand < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb index 29cff1ed9741..f970ca12d6b7 100644 --- a/test/rubygems/test_gem_commands_open_command.rb +++ b/test/rubygems/test_gem_commands_open_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/open_command' +require_relative "helper" +require "rubygems/commands/open_command" class TestGemCommandsOpenCommand < Gem::TestCase def setup @@ -23,8 +23,8 @@ def test_execute @cmd.options[:args] = %w[foo] @cmd.options[:editor] = "#{ruby_with_rubygems_in_load_path} -eexit --" - gem 'foo', '1.0.0' - spec = gem 'foo', '1.0.1' + gem "foo", "1.0.0" + spec = gem "foo", "1.0.1" assert_nothing_raised Gem::MockGemUi::TermError do Dir.stub(:chdir, spec.full_gem_path) do diff --git a/test/rubygems/test_gem_commands_outdated_command.rb b/test/rubygems/test_gem_commands_outdated_command.rb index dc5c40a78293..4ed111a0e73a 100644 --- a/test/rubygems/test_gem_commands_outdated_command.rb +++ b/test/rubygems/test_gem_commands_outdated_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/outdated_command' +require_relative "helper" +require "rubygems/commands/outdated_command" class TestGemCommandsOutdatedCommand < Gem::TestCase def setup @@ -15,10 +15,10 @@ def test_initialize def test_execute spec_fetcher do |fetcher| - fetcher.download 'foo', '1.0' - fetcher.download 'foo', '2.0' - fetcher.gem 'foo', '0.1' - fetcher.gem 'foo', '0.2' + fetcher.download "foo", "1.0" + fetcher.download "foo", "2.0" + fetcher.gem "foo", "0.1" + fetcher.gem "foo", "0.2" end use_ui @ui do @@ -31,10 +31,10 @@ def test_execute def test_execute_with_up_to_date_platform_specific_gem spec_fetcher do |fetcher| - fetcher.download 'foo', '2.0' + fetcher.download "foo", "2.0" - fetcher.gem 'foo', '1.0' - fetcher.gem 'foo', '2.0' do |s| + fetcher.gem "foo", "1.0" + fetcher.gem "foo", "2.0" do |s| s.platform = Gem::Platform.local end end diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb index 5b06b628c204..ca77041000b2 100644 --- a/test/rubygems/test_gem_commands_owner_command.rb +++ b/test/rubygems/test_gem_commands_owner_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/owner_command' +require_relative "helper" +require "rubygems/commands/owner_command" class TestGemCommandsOwnerCommand < Gem::TestCase def setup @@ -36,7 +36,7 @@ def test_show_owners - id: 4 EOF - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, "OK"] use_ui @stub_ui do @cmd.show_owners("freewill") @@ -66,7 +66,7 @@ def test_show_owners_dont_load_objects - id: 4 EOF - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, "OK"] assert_raise Psych::DisallowedClass do use_ui @ui do @@ -80,7 +80,7 @@ def test_show_owners_setting_up_host_through_env_var host = "http://rubygems.example" ENV["RUBYGEMS_HOST"] = host - @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK'] + @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, "OK"] use_ui @stub_ui do @cmd.show_owners("freewill") @@ -95,7 +95,7 @@ def test_show_owners_setting_up_host host = "http://rubygems.example" @cmd.host = host - @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK'] + @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, "OK"] use_ui @stub_ui do @cmd.show_owners("freewill") @@ -107,7 +107,7 @@ def test_show_owners_setting_up_host def test_show_owners_denied response = "You don't have permission to push to this gem" - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, "Forbidden"] assert_raise Gem::MockGemUi::TermError do use_ui @stub_ui do @@ -120,21 +120,21 @@ def test_show_owners_denied def test_show_owners_key response = "- email: user1@example.com\n" - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK'] - File.open Gem.configuration.credentials_path, 'a' do |f| - f.write ':other: 701229f217cdf23b1344c7b4b54ca97' + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, "OK"] + File.open Gem.configuration.credentials_path, "a" do |f| + f.write ":other: 701229f217cdf23b1344c7b4b54ca97" end Gem.configuration.load_api_keys @cmd.handle_options %w[-k other] - @cmd.show_owners('freewill') + @cmd.show_owners("freewill") - assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization'] + assert_equal "701229f217cdf23b1344c7b4b54ca97", @stub_fetcher.last_request["Authorization"] end def test_add_owners response = "Owner added successfully." - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, "OK"] use_ui @stub_ui do @cmd.add_owners("freewill", ["user-new1@example.com"]) @@ -149,7 +149,7 @@ def test_add_owners def test_add_owners_denied response = "You don't have permission to push to this gem" - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, "Forbidden"] use_ui @stub_ui do @cmd.add_owners("freewill", ["user-new1@example.com"]) @@ -162,8 +162,8 @@ def test_add_owner_with_host_option_through_execute host = "http://rubygems.example" add_owner_response = "Owner added successfully." show_owners_response = "- email: user1@example.com\n" - @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, 'OK'] - @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, 'OK'] + @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners"] = [add_owner_response, 200, "OK"] + @stub_fetcher.data["#{host}/api/v1/gems/freewill/owners.yaml"] = [show_owners_response, 200, "OK"] @cmd.handle_options %W[--host #{host} --add user-new1@example.com freewill] @@ -178,21 +178,21 @@ def test_add_owner_with_host_option_through_execute def test_add_owners_key response = "Owner added successfully." - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK'] - File.open Gem.configuration.credentials_path, 'a' do |f| - f.write ':other: 701229f217cdf23b1344c7b4b54ca97' + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, "OK"] + File.open Gem.configuration.credentials_path, "a" do |f| + f.write ":other: 701229f217cdf23b1344c7b4b54ca97" end Gem.configuration.load_api_keys @cmd.handle_options %w[-k other] - @cmd.add_owners('freewill', ['user-new1@example.com']) + @cmd.add_owners("freewill", ["user-new1@example.com"]) - assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization'] + assert_equal "701229f217cdf23b1344c7b4b54ca97", @stub_fetcher.last_request["Authorization"] end def test_remove_owners response = "Owner removed successfully." - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, "OK"] use_ui @stub_ui do @cmd.remove_owners("freewill", ["user-remove1@example.com"]) @@ -207,7 +207,7 @@ def test_remove_owners def test_remove_owners_denied response = "You don't have permission to push to this gem" - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, "Forbidden"] use_ui @stub_ui do @cmd.remove_owners("freewill", ["user-remove1@example.com"]) @@ -218,21 +218,21 @@ def test_remove_owners_denied def test_remove_owners_key response = "Owner removed successfully." - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK'] - File.open Gem.configuration.credentials_path, 'a' do |f| - f.write ':other: 701229f217cdf23b1344c7b4b54ca97' + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, "OK"] + File.open Gem.configuration.credentials_path, "a" do |f| + f.write ":other: 701229f217cdf23b1344c7b4b54ca97" end Gem.configuration.load_api_keys @cmd.handle_options %w[-k other] - @cmd.remove_owners('freewill', ['user-remove1@example.com']) + @cmd.remove_owners("freewill", ["user-remove1@example.com"]) - assert_equal '701229f217cdf23b1344c7b4b54ca97', @stub_fetcher.last_request['Authorization'] + assert_equal "701229f217cdf23b1344c7b4b54ca97", @stub_fetcher.last_request["Authorization"] end def test_remove_owners_missing - response = 'Owner could not be found.' - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found'] + response = "Owner could not be found." + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, "Not Found"] use_ui @stub_ui do @cmd.remove_owners("freewill", ["missing@example"]) @@ -246,8 +246,8 @@ def test_otp_verified_success response_success = "Owner added successfully." @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [ - [response_fail, 401, 'Unauthorized'], - [response_success, 200, 'OK'], + [response_fail, 401, "Unauthorized"], + [response_success, 200, "OK"], ] @otp_ui = Gem::MockGemUi.new "111111\n" @@ -255,15 +255,15 @@ def test_otp_verified_success @cmd.add_owners("freewill", ["user-new1@example.com"]) end - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output - assert_match 'Code: ', @otp_ui.output + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @otp_ui.output + assert_match "Code: ", @otp_ui.output assert_match response_success, @otp_ui.output - assert_equal '111111', @stub_fetcher.last_request['OTP'] + assert_equal "111111", @stub_fetcher.last_request["OTP"] end def test_otp_verified_failure response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." - @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 401, 'Unauthorized'] + @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 401, "Unauthorized"] @otp_ui = Gem::MockGemUi.new "111111\n" use_ui @otp_ui do @@ -271,9 +271,9 @@ def test_otp_verified_failure end assert_match response, @otp_ui.output - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output - assert_match 'Code: ', @otp_ui.output - assert_equal '111111', @stub_fetcher.last_request['OTP'] + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @otp_ui.output + assert_match "Code: ", @otp_ui.output + assert_equal "111111", @stub_fetcher.last_request["OTP"] end def test_remove_owners_unathorized_api_key @@ -281,7 +281,7 @@ def test_remove_owners_unathorized_api_key response_success = "Owner removed successfully." @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [ - [response_forbidden, 403, 'Forbidden'], + [response_forbidden, 403, "Forbidden"], [response_success, 200, "OK"], ] @stub_fetcher.data["#{Gem.host}/api/v1/api_key"] = ["", 200, "OK"] @@ -305,7 +305,7 @@ def test_add_owners_unathorized_api_key response_success = "Owner added successfully." @stub_fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [ - [response_forbidden, 403, 'Forbidden'], + [response_forbidden, 403, "Forbidden"], [response_success, 200, "OK"], ] @stub_fetcher.data["#{Gem.host}/api/v1/api_key"] = ["", 200, "OK"] diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index 0ee67be391f9..5bf1d27eb9af 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/pristine_command' +require_relative "helper" +require "rubygems/commands/pristine_command" class TestGemCommandsPristineCommand < Gem::TestCase def setup @@ -11,29 +11,29 @@ def setup end def test_execute - a = util_spec 'a' do |s| + a = util_spec "a" do |s| s.executables = %w[foo] s.files = %w[bin/foo lib/a.rb] end - write_file File.join(@tempdir, 'lib', 'a.rb') do |fp| + write_file File.join(@tempdir, "lib", "a.rb") do |fp| fp.puts "puts __FILE__" end - write_file File.join(@tempdir, 'bin', 'foo') do |fp| + write_file File.join(@tempdir, "bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - foo_path = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo' - a_rb_path = File.join @gemhome, 'gems', a.full_name, 'lib', 'a.rb' + foo_path = File.join @gemhome, "gems", a.full_name, "bin", "foo" + a_rb_path = File.join @gemhome, "gems", a.full_name, "lib", "a.rb" write_file foo_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end write_file a_rb_path do |io| - io.puts 'I changed it!' + io.puts "I changed it!" end @cmd.options[:args] = %w[a] @@ -102,18 +102,18 @@ def test_execute_user_install end def test_execute_all - a = util_spec 'a' do |s| + a = util_spec "a" do |s| s.executables = %w[foo] end - write_file File.join(@tempdir, 'bin', 'foo') do |fp| + write_file File.join(@tempdir, "bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - gem_bin = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo' - gem_stub = File.join @gemhome, 'bin', 'foo' + gem_bin = File.join @gemhome, "gems", a.full_name, "bin", "foo" + gem_stub = File.join @gemhome, "bin", "foo" FileUtils.rm gem_bin FileUtils.rm gem_stub @@ -135,17 +135,17 @@ def test_execute_all end def test_execute_env_shebang - a = util_spec 'a' do |s| + a = util_spec "a" do |s| s.executables = %w[foo] s.files = %w[bin/foo] end - write_file File.join(@tempdir, 'bin', 'foo') do |fp| + write_file File.join(@tempdir, "bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - gem_exec = File.join @gemhome, 'bin', 'foo' + gem_exec = File.join @gemhome, "bin", "foo" FileUtils.rm gem_exec @@ -157,7 +157,7 @@ def test_execute_env_shebang assert_path_exist gem_exec - 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) } + " " @@ -165,11 +165,11 @@ def test_execute_env_shebang end def test_execute_extensions_explicit - a = util_spec 'a' do |s| - s.extensions << 'ext/a/extconf.rb' + a = util_spec "a" do |s| + s.extensions << "ext/a/extconf.rb" end - ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' + ext_path = File.join @tempdir, "ext", "a", "extconf.rb" write_file ext_path do |io| io.write <<-'RUBY' File.open "Makefile", "w" do |f| @@ -180,7 +180,7 @@ def test_execute_extensions_explicit RUBY end - b = util_spec 'b' + b = util_spec "b" install_gem a install_gem b @@ -195,19 +195,19 @@ def test_execute_extensions_explicit out = @ui.output.split "\n" - assert_equal 'Restoring gems to pristine condition...', out.shift - assert_equal 'Building native extensions. This could take a while...', + assert_equal "Restoring gems to pristine condition...", out.shift + assert_equal "Building native extensions. This could take a while...", out.shift assert_equal "Restored #{a.full_name}", out.shift assert_empty out, out.inspect end def test_execute_no_extension - a = util_spec 'a' do |s| - s.extensions << 'ext/a/extconf.rb' + a = util_spec "a" do |s| + s.extensions << "ext/a/extconf.rb" end - ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' + ext_path = File.join @tempdir, "ext", "a", "extconf.rb" write_file ext_path do |io| io.write "# extconf.rb\nrequire 'mkmf'; create_makefile 'a'" end @@ -223,18 +223,18 @@ def test_execute_no_extension out = @ui.output.split "\n" - assert_equal 'Restoring gems to pristine condition...', out.shift + assert_equal "Restoring gems to pristine condition...", out.shift assert_equal "Skipped #{a.full_name}, it needs to compile an extension", out.shift assert_empty out, out.inspect end def test_execute_with_extension_with_build_args - a = util_spec 'a' do |s| - s.extensions << 'ext/a/extconf.rb' + a = util_spec "a" do |s| + s.extensions << "ext/a/extconf.rb" end - ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' + ext_path = File.join @tempdir, "ext", "a", "extconf.rb" write_file ext_path do |io| io.write <<-'RUBY' File.open "Makefile", "w" do |f| @@ -257,7 +257,7 @@ def test_execute_with_extension_with_build_args out = @ui.output.split "\n" - assert_equal 'Restoring gems to pristine condition...', out.shift + assert_equal "Restoring gems to pristine condition...", out.shift assert_equal "Building native extensions with: '--with-awesome=true --sweet'", out.shift assert_equal "This could take a while...", out.shift assert_equal "Restored #{a.full_name}", out.shift @@ -265,8 +265,8 @@ def test_execute_with_extension_with_build_args end def test_execute_many - a = util_spec 'a' - b = util_spec 'b' + a = util_spec "a" + b = util_spec "b" install_gem a install_gem b @@ -286,14 +286,14 @@ def test_execute_many end def test_skip - a = util_spec 'a' - b = util_spec 'b' + a = util_spec "a" + b = util_spec "b" install_gem a install_gem b @cmd.options[:args] = %w[a b] - @cmd.options[:skip] = 'a' + @cmd.options[:skip] = "a" use_ui @ui do @cmd.execute @@ -308,16 +308,16 @@ def test_skip end def test_skip_many_gems - a = util_spec 'a' - b = util_spec 'b' - c = util_spec 'c' + a = util_spec "a" + b = util_spec "b" + c = util_spec "c" install_gem a install_gem b install_gem c @cmd.options[:args] = %w[a b c] - @cmd.options[:skip] = ['a', 'c'] + @cmd.options[:skip] = ["a", "c"] use_ui @ui do @cmd.execute @@ -333,14 +333,14 @@ def test_skip_many_gems end def test_execute_many_multi_repo - a = util_spec 'a' + a = util_spec "a" install_gem a Gem.clear_paths - gemhome2 = File.join @tempdir, 'gemhome2' + gemhome2 = File.join @tempdir, "gemhome2" Gem.use_paths gemhome2, [gemhome2, @gemhome] - b = util_spec 'b' + b = util_spec "b" install_gem b @cmd.options[:args] = %w[a b] @@ -356,21 +356,21 @@ def test_execute_many_multi_repo assert_equal "Restored #{b.full_name}", out.shift assert_empty out, out.inspect - assert_path_exist File.join(@gemhome, "gems", 'a-2') - assert_path_not_exist File.join(gemhome2, "gems", 'a-2') - assert_path_exist File.join(gemhome2, "gems", 'b-2') - assert_path_not_exist File.join(@gemhome, "gems", 'b-2') + assert_path_exist File.join(@gemhome, "gems", "a-2") + assert_path_not_exist File.join(gemhome2, "gems", "a-2") + assert_path_exist File.join(gemhome2, "gems", "b-2") + assert_path_not_exist File.join(@gemhome, "gems", "b-2") end def test_execute_missing_cache_gem specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 - fetcher.gem 'a', 3 - fetcher.gem 'a', '3.a' + fetcher.gem "a", 1 + fetcher.gem "a", 2 + fetcher.gem "a", 3 + fetcher.gem "a", "3.a" end - FileUtils.rm specs['a-2'].cache_file + FileUtils.rm specs["a-2"].cache_file @cmd.options[:args] = %w[a] @@ -396,22 +396,22 @@ def test_execute_missing_cache_gem def test_execute_missing_cache_gem_when_multi_repo specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'b', 1 + fetcher.gem "a", 1 + fetcher.gem "b", 1 end - FileUtils.rm_rf File.join(@gemhome, 'gems', 'a-1') - FileUtils.rm_rf File.join(@gemhome, 'gems', 'b-1') + FileUtils.rm_rf File.join(@gemhome, "gems", "a-1") + FileUtils.rm_rf File.join(@gemhome, "gems", "b-1") install_gem specs["a-1"] - FileUtils.rm File.join(@gemhome, 'cache', 'a-1.gem') + FileUtils.rm File.join(@gemhome, "cache", "a-1.gem") Gem.clear_paths - gemhome2 = File.join(@tempdir, 'gemhome2') + gemhome2 = File.join(@tempdir, "gemhome2") Gem.use_paths gemhome2, [gemhome2, @gemhome] install_gem specs["b-1"] - FileUtils.rm File.join(gemhome2, 'cache', 'b-1.gem') + FileUtils.rm File.join(gemhome2, "cache", "b-1.gem") Gem::Specification.reset @cmd.options[:args] = %w[a b] @@ -435,15 +435,15 @@ def test_execute_missing_cache_gem_when_multi_repo assert_empty out, out.inspect assert_empty @ui.error - assert_path_exist File.join(@gemhome, "cache", 'a-1.gem') - assert_path_not_exist File.join(gemhome2, "cache", 'a-2.gem') - assert_path_exist File.join(@gemhome, "gems", 'a-1') - assert_path_not_exist File.join(gemhome2, "gems", 'a-1') + assert_path_exist File.join(@gemhome, "cache", "a-1.gem") + assert_path_not_exist File.join(gemhome2, "cache", "a-2.gem") + assert_path_exist File.join(@gemhome, "gems", "a-1") + assert_path_not_exist File.join(gemhome2, "gems", "a-1") - assert_path_exist File.join(gemhome2, "cache", 'b-1.gem') - assert_path_not_exist File.join(@gemhome, "cache", 'b-2.gem') - assert_path_exist File.join(gemhome2, "gems", 'b-1') - assert_path_not_exist File.join(@gemhome, "gems", 'b-1') + assert_path_exist File.join(gemhome2, "cache", "b-1.gem") + assert_path_not_exist File.join(@gemhome, "cache", "b-2.gem") + assert_path_exist File.join(gemhome2, "gems", "b-1") + assert_path_not_exist File.join(@gemhome, "gems", "b-1") end def test_execute_no_gem @@ -459,21 +459,21 @@ def test_execute_no_gem end def test_execute_only_executables - a = util_spec 'a' do |s| + a = util_spec "a" do |s| s.executables = %w[foo] s.files = %w[bin/foo lib/a.rb] end - write_file File.join(@tempdir, 'lib', 'a.rb') do |fp| + write_file File.join(@tempdir, "lib", "a.rb") do |fp| fp.puts "puts __FILE__" end - write_file File.join(@tempdir, 'bin', 'foo') do |fp| + write_file File.join(@tempdir, "bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - gem_lib = File.join @gemhome, 'gems', a.full_name, 'lib', 'a.rb' - gem_exec = File.join @gemhome, 'bin', 'foo' + gem_lib = File.join @gemhome, "gems", a.full_name, "lib", "a.rb" + gem_exec = File.join @gemhome, "bin", "foo" FileUtils.rm gem_exec FileUtils.rm gem_lib @@ -489,25 +489,25 @@ def test_execute_only_executables end def test_execute_only_plugins - a = util_spec 'a' do |s| + a = util_spec "a" do |s| s.executables = %w[foo] s.files = %w[bin/foo lib/a.rb lib/rubygems_plugin.rb] end - write_file File.join(@tempdir, 'lib', 'a.rb') do |fp| + write_file File.join(@tempdir, "lib", "a.rb") do |fp| fp.puts "puts __FILE__" end - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |fp| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |fp| fp.puts "puts __FILE__" end - write_file File.join(@tempdir, 'bin', 'foo') do |fp| + write_file File.join(@tempdir, "bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - gem_lib = File.join @gemhome, 'gems', a.full_name, 'lib', 'a.rb' - gem_plugin = File.join @gemhome, 'plugins', 'a_plugin.rb' - gem_exec = File.join @gemhome, 'bin', 'foo' + gem_lib = File.join @gemhome, "gems", a.full_name, "lib", "a.rb" + gem_plugin = File.join @gemhome, "plugins", "a_plugin.rb" + gem_exec = File.join @gemhome, "bin", "foo" FileUtils.rm gem_exec FileUtils.rm gem_plugin @@ -525,24 +525,24 @@ def test_execute_only_plugins end def test_execute_bindir - a = util_spec 'a' do |s| + a = util_spec "a" do |s| s.name = "test_gem" s.executables = %w[foo] s.files = %w[bin/foo] end - write_file File.join(@tempdir, 'bin', 'foo') do |fp| + write_file File.join(@tempdir, "bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end - write_file File.join(@tempdir, 'test_bin', 'foo') do |fp| + write_file File.join(@tempdir, "test_bin", "foo") do |fp| fp.puts "#!/usr/bin/ruby" end install_gem a - gem_exec = File.join @gemhome, 'bin', 'foo' - gem_bindir = File.join @tempdir, 'test_bin', 'foo' + gem_exec = File.join @gemhome, "bin", "foo" + gem_bindir = File.join @tempdir, "test_bin", "foo" FileUtils.rm gem_exec FileUtils.rm gem_bindir @@ -558,7 +558,7 @@ def test_execute_bindir end def test_execute_unknown_gem_at_remote_source - install_specs util_spec 'a' + install_specs util_spec "a" @cmd.options[:args] = %w[a] @@ -597,16 +597,16 @@ def test_execute_default_gem end def test_execute_multi_platform - a = util_spec 'a' do |s| - s.extensions << 'ext/a/extconf.rb' + a = util_spec "a" do |s| + s.extensions << "ext/a/extconf.rb" end - b = util_spec 'b' do |s| - s.extensions << 'ext/a/extconf.rb' + b = util_spec "b" do |s| + s.extensions << "ext/a/extconf.rb" s.platform = Gem::Platform.new("java") end - ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' + ext_path = File.join @tempdir, "ext", "a", "extconf.rb" write_file ext_path do |io| io.write <<-'RUBY' File.open "Makefile", "w" do |f| @@ -632,8 +632,8 @@ def test_execute_multi_platform out = @ui.output.split "\n" - assert_equal 'Restoring gems to pristine condition...', out.shift - assert_equal 'Building native extensions. This could take a while...', + assert_equal "Restoring gems to pristine condition...", out.shift + assert_equal "Building native extensions. This could take a while...", out.shift assert_equal "Restored #{a.full_name}", out.shift assert_empty out, out.inspect diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb index 1bbd341ecacb..f38a2ae7a1d2 100644 --- a/test/rubygems/test_gem_commands_push_command.rb +++ b/test/rubygems/test_gem_commands_push_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/push_command' +require_relative "helper" +require "rubygems/commands/push_command" class TestGemCommandsPushCommand < Gem::TestCase def setup @@ -12,7 +12,7 @@ def setup Gem.host = Gem::DEFAULT_HOST Gem.configuration.disable_default_gem_server = false - @gems_dir = File.join @tempdir, 'gems' + @gems_dir = File.join @tempdir, "gems" @cache_dir = File.join @gemhome, "cache" FileUtils.mkdir @gems_dir @@ -21,7 +21,7 @@ def setup "ed244fbf2b1a52e012da8616c512fa47f9aa5250" @spec, @path = util_gem "freewill", "1.0.0" - @host = 'https://rubygems.example' + @host = "https://rubygems.example" @api_key = Gem.configuration.rubygems_api_key @fetcher = Gem::FakeFetcher.new @@ -68,7 +68,7 @@ def send_battery def test_execute @response = "Successfully registered gem: freewill (1.0.0)" - @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, "OK"] @cmd.options[:args] = [@path] @@ -81,12 +81,12 @@ def test_execute end def test_execute_host - host = 'https://other.example' + host = "https://other.example" @response = "Successfully registered gem: freewill (1.0.0)" - @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, "OK"] @fetcher.data["#{Gem.host}/api/v1/gems"] = - ['fail', 500, 'Internal Server Error'] + ["fail", 500, "Internal Server Error"] @cmd.options[:host] = host @cmd.options[:args] = [@path] @@ -101,13 +101,13 @@ def test_execute_host def test_execute_allowed_push_host @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['allowed_push_host'] = "https://privategemserver.example" + spec.metadata["allowed_push_host"] = "https://privategemserver.example" end @response = "Successfully registered gem: freewill (1.0.0)" - @fetcher.data["#{@spec.metadata['allowed_push_host']}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@spec.metadata['allowed_push_host']}/api/v1/gems"] = [@response, 200, "OK"] @fetcher.data["#{Gem.host}/api/v1/gems"] = - ['fail', 500, 'Internal Server Error'] + ["fail", 500, "Internal Server Error"] @cmd.options[:args] = [@path] @@ -136,7 +136,7 @@ def test_sending_when_default_host_disabled_with_override ENV["RUBYGEMS_HOST"] = @host Gem.configuration.disable_default_gem_server = true @response = "Successfully registered gem: freewill (1.0.0)" - @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] send_battery end @@ -145,17 +145,17 @@ def test_sending_gem_to_metadata_host @host = "http://privategemserver.example" @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['default_gem_server'] = @host + spec.metadata["default_gem_server"] = @host end @api_key = "EYKEY" keys = { - :rubygems_api_key => 'KEY', + :rubygems_api_key => "KEY", @host => @api_key, } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys @@ -163,14 +163,14 @@ def test_sending_gem_to_metadata_host FileUtils.rm Gem.configuration.credentials_path @response = "Successfully registered gem: freebird (1.0.1)" - @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] send_battery end def test_sending_gem @response = "Successfully registered gem: freewill (1.0.0)" - @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] send_battery end @@ -179,17 +179,17 @@ def test_sending_gem_to_allowed_push_host @host = "http://privategemserver.example" @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['allowed_push_host'] = @host + spec.metadata["allowed_push_host"] = @host end @api_key = "PRIVKEY" keys = { - :rubygems_api_key => 'KEY', + :rubygems_api_key => "KEY", @host => @api_key, } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys @@ -197,7 +197,7 @@ def test_sending_gem_to_allowed_push_host FileUtils.rm Gem.configuration.credentials_path @response = "Successfully registered gem: freebird (1.0.1)" - @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] send_battery end @@ -205,14 +205,14 @@ def test_sending_gem_with_env_var_api_key @host = "http://privategemserver.example" @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['allowed_push_host'] = @host + spec.metadata["allowed_push_host"] = @host end @api_key = "PRIVKEY" ENV["GEM_HOST_API_KEY"] = "PRIVKEY" @response = "Successfully registered gem: freebird (1.0.1)" - @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] send_battery end @@ -221,7 +221,7 @@ def test_sending_gem_to_allowed_push_host_with_basic_credentials @host = "http://user:password@privategemserver.example" @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['allowed_push_host'] = @sanitized_host + spec.metadata["allowed_push_host"] = @sanitized_host end @api_key = "DOESNTMATTER" @@ -230,7 +230,7 @@ def test_sending_gem_to_allowed_push_host_with_basic_credentials :rubygems_api_key => @api_key, } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys @@ -238,13 +238,13 @@ def test_sending_gem_to_allowed_push_host_with_basic_credentials FileUtils.rm Gem.configuration.credentials_path @response = "Successfully registered gem: freebird (1.0.1)" - @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] send_battery end def test_sending_gem_to_disallowed_default_host @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['allowed_push_host'] = "https://privategemserver.example" + spec.metadata["allowed_push_host"] = "https://privategemserver.example" end response = %(ERROR: "#{@host}" is not allowed by the gemspec, which only allows "https://privategemserver.example") @@ -261,17 +261,17 @@ def test_sending_gem_to_disallowed_push_host push_host = "https://privategemserver.example" @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata['allowed_push_host'] = push_host + spec.metadata["allowed_push_host"] = push_host end @api_key = "PRIVKEY" keys = { - :rubygems_api_key => 'KEY', + :rubygems_api_key => "KEY", @host => @api_key, } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys @@ -291,8 +291,8 @@ def test_sending_gem_defaulting_to_allowed_push_host host = "http://privategemserver.example" @spec, @path = util_gem "freebird", "1.0.1" do |spec| - spec.metadata.delete('default_gem_server') - spec.metadata['allowed_push_host'] = host + spec.metadata.delete("default_gem_server") + spec.metadata["allowed_push_host"] = host end api_key = "PRIVKEY" @@ -301,7 +301,7 @@ def test_sending_gem_defaulting_to_allowed_push_host host => api_key, } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys @@ -309,7 +309,7 @@ def test_sending_gem_defaulting_to_allowed_push_host FileUtils.rm Gem.configuration.credentials_path @response = "Successfully registered gem: freebird (1.0.1)" - @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK'] + @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, "OK"] # do not set @host use_ui(@ui) { @cmd.send_gem(@path) } @@ -334,7 +334,7 @@ def @cmd.sign_in(*); end def test_sending_gem_denied response = "You don't have permission to push to this gem" - @fetcher.data["#{@host}/api/v1/gems"] = [response, 403, 'Forbidden'] + @fetcher.data["#{@host}/api/v1/gems"] = [response, 403, "Forbidden"] @cmd.instance_variable_set :@host, @host assert_raise Gem::MockGemUi::TermError do @@ -349,8 +349,8 @@ def test_sending_gem_denied def test_sending_gem_key @response = "Successfully registered gem: freewill (1.0.0)" @fetcher.data["#{@host}/api/v1/gems"] = [@response, 200, "OK"] - File.open Gem.configuration.credentials_path, 'a' do |f| - f.write ':other: 701229f217cdf23b1344c7b4b54ca97' + File.open Gem.configuration.credentials_path, "a" do |f| + f.write ":other: 701229f217cdf23b1344c7b4b54ca97" end Gem.configuration.load_api_keys @@ -364,11 +364,11 @@ def test_sending_gem_key def test_otp_verified_success response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." - response_success = 'Successfully registered gem: freewill (1.0.0)' + response_success = "Successfully registered gem: freewill (1.0.0)" @fetcher.data["#{Gem.host}/api/v1/gems"] = [ - [response_fail, 401, 'Unauthorized'], - [response_success, 200, 'OK'], + [response_fail, 401, "Unauthorized"], + [response_success, 200, "OK"], ] @otp_ui = Gem::MockGemUi.new "111111\n" @@ -376,15 +376,15 @@ def test_otp_verified_success @cmd.send_gem(@path) end - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output - assert_match 'Code: ', @otp_ui.output + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @otp_ui.output + assert_match "Code: ", @otp_ui.output assert_match response_success, @otp_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_equal "111111", @fetcher.last_request["OTP"] end def test_otp_verified_failure response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." - @fetcher.data["#{Gem.host}/api/v1/gems"] = [response, 401, 'Unauthorized'] + @fetcher.data["#{Gem.host}/api/v1/gems"] = [response, 401, "Unauthorized"] @otp_ui = Gem::MockGemUi.new "111111\n" assert_raise Gem::MockGemUi::TermError do @@ -394,19 +394,19 @@ def test_otp_verified_failure end assert_match response, @otp_ui.output - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output - assert_match 'Code: ', @otp_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @otp_ui.output + assert_match "Code: ", @otp_ui.output + assert_equal "111111", @fetcher.last_request["OTP"] end def test_sending_gem_unathorized_api_key_with_mfa_enabled response_mfa_enabled = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." response_forbidden = "The API key doesn't have access" - response_success = 'Successfully registered gem: freewill (1.0.0)' + response_success = "Successfully registered gem: freewill (1.0.0)" @fetcher.data["#{@host}/api/v1/gems"] = [ - [response_mfa_enabled, 401, 'Unauthorized'], - [response_forbidden, 403, 'Forbidden'], + [response_mfa_enabled, 401, "Unauthorized"], + [response_forbidden, 403, "Forbidden"], [response_success, 200, "OK"], ] @@ -427,14 +427,14 @@ def test_sending_gem_unathorized_api_key_with_mfa_enabled assert_match "Password:", @ui.output assert_match "Added push_rubygem scope to the existing API key", @ui.output assert_match response_success, @ui.output - assert_equal '11111', @fetcher.last_request['OTP'] + assert_equal "11111", @fetcher.last_request["OTP"] end def test_sending_gem_with_no_local_creds Gem.configuration.rubygems_api_key = nil response_mfa_enabled = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." - response_success = 'Successfully registered gem: freewill (1.0.0)' + response_success = "Successfully registered gem: freewill (1.0.0)" response_profile = "mfa: disabled\n" @fetcher.data["#{@host}/api/v1/gems"] = [ @@ -442,7 +442,7 @@ def test_sending_gem_with_no_local_creds ] @fetcher.data["#{@host}/api/v1/api_key"] = [ - [response_mfa_enabled, 401, 'Unauthorized'], + [response_mfa_enabled, 401, "Unauthorized"], ["", 200, "OK"], ] @@ -466,7 +466,7 @@ def test_sending_gem_with_no_local_creds assert_match "Password:", @ui.output assert_match "Signed in with API key:", @ui.output assert_match response_success, @ui.output - assert_equal '11111', @fetcher.last_request['OTP'] + assert_equal "11111", @fetcher.last_request["OTP"] end private diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb index 0cc88b16851c..6882098c53de 100644 --- a/test/rubygems/test_gem_commands_query_command.rb +++ b/test/rubygems/test_gem_commands_query_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/query_command' +require_relative "helper" +require "rubygems/commands/query_command" module TestGemCommandsQueryCommandSetup def setup @@ -41,7 +41,7 @@ def test_execute EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_all @@ -64,7 +64,7 @@ def test_execute_all EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_all_prerelease @@ -87,15 +87,15 @@ def test_execute_all_prerelease EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_details spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 4 - s.authors = ['Abraham Lincoln', 'Hirohito'] - s.homepage = 'http://a.example.com/' + fetcher.spec "a", 2 do |s| + s.summary = "This is a lot of text. " * 4 + s.authors = ["Abraham Lincoln", "Hirohito"] + s.homepage = "http://a.example.com/" end fetcher.legacy_platform @@ -127,13 +127,13 @@ def test_execute_details EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_details_cleans_text spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 4 + fetcher.spec "a", 2 do |s| + s.summary = "This is a lot of text. " * 4 s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"] s.homepage = "http://a.example.com/\x03" end @@ -167,13 +167,13 @@ def test_execute_details_cleans_text EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_details_truncates_summary spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 10_000 + fetcher.spec "a", 2 do |s| + s.summary = "This is a lot of text. " * 10_000 s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"] s.homepage = "http://a.example.com/\x03" end @@ -207,7 +207,7 @@ def test_execute_details_truncates_summary EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_installed @@ -220,7 +220,7 @@ def test_execute_installed end assert_equal "true\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_installed_inverse @@ -233,7 +233,7 @@ def test_execute_installed_inverse end assert_equal "false\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error assert_equal 1, e.exit_code end @@ -248,7 +248,7 @@ def test_execute_installed_inverse_not_installed end assert_equal "true\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_installed_no_name @@ -260,7 +260,7 @@ def test_execute_installed_no_name end end - assert_equal '', @stub_ui.output + assert_equal "", @stub_ui.output assert_equal "ERROR: You must specify a gem name\n", @stub_ui.error assert_equal 4, e.exit_code @@ -276,7 +276,7 @@ def test_execute_installed_not_installed end assert_equal "false\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error assert_equal 1, e.exit_code end @@ -291,7 +291,7 @@ def test_execute_installed_version end assert_equal "true\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_installed_version_not_installed @@ -304,7 +304,7 @@ def test_execute_installed_version_not_installed end assert_equal "false\n", @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error assert_equal 1, e.exit_code end @@ -329,7 +329,7 @@ def test_execute_local EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_local_notty @@ -351,7 +351,7 @@ def test_execute_local_notty EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_local_quiet @@ -372,7 +372,7 @@ def test_execute_local_quiet EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_no_versions @@ -395,7 +395,7 @@ def test_execute_no_versions EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_notty @@ -417,7 +417,7 @@ def test_execute_notty EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_prerelease @@ -435,7 +435,7 @@ def test_execute_prerelease EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_prerelease_local @@ -502,7 +502,7 @@ def test_execute_remote EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_remote_notty @@ -524,7 +524,7 @@ def test_execute_remote_notty EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_remote_quiet @@ -545,16 +545,16 @@ def test_execute_remote_quiet EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_make_entry - a_2_name = @specs['a-2'].original_name + a_2_name = @specs["a-2"].original_name @stub_fetcher.data.delete \ "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz" - a2 = @specs['a-2'] + a2 = @specs["a-2"] entry_tuples = [ [Gem::NameTuple.new(a2.name, a2.version, a2.platform), Gem.sources.first], @@ -564,7 +564,7 @@ def test_make_entry entry = @cmd.send :make_entry, entry_tuples, platforms - assert_equal 'a (2)', entry + assert_equal "a (2)", entry end # Test for multiple args handling! @@ -581,7 +581,7 @@ def test_execute_multiple_args assert_match %r{^a }, @stub_ui.output assert_match %r{^pl }, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_show_gems @@ -601,9 +601,9 @@ def test_show_gems def add_gems_to_fetcher spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" end end end @@ -613,13 +613,13 @@ class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase def test_execute_platform spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 1 do |s| - s.platform = 'x86-linux' + fetcher.spec "a", 1 + fetcher.spec "a", 1 do |s| + s.platform = "x86-linux" end - fetcher.spec 'a', 2 do |s| - s.platform = 'universal-darwin' + fetcher.spec "a", 2 do |s| + s.platform = "universal-darwin" end end @@ -637,13 +637,13 @@ def test_execute_platform EOF assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error + assert_equal "", @stub_ui.error end def test_execute_show_default_gems - spec_fetcher {|fetcher| fetcher.spec 'a', 2 } + spec_fetcher {|fetcher| fetcher.spec "a", 2 } - a1 = new_default_spec 'a', 1 + a1 = new_default_spec "a", 1 install_default_gems a1 use_ui @stub_ui do @@ -661,8 +661,8 @@ def test_execute_show_default_gems end def test_execute_show_default_gems_with_platform - a1 = new_default_spec 'a', 1 - a1.platform = 'java' + a1 = new_default_spec "a", 1 + a1.platform = "java" install_default_gems a1 use_ui @stub_ui do @@ -681,10 +681,10 @@ def test_execute_show_default_gems_with_platform def test_execute_default_details spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 end - a1 = new_default_spec 'a', 1 + a1 = new_default_spec "a", 1 install_default_gems a1 @cmd.handle_options %w[-l -d] @@ -711,15 +711,15 @@ def test_execute_default_details def test_execute_local_details spec_fetcher do |fetcher| - fetcher.spec 'a', 1 do |s| - s.platform = 'x86-linux' + fetcher.spec "a", 1 do |s| + s.platform = "x86-linux" end - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 4 - s.authors = ['Abraham Lincoln', 'Hirohito'] - s.homepage = 'http://a.example.com/' - s.platform = 'universal-darwin' + fetcher.spec "a", 2 do |s| + s.summary = "This is a lot of text. " * 4 + s.authors = ["Abraham Lincoln", "Hirohito"] + s.homepage = "http://a.example.com/" + s.platform = "universal-darwin" end fetcher.legacy_platform @@ -766,9 +766,9 @@ def test_execute_local_details def test_execute_exact_remote spec_fetcher do |fetcher| - fetcher.spec 'coolgem-omg', 3 - fetcher.spec 'coolgem', '4.2.1' - fetcher.spec 'wow_coolgem', 1 + fetcher.spec "coolgem-omg", 3 + fetcher.spec "coolgem", "4.2.1" + fetcher.spec "wow_coolgem", 1 end @cmd.handle_options %w[--remote --exact coolgem] @@ -789,9 +789,9 @@ def test_execute_exact_remote def test_execute_exact_local spec_fetcher do |fetcher| - fetcher.spec 'coolgem-omg', 3 - fetcher.spec 'coolgem', '4.2.1' - fetcher.spec 'wow_coolgem', 1 + fetcher.spec "coolgem-omg", 3 + fetcher.spec "coolgem", "4.2.1" + fetcher.spec "wow_coolgem", 1 end @cmd.handle_options %w[--exact coolgem] @@ -812,13 +812,13 @@ def test_execute_exact_local def test_execute_exact_multiple spec_fetcher do |fetcher| - fetcher.spec 'coolgem-omg', 3 - fetcher.spec 'coolgem', '4.2.1' - fetcher.spec 'wow_coolgem', 1 + fetcher.spec "coolgem-omg", 3 + fetcher.spec "coolgem", "4.2.1" + fetcher.spec "wow_coolgem", 1 - fetcher.spec 'othergem-omg', 3 - fetcher.spec 'othergem', '1.2.3' - fetcher.spec 'wow_othergem', 1 + fetcher.spec "othergem-omg", 3 + fetcher.spec "othergem", "1.2.3" + fetcher.spec "wow_othergem", 1 end @cmd.handle_options %w[--exact coolgem othergem] @@ -849,9 +849,9 @@ def test_depprecated def add_gems_to_fetcher spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 - fetcher.download 'a', '3.a' + fetcher.download "a", 1 + fetcher.download "a", 2 + fetcher.download "a", "3.a" end end end diff --git a/test/rubygems/test_gem_commands_search_command.rb b/test/rubygems/test_gem_commands_search_command.rb index 6397dbd4d45f..afa6ff8d1392 100644 --- a/test/rubygems/test_gem_commands_search_command.rb +++ b/test/rubygems/test_gem_commands_search_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/search_command' +require_relative "helper" +require "rubygems/commands/search_command" class TestGemCommandsSearchCommand < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_commands_server_command.rb b/test/rubygems/test_gem_commands_server_command.rb index 96c328f93fa2..1becde3ae20a 100644 --- a/test/rubygems/test_gem_commands_server_command.rb +++ b/test/rubygems/test_gem_commands_server_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/server_command' +require_relative "helper" +require "rubygems/commands/server_command" class TestGemCommandsServerCommand < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index aa5feb9074ae..1c0963ee96ce 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 @@ def setup 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 @@ def setup 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 @@ def test_execute_regenerate_binstubs 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 @@ def test_execute_no_regenerate_binstubs 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 @@ def test_execute_regenerate_plugins 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 @@ def test_execute_no_regenerate_plugins 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 @@ def test_execute_informs_about_installed_executables 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 @@ def test_env_shebang_flag 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 @@ def test_install_default_bundler_gem 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 @@ def test_install_default_bundler_gem_with_default_gems_not_installed_at_default_ 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 @@ def test_install_default_bundler_gem_with_destdir_flag 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 @@ def test_install_default_bundler_gem_with_destdir_flag 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 @@ def test_install_default_bundler_gem_with_destdir_flag 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 @@ def test_install_default_bundler_gem_with_destdir_and_prefix_flags @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 @@ def test_remove_old_lib_files 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 @@ def test_show_release_notes @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 @@ def create_dummy_files(list) 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 @@ def gem_install(name) 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 @@ def gem_install_with_plugin(name) 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 @@ def bundler_version 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? diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index cfc0b570e339..0f8e4788407e 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/signin_command' -require 'rubygems/installer' +require_relative "helper" +require "rubygems/commands/signin_command" +require "rubygems/installer" class TestGemCommandsSigninCommand < Gem::TestCase def setup @@ -34,7 +34,7 @@ def test_execute_when_not_already_signed_in_and_not_preexisting_credentials_fold end def test_execute_when_already_signed_in_with_same_host - host = 'http://some-gemcutter-compatible-host.org' + host = "http://some-gemcutter-compatible-host.org" util_capture(nil, host) { @cmd.execute } old_credentials = load_yaml_file Gem.configuration.credentials_path @@ -46,10 +46,10 @@ def test_execute_when_already_signed_in_with_same_host end def test_execute_when_already_signed_in_with_different_host - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx" util_capture(nil, nil, api_key) { @cmd.execute } - host = 'http://some-gemcutter-compatible-host.org' + host = "http://some-gemcutter-compatible-host.org" util_capture(nil, host, api_key) { @cmd.execute } credentials = load_yaml_file Gem.configuration.credentials_path @@ -60,13 +60,13 @@ def test_execute_when_already_signed_in_with_different_host end def test_execute_with_host_supplied - host = 'http://some-gemcutter-compatible-host.org' + host = "http://some-gemcutter-compatible-host.org" sign_in_ui = util_capture(nil, host) { @cmd.execute } assert_match %r{Enter your #{host} credentials.}, sign_in_ui.output assert_match %r{Signed in.}, sign_in_ui.output - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[host] end @@ -74,16 +74,16 @@ def test_execute_with_host_supplied def test_execute_with_valid_creds_set_for_default_host util_capture { @cmd.execute } - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[:rubygems_api_key] end def test_execute_with_key_name_and_scope - email = 'you@example.com' - password = 'secret' - api_key = '1234' + email = "you@example.com" + password = "secret" + api_key = "1234" fetcher = Gem::RemoteFetcher.fetcher key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\n" @@ -106,9 +106,9 @@ def test_execute_with_key_name_and_scope end def test_execute_with_key_name_scope_and_mfa_level_of_ui_only - email = 'you@example.com' - password = 'secret' - api_key = '1234' + email = "you@example.com" + password = "secret" + api_key = "1234" fetcher = Gem::RemoteFetcher.fetcher mfa_level = "ui_only" @@ -133,9 +133,9 @@ def test_execute_with_key_name_scope_and_mfa_level_of_ui_only end def test_execute_with_key_name_scope_and_mfa_level_of_gem_signin - email = 'you@example.com' - password = 'secret' - api_key = '1234' + email = "you@example.com" + password = "secret" + api_key = "1234" fetcher = Gem::RemoteFetcher.fetcher mfa_level = "ui_and_gem_signin" @@ -160,19 +160,19 @@ def test_execute_with_key_name_scope_and_mfa_level_of_gem_signin end def test_execute_on_gemserver_without_profile_me_endpoint - host = 'http://some-gemcutter-compatible-host.org' + host = "http://some-gemcutter-compatible-host.org" - email = 'you@example.com' - password = 'secret' - api_key = '1234' + email = "you@example.com" + password = "secret" + api_key = "1234" fetcher = Gem::RemoteFetcher.fetcher key_name_ui = Gem::MockGemUi.new "#{email}\n#{password}\ntest-key\n\ny\n\n\n\n\n\ny" # Set the expected response for the Web-API supplied - ENV['RUBYGEMS_HOST'] = host + ENV["RUBYGEMS_HOST"] = host data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key" - fetcher.data[data_key] = [api_key, 200, 'OK'] + fetcher.data[data_key] = [api_key, 200, "OK"] use_ui key_name_ui do @cmd.execute @@ -194,14 +194,14 @@ def test_execute_on_gemserver_without_profile_me_endpoint # Utility method to capture IO/UI within the block passed def util_capture(ui_stub = nil, host = nil, api_key = nil, fetcher = Gem::FakeFetcher.new, mfa_level = "disabled") - api_key ||= 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - response = [api_key, 200, 'OK'] - profile_response = [ "mfa: #{mfa_level}\n" , 200, 'OK'] - email = 'you@example.com' - password = 'secret' + api_key ||= "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" + response = [api_key, 200, "OK"] + profile_response = [ "mfa: #{mfa_level}\n" , 200, "OK"] + email = "you@example.com" + password = "secret" # Set the expected response for the Web-API supplied - ENV['RUBYGEMS_HOST'] = host || Gem::DEFAULT_HOST + ENV["RUBYGEMS_HOST"] = host || Gem::DEFAULT_HOST data_key = "#{ENV['RUBYGEMS_HOST']}/api/v1/api_key" fetcher.data[data_key] = response profile = "#{ENV['RUBYGEMS_HOST']}/api/v1/profile/me.yaml" diff --git a/test/rubygems/test_gem_commands_signout_command.rb b/test/rubygems/test_gem_commands_signout_command.rb index aa6300b6ab9d..992b127a9495 100644 --- a/test/rubygems/test_gem_commands_signout_command.rb +++ b/test/rubygems/test_gem_commands_signout_command.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/signout_command' -require 'rubygems/installer' +require_relative "helper" +require "rubygems/commands/signout_command" +require "rubygems/installer" class TestGemCommandsSignoutCommand < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb index f10347a6dccc..b7c164c0e60a 100644 --- a/test/rubygems/test_gem_commands_sources_command.rb +++ b/test/rubygems/test_gem_commands_sources_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/sources_command' +require_relative "helper" +require "rubygems/commands/sources_command" class TestGemCommandsSourcesCommand < Gem::TestCase def setup @@ -20,7 +20,7 @@ def teardown end def test_initialize_proxy - assert @cmd.handles?(['--http-proxy', 'http://proxy.example.com']) + assert @cmd.handles?(["--http-proxy", "http://proxy.example.com"]) end def test_execute @@ -37,12 +37,12 @@ def test_execute EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end specs = Gem::Specification.map do |spec| @@ -70,7 +70,7 @@ def test_execute_add EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add_allow_typo_squatting_source @@ -181,7 +181,7 @@ def test_execute_add_nonexistent_source uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz" @fetcher.data[uri] = proc do - raise Gem::RemoteFetcher::FetchError.new('it died', uri) + raise Gem::RemoteFetcher::FetchError.new("it died", uri) end @cmd.handle_options %w[--add http://beta-gems.example.com] @@ -198,7 +198,7 @@ def test_execute_add_nonexistent_source EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add_existent_source_invalid_uri @@ -208,7 +208,7 @@ def test_execute_add_existent_source_invalid_uri @cmd.handle_options %w[--add https://u:p@example.com] @fetcher.data[uri] = proc do - raise Gem::RemoteFetcher::FetchError.new('it died', uri) + raise Gem::RemoteFetcher::FetchError.new("it died", uri) end use_ui @ui do @@ -223,7 +223,7 @@ def test_execute_add_existent_source_invalid_uri EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_the_uri_password @@ -233,7 +233,7 @@ def test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_ @cmd.handle_options %w[--add https://u:secret@example.com] @fetcher.data[uri] = proc do - raise Gem::RemoteFetcher::FetchError.new('it secretly died', uri) + raise Gem::RemoteFetcher::FetchError.new("it secretly died", uri) end use_ui @ui do @@ -248,7 +248,7 @@ def test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_ EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add_redundant_source @@ -267,7 +267,7 @@ def test_execute_add_redundant_source EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add_redundant_source_trailing_slash @@ -287,7 +287,7 @@ def test_execute_add_redundant_source_trailing_slash EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error # Re-add pre-existing gem source (w/o slash) repo_without_slash = "http://gems.example.com" @@ -304,7 +304,7 @@ def test_execute_add_redundant_source_trailing_slash EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error # Re-add original gem source (w/ slash) @cmd.handle_options %W[--add #{repo_with_slash}] @@ -321,14 +321,14 @@ def test_execute_add_redundant_source_trailing_slash EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_add_http_rubygems_org - http_rubygems_org = 'http://rubygems.org/' + http_rubygems_org = "http://rubygems.org/" spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end specs = Gem::Specification.map do |spec| @@ -393,10 +393,10 @@ def test_execute_add_http_rubygems_org_forced end def test_execute_add_https_rubygems_org - https_rubygems_org = 'https://rubygems.org/' + https_rubygems_org = "https://rubygems.org/" spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end specs = Gem::Specification.map do |spec| @@ -446,7 +446,7 @@ def test_execute_add_bad_uri EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_clear_all @@ -461,10 +461,10 @@ def test_execute_clear_all EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error dir = Gem.spec_cache_dir - refute File.exist?(dir), 'cache dir removed' + refute File.exist?(dir), "cache dir removed" end def test_execute_list @@ -481,7 +481,7 @@ def test_execute_list EOF assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_remove @@ -494,7 +494,7 @@ def test_execute_remove expected = "#{@gem_repo} removed from sources\n" assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_remove_no_network @@ -513,14 +513,14 @@ def test_execute_remove_no_network expected = "#{@gem_repo} removed from sources\n" assert_equal expected, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_update @cmd.handle_options %w[--update] spec_fetcher do |fetcher| - fetcher.gem 'a', 1 + fetcher.gem "a", 1 end use_ui @ui do @@ -528,6 +528,6 @@ def test_execute_update end assert_equal "source cache successfully updated\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end end diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb index c8cb7df32eb2..7564baa2ca41 100644 --- a/test/rubygems/test_gem_commands_specification_command.rb +++ b/test/rubygems/test_gem_commands_specification_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/specification_command' +require_relative "helper" +require "rubygems/commands/specification_command" class TestGemCommandsSpecificationCommand < Gem::TestCase def setup @@ -10,7 +10,7 @@ def setup end def test_execute - foo = util_spec 'foo' + foo = util_spec "foo" install_specs foo @@ -22,12 +22,12 @@ def test_execute assert_match %r{Gem::Specification}, @ui.output assert_match %r{name: foo}, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_all - install_specs util_spec 'foo', '0.0.1' - install_specs util_spec 'foo', '0.0.2' + install_specs util_spec "foo", "0.0.1" + install_specs util_spec "foo", "0.0.2" @cmd.options[:args] = %w[foo] @cmd.options[:all] = true @@ -40,12 +40,12 @@ def test_execute_all assert_match %r{name: foo}, @ui.output assert_match %r{version: 0.0.1}, @ui.output assert_match %r{version: 0.0.2}, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_all_conflicts_with_version - util_spec 'foo', '0.0.1' - util_spec 'foo', '0.0.2' + util_spec "foo", "0.0.1" + util_spec "foo", "0.0.2" @cmd.options[:args] = %w[foo] @cmd.options[:all] = true @@ -57,7 +57,7 @@ def test_execute_all_conflicts_with_version end end - assert_equal '', @ui.output + assert_equal "", @ui.output assert_equal "ERROR: Specify --all or -v, not both\n", @ui.error end @@ -70,7 +70,7 @@ def test_execute_bad_name end end - assert_equal '', @ui.output + assert_equal "", @ui.output assert_equal "ERROR: No gem matching 'foo (>= 0)' found\n", @ui.error end @@ -84,13 +84,13 @@ def test_execute_bad_name_with_version end end - assert_equal '', @ui.output + assert_equal "", @ui.output assert_equal "ERROR: No gem matching 'foo (= 1.3.2)' found\n", @ui.error end def test_execute_exact_match - install_specs util_spec 'foo' - install_specs util_spec 'foo_bar' + install_specs util_spec "foo" + install_specs util_spec "foo_bar" @cmd.options[:args] = %w[foo] @@ -100,11 +100,11 @@ def test_execute_exact_match assert_match %r{Gem::Specification}, @ui.output assert_match %r{name: foo}, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_field - foo = util_spec 'foo', '2' + foo = util_spec "foo", "2" install_specs foo @@ -118,7 +118,7 @@ def test_execute_field end def test_execute_file - foo = util_spec 'foo' do |s| + foo = util_spec "foo" do |s| s.files = %w[lib/code.rb] end @@ -132,11 +132,11 @@ def test_execute_file assert_match %r{Gem::Specification}, @ui.output assert_match %r{name: foo}, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_marshal - foo = util_spec 'foo', '2' + foo = util_spec "foo", "2" install_specs foo @@ -148,12 +148,12 @@ def test_execute_marshal end assert_equal foo, Marshal.load(@ui.output) - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_remote spec_fetcher do |fetcher| - fetcher.spec 'foo', 1 + fetcher.spec "foo", 1 end @cmd.options[:args] = %w[foo] @@ -169,8 +169,8 @@ def test_execute_remote def test_execute_remote_with_version spec_fetcher do |fetcher| - fetcher.spec 'foo', "1" - fetcher.spec 'foo', "2" + fetcher.spec "foo", "1" + fetcher.spec "foo", "2" end @cmd.options[:args] = %w[foo] @@ -190,9 +190,9 @@ def test_execute_remote_with_version_and_platform original_platforms = Gem.platforms.dup spec_fetcher do |fetcher| - fetcher.spec 'foo', "1" - fetcher.spec 'foo', "1" do |s| - s.platform = 'x86_64-linux' + fetcher.spec "foo", "1" + fetcher.spec "foo", "1" do |s| + s.platform = "x86_64-linux" end end @@ -216,8 +216,8 @@ def test_execute_remote_with_version_and_platform def test_execute_remote_without_prerelease spec_fetcher do |fetcher| - fetcher.spec 'foo', '2.0.0' - fetcher.spec 'foo', '2.0.1.pre' + fetcher.spec "foo", "2.0.0" + fetcher.spec "foo", "2.0.1.pre" end @cmd.options[:args] = %w[foo] @@ -237,8 +237,8 @@ def test_execute_remote_without_prerelease def test_execute_remote_with_prerelease spec_fetcher do |fetcher| - fetcher.spec 'foo', '2.0.0' - fetcher.spec 'foo', '2.0.1.pre' + fetcher.spec "foo", "2.0.0" + fetcher.spec "foo", "2.0.1.pre" end @cmd.options[:args] = %w[foo] @@ -258,7 +258,7 @@ def test_execute_remote_with_prerelease end def test_execute_ruby - foo = util_spec 'foo' + foo = util_spec "foo" install_specs foo @@ -271,6 +271,6 @@ def test_execute_ruby assert_match %r{Gem::Specification.new}, @ui.output assert_match %r{s.name = "foo"}, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end end diff --git a/test/rubygems/test_gem_commands_stale_command.rb b/test/rubygems/test_gem_commands_stale_command.rb index 83bd3e5defe2..99eb23fb30cf 100644 --- a/test/rubygems/test_gem_commands_stale_command.rb +++ b/test/rubygems/test_gem_commands_stale_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/stale_command' +require_relative "helper" +require "rubygems/commands/stale_command" class TestGemCommandsStaleCommand < Gem::TestCase def setup @@ -11,12 +11,12 @@ def setup def test_execute_sorts files = %w[lib/foo_bar.rb Rakefile] - foo_bar = util_spec 'foo_bar' do |gem| + foo_bar = util_spec "foo_bar" do |gem| gem.files = files end install_specs foo_bar - bar_baz = util_spec 'bar_baz' do |gem| + bar_baz = util_spec "bar_baz" do |gem| gem.files = files end install_specs bar_baz diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index 5bd2c40d593f..083b831c98c1 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative 'installer_test_case' -require 'rubygems/commands/uninstall_command' +require_relative "installer_test_case" +require "rubygems/commands/uninstall_command" class TestGemCommandsUninstallCommand < Gem::InstallerTestCase def setup super @cmd = Gem::Commands::UninstallCommand.new - @executable = File.join(@gemhome, 'bin', 'executable') + @executable = File.join(@gemhome, "bin", "executable") end def test_execute_all_named @@ -14,20 +14,20 @@ def test_execute_all_named util_make_gems - default = new_default_spec 'default', '1' + default = new_default_spec "default", "1" install_default_gems default gemhome2 = "#{@gemhome}2" - a_4, = util_gem 'a', 4 + a_4, = util_gem "a", 4 install_gem a_4, :install_dir => gemhome2 Gem::Specification.dirs = [@gemhome, gemhome2] - assert_includes Gem::Specification.all_names, 'a-1' - assert_includes Gem::Specification.all_names, 'a-4' - assert_includes Gem::Specification.all_names, 'b-2' - assert_includes Gem::Specification.all_names, 'default-1' + assert_includes Gem::Specification.all_names, "a-1" + assert_includes Gem::Specification.all_names, "a-4" + assert_includes Gem::Specification.all_names, "b-2" + assert_includes Gem::Specification.all_names, "default-1" @cmd.options[:all] = true @cmd.options[:args] = %w[a] @@ -41,10 +41,10 @@ def test_execute_all_named end def test_execute_all_named_default_single - z_1 = new_default_spec 'z', '1' + z_1 = new_default_spec "z", "1" install_default_gems z_1 - assert_includes Gem::Specification.all_names, 'z-1' + assert_includes Gem::Specification.all_names, "z-1" @cmd.options[:all] = true @cmd.options[:args] = %w[z] @@ -57,18 +57,18 @@ def test_execute_all_named_default_single output = @ui.output.split "\n" - assert_equal 'Gem z-1 cannot be uninstalled because it is a default gem', output.shift + assert_equal "Gem z-1 cannot be uninstalled because it is a default gem", output.shift end def test_execute_all_named_default_multiple - z_1 = new_default_spec 'z', '1' + z_1 = new_default_spec "z", "1" install_default_gems z_1 - z_2, = util_gem 'z', 2 + z_2, = util_gem "z", 2 install_gem z_2 - assert_includes Gem::Specification.all_names, 'z-1' - assert_includes Gem::Specification.all_names, 'z-2' + assert_includes Gem::Specification.all_names, "z-1" + assert_includes Gem::Specification.all_names, "z-2" @cmd.options[:all] = true @cmd.options[:args] = %w[z] @@ -81,15 +81,15 @@ def test_execute_all_named_default_multiple output = @ui.output.split "\n" - assert_equal 'Gem z-1 cannot be uninstalled because it is a default gem', output.shift - assert_equal 'Successfully uninstalled z-2', output.shift + assert_equal "Gem z-1 cannot be uninstalled because it is a default gem", output.shift + assert_equal "Successfully uninstalled z-2", output.shift end def test_execute_dependency_order initial_install - c = quick_gem 'c' do |spec| - spec.add_dependency 'a' + c = quick_gem "c" do |spec| + spec.add_dependency "a" end util_build_gem c @@ -110,9 +110,9 @@ def test_execute_dependency_order output = ui.output.split "\n" - assert_equal 'Successfully uninstalled c-2', output.shift + assert_equal "Successfully uninstalled c-2", output.shift assert_equal "Removing executable", output.shift - assert_equal 'Successfully uninstalled a-2', output.shift + assert_equal "Successfully uninstalled a-2", output.shift end def test_execute_removes_executable @@ -149,12 +149,12 @@ def test_execute_removes_formatted_executable FileUtils.rm_f @executable # Wish this didn't happen in #setup - Gem::Installer.exec_format = 'foo-%s-bar' + Gem::Installer.exec_format = "foo-%s-bar" installer.format_executable = true installer.install - formatted_executable = File.join @gemhome, 'bin', 'foo-executable-bar' + formatted_executable = File.join @gemhome, "bin", "foo-executable-bar" assert_equal true, File.exist?(formatted_executable) @cmd.options[:executables] = true @@ -197,19 +197,19 @@ def test_execute_with_version_leaves_non_matching_versions util_make_gems - assert_equal 3, Gem::Specification.find_all_by_name('a').length + assert_equal 3, Gem::Specification.find_all_by_name("a").length - @cmd.options[:version] = '1' + @cmd.options[:version] = "1" @cmd.options[:force] = true - @cmd.options[:args] = ['a'] + @cmd.options[:args] = ["a"] use_ui ui do @cmd.execute end - assert_equal 2, Gem::Specification.find_all_by_name('a').length + assert_equal 2, Gem::Specification.find_all_by_name("a").length - assert File.exist? File.join(@gemhome, 'bin', 'executable') + assert File.exist? File.join(@gemhome, "bin", "executable") end def test_execute_with_version_specified_as_colon @@ -219,18 +219,18 @@ def test_execute_with_version_specified_as_colon util_make_gems - assert_equal 3, Gem::Specification.find_all_by_name('a').length + assert_equal 3, Gem::Specification.find_all_by_name("a").length @cmd.options[:force] = true - @cmd.options[:args] = ['a:1'] + @cmd.options[:args] = ["a:1"] use_ui ui do @cmd.execute end - assert_equal 2, Gem::Specification.find_all_by_name('a').length + assert_equal 2, Gem::Specification.find_all_by_name("a").length - assert File.exist? File.join(@gemhome, 'bin', 'executable') + assert File.exist? File.join(@gemhome, "bin", "executable") end def test_uninstall_selection @@ -238,22 +238,22 @@ def test_uninstall_selection util_make_gems - list = Gem::Specification.find_all_by_name 'a' + list = Gem::Specification.find_all_by_name "a" - @cmd.options[:args] = ['a'] + @cmd.options[:args] = ["a"] use_ui ui do @cmd.execute end - updated_list = Gem::Specification.find_all_by_name('a') + updated_list = Gem::Specification.find_all_by_name("a") assert_equal list.length - 1, updated_list.length - assert_match ' 1. a-1', ui.output - assert_match ' 2. a-2', ui.output - assert_match ' 3. a-3.a', ui.output - assert_match ' 4. All versions', ui.output - assert_match 'uninstalled a-1', ui.output + assert_match " 1. a-1", ui.output + assert_match " 2. a-2", ui.output + assert_match " 3. a-3.a", ui.output + assert_match " 4. All versions", ui.output + assert_match "uninstalled a-1", ui.output end def test_uninstall_selection_multiple_gems @@ -261,31 +261,31 @@ def test_uninstall_selection_multiple_gems util_make_gems - a_list = Gem::Specification.find_all_by_name('a') - b_list = Gem::Specification.find_all_by_name('b') + a_list = Gem::Specification.find_all_by_name("a") + b_list = Gem::Specification.find_all_by_name("b") list = a_list + b_list - @cmd.options[:args] = ['a', 'b'] + @cmd.options[:args] = ["a", "b"] use_ui ui do @cmd.execute end - updated_a_list = Gem::Specification.find_all_by_name('a') - updated_b_list = Gem::Specification.find_all_by_name('b') + updated_a_list = Gem::Specification.find_all_by_name("a") + updated_b_list = Gem::Specification.find_all_by_name("b") updated_list = updated_a_list + updated_b_list assert_equal list.length - 2, updated_list.length out = ui.output.split("\n") - assert_match 'uninstalled b-2', out.shift - assert_match '', out.shift - assert_match 'Select gem to uninstall:', out.shift - assert_match ' 1. a-1', out.shift - assert_match ' 2. a-2', out.shift - assert_match ' 3. a-3.a', out.shift - assert_match ' 4. All versions', out.shift - assert_match 'uninstalled a-1', out.shift + assert_match "uninstalled b-2", out.shift + assert_match "", out.shift + assert_match "Select gem to uninstall:", out.shift + assert_match " 1. a-1", out.shift + assert_match " 2. a-2", out.shift + assert_match " 3. a-3.a", out.shift + assert_match " 4. All versions", out.shift + assert_match "uninstalled a-1", out.shift assert_empty out end @@ -294,22 +294,22 @@ def test_execute_with_force_and_without_version_uninstalls_everything ui = Gem::MockGemUi.new "y\n" - a_1, = util_gem 'a', 1 + a_1, = util_gem "a", 1 install_gem a_1 - a_3a, = util_gem 'a', '3.a' + a_3a, = util_gem "a", "3.a" install_gem a_3a - assert_equal 3, Gem::Specification.find_all_by_name('a').length + assert_equal 3, Gem::Specification.find_all_by_name("a").length @cmd.options[:force] = true - @cmd.options[:args] = ['a'] + @cmd.options[:args] = ["a"] use_ui ui do @cmd.execute end - assert_empty Gem::Specification.find_all_by_name('a') + assert_empty Gem::Specification.find_all_by_name("a") assert_match "Removing executable", ui.output refute File.exist? @executable end @@ -321,36 +321,36 @@ def test_execute_with_force_ignores_dependencies util_make_gems - assert Gem::Specification.find_all_by_name('dep_x').length > 0 - assert Gem::Specification.find_all_by_name('x').length > 0 + assert Gem::Specification.find_all_by_name("dep_x").length > 0 + assert Gem::Specification.find_all_by_name("x").length > 0 @cmd.options[:force] = true - @cmd.options[:args] = ['x'] + @cmd.options[:args] = ["x"] use_ui ui do @cmd.execute end - assert Gem::Specification.find_all_by_name('dep_x').length > 0 - assert Gem::Specification.find_all_by_name('x').length.zero? + assert Gem::Specification.find_all_by_name("dep_x").length > 0 + assert Gem::Specification.find_all_by_name("x").length.zero? end def test_execute_all util_make_gems - default = new_default_spec 'default', '1' + default = new_default_spec "default", "1" install_default_gems default gemhome2 = "#{@gemhome}2" - a_4, = util_gem 'a', 4 + a_4, = util_gem "a", 4 install_gem a_4 Gem::Specification.dirs = [@gemhome, gemhome2] - assert_includes Gem::Specification.all_names, 'a-1' - assert_includes Gem::Specification.all_names, 'a-4' - assert_includes Gem::Specification.all_names, 'default-1' + assert_includes Gem::Specification.all_names, "a-1" + assert_includes Gem::Specification.all_names, "a-4" + assert_includes Gem::Specification.all_names, "default-1" @cmd.options[:all] = true @cmd.options[:args] = [] @@ -368,14 +368,14 @@ def test_execute_outside_gem_home gemhome2 = "#{@gemhome}2" - a_4, = util_gem 'a', 4 + a_4, = util_gem "a", 4 install_gem a_4 , :install_dir => gemhome2 Gem::Specification.dirs = [@gemhome, gemhome2] - assert_includes Gem::Specification.all_names, 'a-4' + assert_includes Gem::Specification.all_names, "a-4" - @cmd.options[:args] = ['a:4'] + @cmd.options[:args] = ["a:4"] e = assert_raise Gem::InstallError do use_ui ui do @@ -397,7 +397,7 @@ def test_handle_options end def test_handle_options_vendor - vendordir(File.join(@tempdir, 'vendor')) do + vendordir(File.join(@tempdir, "vendor")) do use_ui @ui do @cmd.handle_options %w[--vendor] end @@ -440,7 +440,7 @@ def test_handle_options_vendor_missing @cmd.handle_options %w[--vendor] end - assert_equal 'invalid option: --vendor your platform is not supported', + assert_equal "invalid option: --vendor your platform is not supported", e.message refute @cmd.options[:vendor] @@ -449,7 +449,7 @@ def test_handle_options_vendor_missing end def test_execute_with_gem_not_installed - @cmd.options[:args] = ['d'] + @cmd.options[:args] = ["d"] use_ui ui do @cmd.execute diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb index 55369f1eebde..1d9d0b6bd0af 100644 --- a/test/rubygems/test_gem_commands_unpack_command.rb +++ b/test/rubygems/test_gem_commands_unpack_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/unpack_command' +require_relative "helper" +require "rubygems/commands/unpack_command" class TestGemCommandsUnpackCommand < Gem::TestCase def setup @@ -17,28 +17,28 @@ def test_find_in_cache assert_equal( @cmd.find_in_cache(File.basename @a1.cache_file), @a1.cache_file, - 'found a-1.gem in the cache' + "found a-1.gem in the cache" ) end def test_get_path specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 + fetcher.gem "a", 1 end - dep = Gem::Dependency.new 'a', 1 + dep = Gem::Dependency.new "a", 1 assert_equal( @cmd.get_path(dep), - specs['a-1'].cache_file, - 'fetches a-1 and returns the cache path' + specs["a-1"].cache_file, + "fetches a-1 and returns the cache path" ) - FileUtils.rm specs['a-1'].cache_file + FileUtils.rm specs["a-1"].cache_file assert_equal( @cmd.get_path(dep), - specs['a-1'].cache_file, - 'when removed from cache, refetches a-1' + specs["a-1"].cache_file, + "when removed from cache, refetches a-1" ) end @@ -53,18 +53,18 @@ def test_execute end end - assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be unpacked' - assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked' + assert File.exist?(File.join(@tempdir, "a-3.a")), "a should be unpacked" + assert File.exist?(File.join(@tempdir, "b-2")), "b should be unpacked" end def test_execute_gem_path spec_fetcher do |fetcher| - fetcher.gem 'a', '3.a' + fetcher.gem "a", "3.a" end Gem.clear_paths - gemhome2 = File.join @tempdir, 'gemhome2' + gemhome2 = File.join @tempdir, "gemhome2" Gem.use_paths gemhome2, [gemhome2, @gemhome] @@ -76,7 +76,7 @@ def test_execute_gem_path end end - assert File.exist?(File.join(@tempdir, 'a-3.a')) + assert File.exist?(File.join(@tempdir, "a-3.a")) end def test_execute_gem_path_missing @@ -84,7 +84,7 @@ def test_execute_gem_path_missing Gem.clear_paths - gemhome2 = File.join @tempdir, 'gemhome2' + gemhome2 = File.join @tempdir, "gemhome2" Gem.use_paths gemhome2, [gemhome2, @gemhome] @@ -96,13 +96,13 @@ def test_execute_gem_path_missing end end - assert_equal '', @ui.output + assert_equal "", @ui.output end def test_execute_remote spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 + fetcher.download "a", 1 + fetcher.download "a", 2 end Gem.configuration.verbose = :really @@ -114,7 +114,7 @@ def test_execute_remote end end - assert File.exist?(File.join(@tempdir, 'a-2')), 'a should be unpacked' + assert File.exist?(File.join(@tempdir, "a-2")), "a should be unpacked" end def test_execute_spec @@ -129,15 +129,15 @@ def test_execute_spec end end - assert File.exist?(File.join(@tempdir, 'a-3.a.gemspec')) - assert File.exist?(File.join(@tempdir, 'b-2.gemspec')) + assert File.exist?(File.join(@tempdir, "a-3.a.gemspec")) + assert File.exist?(File.join(@tempdir, "b-2.gemspec")) end def test_execute_spec_target util_make_gems @cmd.options[:args] = %w[a b] - @cmd.options[:target] = 'specs' + @cmd.options[:target] = "specs" @cmd.options[:spec] = true use_ui @ui do @@ -146,12 +146,12 @@ def test_execute_spec_target end end - assert File.exist?(File.join(@tempdir, 'specs/a-3.a.gemspec')) - assert File.exist?(File.join(@tempdir, 'specs/b-2.gemspec')) + assert File.exist?(File.join(@tempdir, "specs/a-3.a.gemspec")) + assert File.exist?(File.join(@tempdir, "specs/b-2.gemspec")) end def test_execute_sudo - pend 'Cannot perform this test on windows (chmod)' if win_platform? + pend "Cannot perform this test on windows (chmod)" if win_platform? util_make_gems @@ -165,7 +165,7 @@ def test_execute_sudo end end - assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked' + assert File.exist?(File.join(@tempdir, "b-2")), "b should be unpacked" ensure FileUtils.chmod 0755, @gemhome end @@ -173,7 +173,7 @@ def test_execute_sudo def test_execute_with_target_option util_make_gems - target = 'with_target' + target = "with_target" @cmd.options[:args] = %w[a] @cmd.options[:target] = target @@ -183,12 +183,12 @@ def test_execute_with_target_option end end - assert File.exist?(File.join(@tempdir, target, 'a-3.a')) + assert File.exist?(File.join(@tempdir, target, "a-3.a")) end def test_execute_exact_match - foo_spec = util_spec 'foo' - foo_bar_spec = util_spec 'foo_bar' + foo_spec = util_spec "foo" + foo_bar_spec = util_spec "foo_bar" use_ui @ui do Dir.chdir @tempdir do diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 1d8dcb2e64a3..58bc7576da8c 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/update_command' +require_relative "helper" +require "rubygems/commands/update_command" class TestGemCommandsUpdateCommand < Gem::TestCase def setup @@ -12,20 +12,20 @@ def setup @cmd.options[:document] = [] @specs = spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 - fetcher.download 'a', '3.a' + fetcher.download "a", 1 + fetcher.download "a", 2 + fetcher.download "a", "3.a" end - @a1_path = @specs['a-1'].cache_file - @a2_path = @specs['a-1'].cache_file - @a3a_path = @specs['a-3.a'].cache_file + @a1_path = @specs["a-1"].cache_file + @a2_path = @specs["a-1"].cache_file + @a3a_path = @specs["a-3.a"].cache_file end def test_execute spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.spec 'a', 1 + fetcher.download "a", 2 + fetcher.spec "a", 1 end @cmd.options[:args] = [] @@ -43,11 +43,11 @@ def test_execute def test_execute_multiple spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.download 'ab', 2 + fetcher.download "a", 2 + fetcher.download "ab", 2 - fetcher.spec 'a', 1 - fetcher.spec 'ab', 1 + fetcher.spec "a", 1 + fetcher.spec "ab", 1 end @cmd.options[:args] = %w[a] @@ -65,7 +65,7 @@ def test_execute_multiple def test_execute_system spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] end end @@ -87,7 +87,7 @@ def test_execute_system def test_execute_system_at_latest spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', Gem::VERSION do |s| + fetcher.download "rubygems-update", Gem::VERSION do |s| s.files = %w[setup.rb] end end @@ -108,9 +108,9 @@ def test_execute_system_at_latest def test_execute_system_when_latest_does_not_support_your_ruby spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] - s.required_ruby_version = '> 9' + s.required_ruby_version = "> 9" end end @@ -133,11 +133,11 @@ def test_execute_system_when_latest_does_not_support_your_ruby def test_execute_system_multiple spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 8 do |s| + fetcher.download "rubygems-update", 8 do |s| s.files = %w[setup.rb] end - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] end end @@ -159,7 +159,7 @@ def test_execute_system_multiple def test_execute_system_update_installed spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 8 do |s| + fetcher.download "rubygems-update", 8 do |s| s.files = %w[setup.rb] end end @@ -170,7 +170,7 @@ def test_execute_system_update_installed @cmd.execute spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] end end @@ -193,7 +193,7 @@ def test_execute_system_update_installed def test_execute_system_update_installed_in_non_default_gem_path rubygems_update_spec = quick_gem "rubygems-update", 9 do |s| - write_file File.join(@tempdir, 'setup.rb') + write_file File.join(@tempdir, "setup.rb") s.files += %w[setup.rb] end @@ -224,11 +224,11 @@ def test_execute_system_update_installed_in_non_default_gem_path def test_execute_system_specific spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 8 do |s| + fetcher.download "rubygems-update", 8 do |s| s.files = %w[setup.rb] end - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] end end @@ -250,7 +250,7 @@ def test_execute_system_specific def test_execute_system_specific_older_than_minimum_supported_rubygems spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', "2.5.1" do |s| + fetcher.download "rubygems-update", "2.5.1" do |s| s.files = %w[setup.rb] end end @@ -279,7 +279,7 @@ def oldest_supported_version def test_execute_system_specific_older_than_3_2_removes_plugins_dir spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 3.1 do |s| + fetcher.download "rubygems-update", 3.1 do |s| s.files = %w[setup.rb] end end @@ -297,7 +297,7 @@ def oldest_supported_version @cmd.options[:system] = "3.1" FileUtils.mkdir_p Gem.plugindir - write_file File.join(Gem.plugindir, 'a_plugin.rb') + write_file File.join(Gem.plugindir, "a_plugin.rb") @cmd.execute @@ -306,7 +306,7 @@ def oldest_supported_version def test_execute_system_specific_newer_than_or_equal_to_3_2_leaves_plugins_dir_alone spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', "3.2.a" do |s| + fetcher.download "rubygems-update", "3.2.a" do |s| s.files = %w[setup.rb] end end @@ -324,7 +324,7 @@ def oldest_supported_version @cmd.options[:system] = "3.2.a" FileUtils.mkdir_p Gem.plugindir - plugin_file = File.join(Gem.plugindir, 'a_plugin.rb') + plugin_file = File.join(Gem.plugindir, "a_plugin.rb") write_file plugin_file @cmd.execute @@ -335,11 +335,11 @@ def oldest_supported_version def test_execute_system_specifically_to_latest_version spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 8 do |s| + fetcher.download "rubygems-update", 8 do |s| s.files = %w[setup.rb] end - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] end end @@ -400,12 +400,12 @@ def test_execute_system_silent_passed_to_setuprb @cmd.options[:system] = true @cmd.options[:silent] = true - assert_equal true, @cmd.update_rubygems_arguments.include?('--silent') + assert_equal true, @cmd.update_rubygems_arguments.include?("--silent") end def test_execute_system_silent spec_fetcher do |fetcher| - fetcher.download 'rubygems-update', 9 do |s| + fetcher.download "rubygems-update", 9 do |s| s.files = %w[setup.rb] end end @@ -429,12 +429,12 @@ def test_execute_system_silent def test_execute_dependencies spec_fetcher do |fetcher| - fetcher.download 'a', 2, 'b' => 2, 'c' => 2 - fetcher.download 'b', 2 - fetcher.download 'c', 2 + fetcher.download "a", 2, "b" => 2, "c" => 2 + fetcher.download "b", 2 + fetcher.download "c", 2 - fetcher.spec 'a', 1, 'c' => '1.2' - fetcher.spec 'c', '1.2' + fetcher.spec "a", 1, "c" => "1.2" + fetcher.spec "c", "1.2" end Gem::Specification.reset @@ -456,8 +456,8 @@ def test_execute_dependencies def test_execute_rdoc spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.spec 'a', 1 + fetcher.download "a", 2 + fetcher.spec "a", 1 end Gem.done_installing(&Gem::RDoc.method(:generation_hook)) @@ -472,16 +472,16 @@ def test_execute_rdoc wait_for_child_process_to_exit - a2 = @specs['a-2'] + a2 = @specs["a-2"] - assert_path_exist File.join(a2.doc_dir, 'rdoc') + assert_path_exist File.join(a2.doc_dir, "rdoc") end def test_execute_named spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end @cmd.options[:args] = %w[a] @@ -500,10 +500,10 @@ def test_execute_named def test_execute_named_some_up_to_date spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.spec 'a', 1 + fetcher.download "a", 2 + fetcher.spec "a", 1 - fetcher.spec 'b', 2 + fetcher.spec "b", 2 end @cmd.options[:args] = %w[a b] @@ -523,7 +523,7 @@ def test_execute_named_some_up_to_date def test_execute_named_up_to_date spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 end @cmd.options[:args] = %w[a] @@ -542,9 +542,9 @@ def test_execute_named_up_to_date def test_execute_named_up_to_date_prerelease spec_fetcher do |fetcher| - fetcher.download 'a', '3.a' + fetcher.download "a", "3.a" - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:args] = %w[a] @@ -564,7 +564,7 @@ def test_execute_named_up_to_date_prerelease def test_execute_up_to_date spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end @cmd.options[:args] = [] @@ -606,63 +606,63 @@ def test_execute_user_install def test_fetch_remote_gems specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 + fetcher.gem "a", 1 + fetcher.gem "a", 2 end expected = [ - [Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY), + [Gem::NameTuple.new("a", v(2), Gem::Platform::RUBY), Gem::Source.new(@gem_repo)], ] - assert_equal expected, @cmd.fetch_remote_gems(specs['a-1']) + assert_equal expected, @cmd.fetch_remote_gems(specs["a-1"]) end def test_fetch_remote_gems_error Gem.sources.replace %w[http://nonexistent.example] assert_raise Gem::RemoteFetcher::FetchError do - @cmd.fetch_remote_gems @specs['a-1'] + @cmd.fetch_remote_gems @specs["a-1"] end end def test_fetch_remote_gems_mismatch - platform = Gem::Platform.new 'x86-freebsd9' + platform = Gem::Platform.new "x86-freebsd9" specs = spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 + fetcher.spec "a", 1 + fetcher.spec "a", 2 - fetcher.spec 'a', 2 do |s| + fetcher.spec "a", 2 do |s| s.platform = platform end end expected = [ - [Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY), + [Gem::NameTuple.new("a", v(2), Gem::Platform::RUBY), Gem::Source.new(@gem_repo)], ] - assert_equal expected, @cmd.fetch_remote_gems(specs['a-1']) + assert_equal expected, @cmd.fetch_remote_gems(specs["a-1"]) end def test_fetch_remote_gems_prerelease specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', 2 - fetcher.gem 'a', '3.a' + fetcher.gem "a", 1 + fetcher.gem "a", 2 + fetcher.gem "a", "3.a" end @cmd.options[:prerelease] = true expected = [ - [Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY), + [Gem::NameTuple.new("a", v(2), Gem::Platform::RUBY), Gem::Source.new(@gem_repo)], - [Gem::NameTuple.new('a', v('3.a'), Gem::Platform::RUBY), + [Gem::NameTuple.new("a", v("3.a"), Gem::Platform::RUBY), Gem::Source.new(@gem_repo)], ] - assert_equal expected, @cmd.fetch_remote_gems(specs['a-1']) + assert_equal expected, @cmd.fetch_remote_gems(specs["a-1"]) end def test_handle_options_system @@ -699,11 +699,11 @@ def test_handle_options_system_specific def test_update_gem_prerelease spec_fetcher do |fetcher| - fetcher.spec 'a', '1.a' - fetcher.gem 'a', '1.b' + fetcher.spec "a", "1.a" + fetcher.gem "a", "1.b" end - @cmd.update_gem 'a', Gem::Requirement.new('= 1.b') + @cmd.update_gem "a", Gem::Requirement.new("= 1.b") refute_empty @cmd.updated @@ -712,15 +712,15 @@ def test_update_gem_prerelease def test_update_gem_unresolved_dependency spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.gem 'a', 2 do |s| - s.add_dependency 'b', '>= 2' + fetcher.spec "a", 1 + fetcher.gem "a", 2 do |s| + s.add_dependency "b", ">= 2" end - fetcher.spec 'b', 1 + fetcher.spec "b", 1 end - @cmd.update_gem 'a' + @cmd.update_gem "a" assert_empty @cmd.updated end @@ -730,18 +730,18 @@ def test_update_rubygems_arguments arguments = @cmd.update_rubygems_arguments - assert_equal '--prefix', arguments.shift + assert_equal "--prefix", arguments.shift assert_equal Gem.prefix, arguments.shift - assert_equal '--no-document', arguments.shift - assert_equal '--previous-version', arguments.shift + assert_equal "--no-document", arguments.shift + assert_equal "--previous-version", arguments.shift assert_equal Gem::VERSION, arguments.shift assert_empty arguments end def test_explain spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.spec 'a', 1 + fetcher.download "a", 2 + fetcher.spec "a", 1 end @cmd.options[:explain] = true @@ -761,13 +761,13 @@ def test_explain def test_explain_platform_local local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 - fetcher.download 'a', 2 do |s| + fetcher.download "a", 2 do |s| s.platform = local end - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end @cmd.options[:explain] = true @@ -787,13 +787,13 @@ def test_explain_platform_local def test_explain_platform_ruby local = Gem::Platform.local spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 - fetcher.download 'a', 2 do |s| + fetcher.download "a", 2 do |s| s.platform = local end - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end # equivalent to --platform=ruby @@ -815,7 +815,7 @@ def test_explain_platform_ruby def test_execute_named_not_installed_and_no_update spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 end @cmd.options[:args] = %w[a b] diff --git a/test/rubygems/test_gem_commands_which_command.rb b/test/rubygems/test_gem_commands_which_command.rb index a398dc570878..46e95bf619d3 100644 --- a/test/rubygems/test_gem_commands_which_command.rb +++ b/test/rubygems/test_gem_commands_which_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/which_command' +require_relative "helper" +require "rubygems/commands/which_command" class TestGemCommandsWhichCommand < Gem::TestCase def setup @@ -19,7 +19,7 @@ def test_execute end assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_execute_directory @@ -31,7 +31,7 @@ def test_execute_directory end end - assert_equal '', @ui.output + assert_equal "", @ui.output assert_match %r{Can.t find Ruby library file or shared library directory\n}, @ui.error end @@ -63,14 +63,14 @@ def test_execute_missing end end - assert_equal '', @ui.output + assert_equal "", @ui.output assert_match %r{Can.t find Ruby library file or shared library missinglib\n}, @ui.error end def util_foo_bar files = %w[lib/foo_bar.rb lib/directory/baz.rb Rakefile] - @foo_bar = util_spec 'foo_bar' do |gem| + @foo_bar = util_spec "foo_bar" do |gem| gem.files = files end install_specs @foo_bar diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb index b798eb3689eb..878b52416e67 100644 --- a/test/rubygems/test_gem_commands_yank_command.rb +++ b/test/rubygems/test_gem_commands_yank_command.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/commands/yank_command' +require_relative "helper" +require "rubygems/commands/yank_command" class TestGemCommandsYankCommand < Gem::TestCase def setup @@ -9,12 +9,12 @@ def setup credential_setup @cmd = Gem::Commands::YankCommand.new - @cmd.options[:host] = 'http://example' + @cmd.options[:host] = "http://example" @fetcher = Gem::RemoteFetcher.fetcher - Gem.configuration.rubygems_api_key = 'key' - Gem.configuration.api_keys[:KEY] = 'other' + Gem.configuration.rubygems_api_key = "key" + Gem.configuration.api_keys[:KEY] = "other" end def teardown @@ -30,7 +30,7 @@ def test_handle_options assert_equal :KEY, @cmd.options[:key] assert_equal "HOST", @cmd.options[:host] assert_nil @cmd.options[:platform] - assert_equal req('= 1.0'), @cmd.options[:version] + assert_equal req("= 1.0"), @cmd.options[:version] end def test_handle_options_missing_argument @@ -42,12 +42,12 @@ def test_handle_options_missing_argument end def test_execute - yank_uri = 'http://example/api/v1/gems/yank' - @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK'] + yank_uri = "http://example/api/v1/gems/yank" + @fetcher.data[yank_uri] = ["Successfully yanked", 200, "OK"] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") use_ui @ui do @cmd.execute @@ -57,82 +57,82 @@ def test_execute assert_match %r{Successfully yanked}, @ui.output platform = Gem.platforms[1] - body = @fetcher.last_request.body.split('&').sort + body = @fetcher.last_request.body.split("&").sort assert_equal %W[gem_name=a platform=#{platform} version=1.0], body - assert_equal 'key', @fetcher.last_request['Authorization'] + assert_equal "key", @fetcher.last_request["Authorization"] assert_equal [yank_uri], @fetcher.paths end def test_execute_with_otp_success - response_fail = 'You have enabled multifactor authentication but your request doesn\'t have the correct OTP code. Please check it and retry.' - yank_uri = 'http://example/api/v1/gems/yank' + response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." + yank_uri = "http://example/api/v1/gems/yank" @fetcher.data[yank_uri] = [ - [response_fail, 401, 'Unauthorized'], - ['Successfully yanked', 200, 'OK'], + [response_fail, 401, "Unauthorized"], + ["Successfully yanked", 200, "OK"], ] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @otp_ui = Gem::MockGemUi.new "111111\n" use_ui @otp_ui do @cmd.execute end - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output - assert_match 'Code: ', @otp_ui.output + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @otp_ui.output + assert_match "Code: ", @otp_ui.output assert_match %r{Yanking gem from http://example}, @otp_ui.output assert_match %r{Successfully yanked}, @otp_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_equal "111111", @fetcher.last_request["OTP"] end def test_execute_with_otp_failure - response = 'You have enabled multifactor authentication but your request doesn\'t have the correct OTP code. Please check it and retry.' - yank_uri = 'http://example/api/v1/gems/yank' - @fetcher.data[yank_uri] = [response, 401, 'Unauthorized'] + response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." + yank_uri = "http://example/api/v1/gems/yank" + @fetcher.data[yank_uri] = [response, 401, "Unauthorized"] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @otp_ui = Gem::MockGemUi.new "111111\n" use_ui @otp_ui do @cmd.execute end - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @otp_ui.output + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @otp_ui.output assert_match response, @otp_ui.output - assert_match 'Code: ', @otp_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_match "Code: ", @otp_ui.output + assert_equal "111111", @fetcher.last_request["OTP"] end def test_execute_key - yank_uri = 'http://example/api/v1/gems/yank' - @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK'] + yank_uri = "http://example/api/v1/gems/yank" + @fetcher.data[yank_uri] = ["Successfully yanked", 200, "OK"] @cmd.options[:args] = %w[a] - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @cmd.options[:key] = :KEY use_ui @ui do @cmd.execute end - body = @fetcher.last_request.body.split('&').sort + body = @fetcher.last_request.body.split("&").sort assert_equal %w[gem_name=a version=1.0], body - assert_equal 'other', @fetcher.last_request['Authorization'] + assert_equal "other", @fetcher.last_request["Authorization"] end def test_execute_host - host = 'https://other.example' + host = "https://other.example" yank_uri = "#{host}/api/v1/gems/yank" - @fetcher.data[yank_uri] = ['Successfully yanked', 200, 'OK'] + @fetcher.data[yank_uri] = ["Successfully yanked", 200, "OK"] @cmd.options[:args] = %w[a] - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @cmd.options[:host] = host use_ui @ui do @@ -142,26 +142,26 @@ def test_execute_host assert_match %r{Yanking gem from https://other.example}, @ui.output assert_match %r{Successfully yanked}, @ui.output - body = @fetcher.last_request.body.split('&').sort + body = @fetcher.last_request.body.split("&").sort assert_equal %w[gem_name=a version=1.0], body - assert_equal 'key', @fetcher.last_request['Authorization'] + assert_equal "key", @fetcher.last_request["Authorization"] assert_equal [yank_uri], @fetcher.paths end def test_yank_gem_unathorized_api_key response_forbidden = "The API key doesn't have access" - response_success = 'Successfully yanked' - host = 'http://example' + response_success = "Successfully yanked" + host = "http://example" @fetcher.data["#{host}/api/v1/gems/yank"] = [ - [response_forbidden, 403, 'Forbidden'], + [response_forbidden, 403, "Forbidden"], [response_success, 200, "OK"], ] @fetcher.data["#{host}/api/v1/api_key"] = ["", 200, "OK"] @cmd.options[:args] = %w[a] @cmd.options[:added_platform] = true - @cmd.options[:version] = req('= 1.0') + @cmd.options[:version] = req("= 1.0") @cmd.instance_variable_set :@host, host @cmd.instance_variable_set :@scope, :yank_rubygem diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb index 3e09079df87b..fbc7c85757e9 100644 --- a/test/rubygems/test_gem_config_file.rb +++ b/test/rubygems/test_gem_config_file.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/config_file' +require_relative "helper" +require "rubygems/config_file" class TestGemConfigFile < Gem::TestCase def setup @@ -8,15 +8,15 @@ def setup credential_setup - @temp_conf = File.join @tempdir, '.gemrc' + @temp_conf = File.join @tempdir, ".gemrc" @cfg_args = %W[--config-file #{@temp_conf}] Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear Gem::ConfigFile::PLATFORM_DEFAULTS.clear - @env_gemrc = ENV['GEMRC'] - ENV['GEMRC'] = '' + @env_gemrc = ENV["GEMRC"] + ENV["GEMRC"] = "" util_config_file end @@ -25,7 +25,7 @@ def teardown Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear Gem::ConfigFile::PLATFORM_DEFAULTS.clear - ENV['GEMRC'] = @env_gemrc + ENV["GEMRC"] = @env_gemrc credential_teardown @@ -43,7 +43,7 @@ def test_initialize assert_equal 365, @cfg.cert_expiration_length_days assert_equal false, @cfg.ipv4_fallback_enabled - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":backtrace: true" fp.puts ":update_sources: false" fp.puts ":bulk_threshold: 10" @@ -66,17 +66,17 @@ def test_initialize assert_equal false, @cfg.verbose assert_equal false, @cfg.update_sources assert_equal %w[http://more-gems.example.com], @cfg.sources - assert_equal '--wrappers', @cfg[:install] - assert_equal(['/usr/ruby/1.8/lib/ruby/gems/1.8', '/var/ruby/1.8/gem_home'], + assert_equal "--wrappers", @cfg[:install] + assert_equal(["/usr/ruby/1.8/lib/ruby/gems/1.8", "/var/ruby/1.8/gem_home"], @cfg.path) assert_equal 0, @cfg.ssl_verify_mode - assert_equal '/etc/ssl/certs', @cfg.ssl_ca_cert + assert_equal "/etc/ssl/certs", @cfg.ssl_ca_cert assert_equal 28, @cfg.cert_expiration_length_days assert_equal true, @cfg.ipv4_fallback_enabled end def test_initialize_ipv4_fallback_enabled_env - ENV['IPV4_FALLBACK_ENABLED'] = 'true' + ENV["IPV4_FALLBACK_ENABLED"] = "true" util_config_file %W[--config-file #{@temp_conf}] assert_equal true, @cfg.ipv4_fallback_enabled @@ -102,37 +102,37 @@ def test_initialize_handle_arguments_config_file_equals def test_initialize_operating_system_override Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS[:bulk_threshold] = 1 - Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS['install'] = '--no-env-shebang' + Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--no-env-shebang" Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2 util_config_file assert_equal 2, @cfg.bulk_threshold - assert_equal '--no-env-shebang', @cfg[:install] + assert_equal "--no-env-shebang", @cfg[:install] end def test_initialize_platform_override Gem::ConfigFile::PLATFORM_DEFAULTS[:bulk_threshold] = 2 - Gem::ConfigFile::PLATFORM_DEFAULTS['install'] = '--no-env-shebang' + Gem::ConfigFile::PLATFORM_DEFAULTS["install"] = "--no-env-shebang" - File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp| + File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, "w" do |fp| fp.puts ":bulk_threshold: 3" end util_config_file assert_equal 3, @cfg.bulk_threshold - assert_equal '--no-env-shebang', @cfg[:install] + assert_equal "--no-env-shebang", @cfg[:install] end def test_initialize_system_wide_override - File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp| + File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, "w" do |fp| fp.puts ":backtrace: false" fp.puts ":bulk_threshold: 2048" end - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":backtrace: true" end @@ -143,28 +143,28 @@ def test_initialize_system_wide_override end def test_initialize_environment_variable_override - File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, 'w' do |fp| - fp.puts ':backtrace: false' - fp.puts ':verbose: false' - fp.puts ':bulk_threshold: 2048' + File.open Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE, "w" do |fp| + fp.puts ":backtrace: false" + fp.puts ":verbose: false" + fp.puts ":bulk_threshold: 2048" end - conf1 = File.join @tempdir, 'gemrc1' - File.open conf1, 'w' do |fp| - fp.puts ':backtrace: true' + conf1 = File.join @tempdir, "gemrc1" + File.open conf1, "w" do |fp| + fp.puts ":backtrace: true" end - conf2 = File.join @tempdir, 'gemrc2' - File.open conf2, 'w' do |fp| - fp.puts ':verbose: true' + conf2 = File.join @tempdir, "gemrc2" + File.open conf2, "w" do |fp| + fp.puts ":verbose: true" end - conf3 = File.join @tempdir, 'gemrc3' - File.open conf3, 'w' do |fp| - fp.puts ':verbose: :loud' + conf3 = File.join @tempdir, "gemrc3" + File.open conf3, "w" do |fp| + fp.puts ":verbose: :loud" end ps = File::PATH_SEPARATOR - ENV['GEMRC'] = conf1 + ps + conf2 + ps + conf3 + ENV["GEMRC"] = conf1 + ps + conf2 + ps + conf3 util_config_file @@ -174,7 +174,7 @@ def test_initialize_environment_variable_override end def test_set_config_file_name_from_environment_variable - ENV['GEMRC'] = "/tmp/.gemrc" + ENV["GEMRC"] = "/tmp/.gemrc" cfg = Gem::ConfigFile.new([]) assert_equal cfg.config_file_name, "/tmp/.gemrc" end @@ -182,22 +182,22 @@ def test_set_config_file_name_from_environment_variable def test_api_keys assert_nil @cfg.instance_variable_get :@api_keys - temp_cred = File.join Gem.user_home, '.gem', 'credentials' + temp_cred = File.join Gem.user_home, ".gem", "credentials" FileUtils.mkdir_p File.dirname(temp_cred) - File.open temp_cred, 'w', 0600 do |fp| - fp.puts ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' + File.open temp_cred, "w", 0600 do |fp| + fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97" end util_config_file - assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97' }, + assert_equal({ :rubygems => "701229f217cdf23b1344c7b4b54ca97" }, @cfg.api_keys) end def test_check_credentials_permissions - pend 'chmod not supported' if win_platform? + pend "chmod not supported" if win_platform? - @cfg.rubygems_api_key = 'x' + @cfg.rubygems_api_key = "x" File.chmod 0644, @cfg.credentials_path @@ -257,7 +257,7 @@ def test_handle_arguments_debug @cfg.handle_arguments args end - assert_match 'NOTE', err + assert_match "NOTE", err assert_equal true, $DEBUG ensure @@ -265,7 +265,7 @@ def test_handle_arguments_debug end def test_handle_arguments_override - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":backtrace: false" end @@ -287,7 +287,7 @@ def test_handle_arguments_traceback def test_handle_arguments_norc assert_equal @temp_conf, @cfg.config_file_name - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":backtrace: true" fp.puts ":update_sources: false" fp.puts ":bulk_threshold: 10" @@ -308,23 +308,23 @@ def test_handle_arguments_norc end def test_load_api_keys - temp_cred = File.join Gem.user_home, '.gem', 'credentials' + temp_cred = File.join Gem.user_home, ".gem", "credentials" FileUtils.mkdir_p File.dirname(temp_cred) - File.open temp_cred, 'w', 0600 do |fp| + File.open temp_cred, "w", 0600 do |fp| fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97" fp.puts ":other: a5fdbb6ba150cbb83aad2bb2fede64c" end util_config_file - assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97', - :other => 'a5fdbb6ba150cbb83aad2bb2fede64c' }, @cfg.api_keys) + assert_equal({ :rubygems => "701229f217cdf23b1344c7b4b54ca97", + :other => "a5fdbb6ba150cbb83aad2bb2fede64c" }, @cfg.api_keys) end def test_load_api_keys_bad_permission - pend 'chmod not supported' if win_platform? + pend "chmod not supported" if win_platform? - @cfg.rubygems_api_key = 'x' + @cfg.rubygems_api_key = "x" File.chmod 0644, @cfg.credentials_path @@ -346,12 +346,12 @@ def test_really_verbose end def test_rubygems_api_key_equals - @cfg.rubygems_api_key = 'x' + @cfg.rubygems_api_key = "x" - assert_equal 'x', @cfg.rubygems_api_key + assert_equal "x", @cfg.rubygems_api_key expected = { - :rubygems_api_key => 'x', + :rubygems_api_key => "x", } assert_equal expected, load_yaml_file(@cfg.credentials_path) @@ -364,18 +364,18 @@ def test_rubygems_api_key_equals end def test_rubygems_api_key_equals_bad_permission - pend 'chmod not supported' if win_platform? + pend "chmod not supported" if win_platform? - @cfg.rubygems_api_key = 'x' + @cfg.rubygems_api_key = "x" File.chmod 0644, @cfg.credentials_path assert_raise Gem::MockGemUi::TermError do - @cfg.rubygems_api_key = 'y' + @cfg.rubygems_api_key = "y" end expected = { - :rubygems_api_key => 'x', + :rubygems_api_key => "x", } assert_equal expected, load_yaml_file(@cfg.credentials_path) @@ -391,27 +391,27 @@ def test_write @cfg.bulk_threshold = 10 @cfg.verbose = false Gem.sources.replace %w[http://more-gems.example.com] - @cfg[:install] = '--wrappers' + @cfg[:install] = "--wrappers" @cfg.write util_config_file # These should not be written out to the config file. - assert_equal false, @cfg.backtrace, 'backtrace' + assert_equal false, @cfg.backtrace, "backtrace" assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold, - 'bulk_threshold' - assert_equal true, @cfg.update_sources, 'update_sources' - assert_equal true, @cfg.verbose, 'verbose' + "bulk_threshold" + assert_equal true, @cfg.update_sources, "update_sources" + assert_equal true, @cfg.verbose, "verbose" - assert_equal '--wrappers', @cfg[:install], 'install' + assert_equal "--wrappers", @cfg[:install], "install" # this should be written out to the config file. assert_equal %w[http://more-gems.example.com], Gem.sources end def test_write_from_hash - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":backtrace: true" fp.puts ":bulk_threshold: 10" fp.puts ":update_sources: false" @@ -431,29 +431,29 @@ def test_write_from_hash @cfg.bulk_threshold = 20 @cfg.verbose = :junk Gem.sources.replace %w[http://even-more-gems.example.com] - @cfg[:install] = '--wrappers --no-rdoc' + @cfg[:install] = "--wrappers --no-rdoc" @cfg.write util_config_file # These should not be written out to the config file - assert_equal true, @cfg.backtrace, 'backtrace' - assert_equal 10, @cfg.bulk_threshold, 'bulk_threshold' - assert_equal false, @cfg.update_sources, 'update_sources' - assert_equal false, @cfg.verbose, 'verbose' + assert_equal true, @cfg.backtrace, "backtrace" + assert_equal 10, @cfg.bulk_threshold, "bulk_threshold" + assert_equal false, @cfg.update_sources, "update_sources" + assert_equal false, @cfg.verbose, "verbose" assert_equal 2, @cfg.ssl_verify_mode - assert_equal '/nonexistent/ca_cert.pem', @cfg.ssl_ca_cert - assert_equal '/nonexistent/client_cert.pem', @cfg.ssl_client_cert + assert_equal "/nonexistent/ca_cert.pem", @cfg.ssl_ca_cert + assert_equal "/nonexistent/client_cert.pem", @cfg.ssl_client_cert - assert_equal '--wrappers --no-rdoc', @cfg[:install], 'install' + assert_equal "--wrappers --no-rdoc", @cfg[:install], "install" assert_equal %w[http://even-more-gems.example.com], Gem.sources end def test_ignore_invalid_config_file - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts "invalid: yaml:" end @@ -467,7 +467,7 @@ def test_ignore_invalid_config_file end def test_load_ssl_verify_mode_from_config - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":ssl_verify_mode: 1" end util_config_file @@ -475,19 +475,19 @@ def test_load_ssl_verify_mode_from_config end def test_load_ssl_ca_cert_from_config - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":ssl_ca_cert: /home/me/certs" end util_config_file - assert_equal('/home/me/certs', @cfg.ssl_ca_cert) + assert_equal("/home/me/certs", @cfg.ssl_ca_cert) end def test_load_ssl_client_cert_from_config - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":ssl_client_cert: /home/me/mine.pem" end util_config_file - assert_equal('/home/me/mine.pem', @cfg.ssl_client_cert) + assert_equal("/home/me/mine.pem", @cfg.ssl_client_cert) end def util_config_file(args = @cfg_args) @@ -495,7 +495,7 @@ def util_config_file(args = @cfg_args) end def test_disable_default_gem_server - File.open @temp_conf, 'w' do |fp| + File.open @temp_conf, "w" do |fp| fp.puts ":disable_default_gem_server: true" end util_config_file diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb index 5551966da249..c585e870877f 100644 --- a/test/rubygems/test_gem_dependency.rb +++ b/test/rubygems/test_gem_dependency.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/dependency' +require_relative "helper" +require "rubygems/dependency" class TestGemDependency < Gem::TestCase def setup @@ -18,7 +18,7 @@ def test_initialize def test_initialize_type_bad e = assert_raise ArgumentError do - Gem::Dependency.new 'monkey' => '1.0' + Gem::Dependency.new "monkey" => "1.0" end assert_equal 'dependency name must be a String, was {"monkey"=>"1.0"}', @@ -36,11 +36,11 @@ def test_initialize_empty end def test_initialize_prerelease - d = dep 'd', '1.a' + d = dep "d", "1.a" assert d.prerelease? - d = dep 'd', '= 1.a' + d = dep "d", "= 1.a" assert d.prerelease? end @@ -105,8 +105,8 @@ def test_equals_tilde_escape def test_equals_tilde_object o = Object.new - def o.name ; 'a' end - def o.version ; '0' end + def o.name ; "a" end + def o.version ; "0" end assert_match dep("a"), o end @@ -133,142 +133,142 @@ def test_hash end def test_match_eh_name_tuple - a_dep = dep 'a' + a_dep = dep "a" - a_tup = Gem::NameTuple.new 'a', 1 - b_tup = Gem::NameTuple.new 'b', 2 - c_tup = Gem::NameTuple.new 'c', '2.a' + a_tup = Gem::NameTuple.new "a", 1 + b_tup = Gem::NameTuple.new "b", 2 + c_tup = Gem::NameTuple.new "c", "2.a" assert a_dep.match? a_tup refute a_dep.match? b_tup - b_dep = dep 'b', '>= 3' + b_dep = dep "b", ">= 3" refute b_dep.match? b_tup - c_dep = dep 'c', '>= 1' + c_dep = dep "c", ">= 1" refute c_dep.match? c_tup - c_dep = dep 'c' + c_dep = dep "c" refute c_dep.match? c_tup - c_dep = dep 'c', '2.a' + c_dep = dep "c", "2.a" assert c_dep.match? c_tup end def test_match_eh_allow_prerelease - a_dep = dep 'a' + a_dep = dep "a" - a_tup = Gem::NameTuple.new 'a', 1 - b_tup = Gem::NameTuple.new 'b', 2 - c_tup = Gem::NameTuple.new 'c', '2.a' + a_tup = Gem::NameTuple.new "a", 1 + b_tup = Gem::NameTuple.new "b", 2 + c_tup = Gem::NameTuple.new "c", "2.a" assert a_dep.match? a_tup, nil, true refute a_dep.match? b_tup, nil, true - b_dep = dep 'b', '>= 3' + b_dep = dep "b", ">= 3" refute b_dep.match? b_tup, nil, true - c_dep = dep 'c', '>= 1' + c_dep = dep "c", ">= 1" assert c_dep.match? c_tup, nil, true - c_dep = dep 'c' + c_dep = dep "c" assert c_dep.match? c_tup, nil, true - c_dep = dep 'c', '2.a' + c_dep = dep "c", "2.a" assert c_dep.match? c_tup, nil, true end def test_match_eh_specification - a_dep = dep 'a' + a_dep = dep "a" - a_spec = util_spec 'a', 1 - b_spec = util_spec 'b', 2 - c_spec = util_spec 'c', '2.a' + a_spec = util_spec "a", 1 + b_spec = util_spec "b", 2 + c_spec = util_spec "c", "2.a" assert a_dep.match? a_spec refute a_dep.match? b_spec - b_dep = dep 'b', '>= 3' + b_dep = dep "b", ">= 3" refute b_dep.match? b_spec - c_dep = dep 'c', '>= 1' + c_dep = dep "c", ">= 1" refute c_dep.match? c_spec - c_dep = dep 'c' + c_dep = dep "c" refute c_dep.match? c_spec - c_dep = dep 'c', '2.a' + c_dep = dep "c", "2.a" assert c_dep.match? c_spec end def test_matches_spec_eh - spec = util_spec 'b', 2 + spec = util_spec "b", 2 - refute dep('a') .matches_spec?(spec), 'name mismatch' - assert dep('b') .matches_spec?(spec), 'name match' - refute dep('b', '= 1') .matches_spec?(spec), 'requirement mismatch' - assert dep('b', '~> 2').matches_spec?(spec), 'requirement match' + refute dep("a") .matches_spec?(spec), "name mismatch" + assert dep("b") .matches_spec?(spec), "name match" + refute dep("b", "= 1") .matches_spec?(spec), "requirement mismatch" + assert dep("b", "~> 2").matches_spec?(spec), "requirement match" end def test_matches_spec_eh_prerelease - spec = util_spec 'b', '2.1.a' + spec = util_spec "b", "2.1.a" - refute dep('a') .matches_spec?(spec), 'name mismatch' - assert dep('b') .matches_spec?(spec), 'name match' - refute dep('b', '= 1') .matches_spec?(spec), 'requirement mismatch' - assert dep('b', '~> 2') .matches_spec?(spec), 'requirement match' - assert dep('b', '~> 2.a').matches_spec?(spec), 'prerelease requirement' + refute dep("a") .matches_spec?(spec), "name mismatch" + assert dep("b") .matches_spec?(spec), "name match" + refute dep("b", "= 1") .matches_spec?(spec), "requirement mismatch" + assert dep("b", "~> 2") .matches_spec?(spec), "requirement match" + assert dep("b", "~> 2.a").matches_spec?(spec), "prerelease requirement" end def test_merge - a1 = dep 'a', '~> 1.0' - a2 = dep 'a', '= 1.0' + a1 = dep "a", "~> 1.0" + a2 = dep "a", "= 1.0" a3 = a1.merge a2 - assert_equal dep('a', '~> 1.0', '= 1.0'), a3 + assert_equal dep("a", "~> 1.0", "= 1.0"), a3 end def test_merge_default - a1 = dep 'a' - a2 = dep 'a', '1' + a1 = dep "a" + a2 = dep "a", "1" a3 = a1.merge a2 - assert_equal dep('a', '1'), a3 + assert_equal dep("a", "1"), a3 end def test_merge_name_mismatch - a = dep 'a' - b = dep 'b' + a = dep "a" + b = dep "b" e = assert_raise ArgumentError do a.merge b end - assert_equal 'a (>= 0) and b (>= 0) have different names', + assert_equal "a (>= 0) and b (>= 0) have different names", e.message end def test_merge_other_default - a1 = dep 'a', '1' - a2 = dep 'a' + a1 = dep "a", "1" + a2 = dep "a" a3 = a1.merge a2 - assert_equal dep('a', '1'), a3 + assert_equal dep("a", "1"), a3 end def test_prerelease_eh @@ -294,44 +294,44 @@ def test_prerelease_eh end def test_specific - refute dep('a', '> 1').specific? + refute dep("a", "> 1").specific? - assert dep('a', '= 1').specific? + assert dep("a", "= 1").specific? end def test_to_spec - a_1 = util_spec 'a', '1' - a_2 = util_spec 'a', '2' + a_1 = util_spec "a", "1" + a_2 = util_spec "a", "2" - a_dep = dep 'a', '>= 0' + a_dep = dep "a", ">= 0" install_specs a_1, a_2 assert_equal a_2, a_dep.to_spec end def test_to_spec_prerelease - a_1 = util_spec 'a', '1' - a_1_1_a = util_spec 'a', '1.1.a' + a_1 = util_spec "a", "1" + a_1_1_a = util_spec "a", "1.1.a" - a_dep = dep 'a', '>= 0' + a_dep = dep "a", ">= 0" install_specs a_1, a_1_1_a assert_equal a_1, a_dep.to_spec - a_pre_dep = dep 'a', '>= 0' + a_pre_dep = dep "a", ">= 0" a_pre_dep.prerelease = true assert_equal a_1_1_a, a_pre_dep.to_spec end def test_to_specs_suggests_other_versions - a = util_spec 'a', '1.0' + a = util_spec "a", "1.0" install_specs a - a_file = File.join a.gem_dir, 'lib', 'a_file.rb' + a_file = File.join a.gem_dir, "lib", "a_file.rb" write_file a_file do |io| - io.puts '# a_file.rb' + io.puts "# a_file.rb" end dep = Gem::Dependency.new "a", "= 2.0" @@ -344,14 +344,14 @@ def test_to_specs_suggests_other_versions end def test_to_specs_respects_bundler_version - b = util_spec 'bundler', '2.0.0.pre.1' - b_1 = util_spec 'bundler', '1' + b = util_spec "bundler", "2.0.0.pre.1" + b_1 = util_spec "bundler", "1" install_specs b, b_1 - b_file = File.join b.gem_dir, 'lib', 'bundler', 'setup.rb' + b_file = File.join b.gem_dir, "lib", "bundler", "setup.rb" write_file b_file do |io| - io.puts '# setup.rb' + io.puts "# setup.rb" end dep = Gem::Dependency.new "bundler", ">= 0.a" @@ -368,13 +368,13 @@ def test_to_specs_respects_bundler_version end def test_to_specs_indicates_total_gem_set_size - a = util_spec 'a', '1.0' + a = util_spec "a", "1.0" install_specs a - a_file = File.join a.gem_dir, 'lib', 'a_file.rb' + a_file = File.join a.gem_dir, "lib", "a_file.rb" write_file a_file do |io| - io.puts '# a_file.rb' + io.puts "# a_file.rb" end dep = Gem::Dependency.new "b", "= 2.0" diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index f2404d61c7ca..9db904ba5374 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/dependency_installer' -require 'rubygems/security' +require_relative "helper" +require "rubygems/dependency_installer" +require "rubygems/security" class TestGemDependencyInstaller < Gem::TestCase def setup super common_installer_setup - @gems_dir = File.join @tempdir, 'gems' - @cache_dir = File.join @gemhome, 'cache' + @gems_dir = File.join @tempdir, "gems" + @cache_dir = File.join @gemhome, "cache" FileUtils.mkdir @gems_dir @@ -25,23 +25,23 @@ def teardown end def util_setup_gems - @a1, @a1_gem = util_gem 'a', '1' do |s| - s.executables << 'a_bin' + @a1, @a1_gem = util_gem "a", "1" do |s| + s.executables << "a_bin" end - @a1_pre, @a1_pre_gem = util_gem 'a', '1.a' + @a1_pre, @a1_pre_gem = util_gem "a", "1.a" - @b1, @b1_gem = util_gem 'b', '1' do |s| - s.add_dependency 'a' - s.add_development_dependency 'aa' + @b1, @b1_gem = util_gem "b", "1" do |s| + s.add_dependency "a" + s.add_development_dependency "aa" end - @c1, @c1_gem = util_gem 'c', '1' do |s| - s.add_development_dependency 'b' + @c1, @c1_gem = util_gem "c", "1" do |s| + s.add_development_dependency "b" end - @d1, @d1_gem = util_gem 'd', '1' do |s| - s.add_development_dependency 'c' + @d1, @d1_gem = util_gem "d", "1" do |s| + s.add_development_dependency "c" end util_setup_spec_fetcher(@a1, @a1_pre, @b1, @d1) @@ -55,7 +55,7 @@ def test_install Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'a' + inst.install "a" end assert_equal %w[a-1], Gem::Specification.map(&:full_name) @@ -65,13 +65,13 @@ def test_install def test_install_prerelease util_setup_gems - p1a, gem = util_gem 'a', '10.a' + p1a, gem = util_gem "a", "10.a" util_setup_spec_fetcher(p1a, @a1, @a1_pre) p1a_data = Gem.read_binary(gem) - @fetcher.data['http://gems.example.com/gems/a-10.a.gem'] = p1a_data + @fetcher.data["http://gems.example.com/gems/a-10.a.gem"] = p1a_data dep = Gem::Dependency.new "a" inst = Gem::DependencyInstaller.new :prerelease => true @@ -83,18 +83,18 @@ def test_install_prerelease def test_install_prerelease_bug_990 spec_fetcher do |fetcher| - fetcher.gem 'a', '1.b' do |s| - s.add_dependency 'b', '~> 1.a' + fetcher.gem "a", "1.b" do |s| + s.add_dependency "b", "~> 1.a" end - fetcher.gem 'b', '1.b' do |s| - s.add_dependency 'c', '>= 1' + fetcher.gem "b", "1.b" do |s| + s.add_dependency "c", ">= 1" end - fetcher.gem 'c', '1.1.b' + fetcher.gem "c", "1.1.b" end - dep = Gem::Dependency.new 'a' + dep = Gem::Dependency.new "a" inst = Gem::DependencyInstaller.new :prerelease => true inst.install dep @@ -103,13 +103,13 @@ def test_install_prerelease_bug_990 end def test_install_when_only_prerelease - p1a, gem = util_gem 'p', '1.a' + p1a, gem = util_gem "p", "1.a" util_setup_spec_fetcher(p1a) p1a_data = Gem.read_binary(gem) - @fetcher.data['http://gems.example.com/gems/p-1.a.gem'] = p1a_data + @fetcher.data["http://gems.example.com/gems/p-1.a.gem"] = p1a_data dep = Gem::Dependency.new "p" inst = Gem::DependencyInstaller.new @@ -128,7 +128,7 @@ def test_install_prerelease_skipped_when_normal_ver p1a_data = Gem.read_binary(@a1_gem) - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = p1a_data + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = p1a_data dep = Gem::Dependency.new "a" inst = Gem::DependencyInstaller.new :prerelease => true @@ -141,8 +141,8 @@ def test_install_prerelease_skipped_when_normal_ver def test_install_all_dependencies util_setup_gems - _, e1_gem = util_gem 'e', '1' do |s| - s.add_dependency 'b' + _, e1_gem = util_gem "e", "1" do |s| + s.add_dependency "b" end FileUtils.mv @a1_gem, @tempdir @@ -153,15 +153,15 @@ def test_install_all_dependencies Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :ignore_dependencies => true - inst.install 'b' + inst.install "b" end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name }, - 'sanity check' + "sanity check" Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'e' + inst.install "e" end assert_equal %w[a-1 e-1], inst.installed_gems.map {|s| s.full_name } @@ -178,7 +178,7 @@ def test_install_cache_dir Dir.chdir dir do inst = Gem::DependencyInstaller.new :cache_dir => @tempdir - inst.install 'b' + inst.install "b" end assert_equal %w[a-1 b-1], inst.installed_gems.map {|s| s.full_name } @@ -190,9 +190,9 @@ def test_install_cache_dir def test_install_dependencies_satisfied util_setup_gems - a2, a2_gem = util_gem 'a', '2' + a2, a2_gem = util_gem "a", "2" - FileUtils.rm_rf File.join(@gemhome, 'gems') + FileUtils.rm_rf File.join(@gemhome, "gems") Gem::Specification.reset @@ -203,17 +203,17 @@ def test_install_dependencies_satisfied Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'a', req("= 2") + inst.install "a", req("= 2") end assert_equal %w[a-2], inst.installed_gems.map {|s| s.full_name }, - 'sanity check' + "sanity check" FileUtils.rm File.join(@tempdir, a2.file_name) Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'b' + inst.install "b" end assert_equal %w[a-2 b-1], Gem::Specification.map(&:full_name) @@ -226,12 +226,12 @@ def test_install_dependencies_satisfied def test_install_doesnt_upgrade_installed_dependencies util_setup_gems - a2, a2_gem = util_gem 'a', '2' - a3, a3_gem = util_gem 'a', '3' + a2, a2_gem = util_gem "a", "2" + a3, a3_gem = util_gem "a", "3" util_setup_spec_fetcher @a1, a3, @b1 - FileUtils.rm_rf File.join(@gemhome, 'gems') + FileUtils.rm_rf File.join(@gemhome, "gems") Gem::Specification.reset @@ -241,7 +241,7 @@ def test_install_doesnt_upgrade_installed_dependencies FileUtils.mv a3_gem, @tempdir Dir.chdir @tempdir do - Gem::DependencyInstaller.new.install 'a', req("= 2") + Gem::DependencyInstaller.new.install "a", req("= 2") end FileUtils.rm File.join(@tempdir, a2.file_name) @@ -250,7 +250,7 @@ def test_install_doesnt_upgrade_installed_dependencies Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'b' + inst.install "b" end assert_equal %w[a-2 b-1], Gem::Specification.map(&:full_name) @@ -274,18 +274,18 @@ def test_install_dependency Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new(:build_docs_in_background => false) - inst.install 'b' + inst.install "b" end assert_equal %w[a-1 b-1], inst.installed_gems.map {|s| s.full_name } - assert done_installing_ran, 'post installs hook was not run' + assert done_installing_ran, "post installs hook was not run" end def test_install_dependency_development util_setup_gems - @aa1, @aa1_gem = util_gem 'aa', '1' + @aa1, @aa1_gem = util_gem "aa", "1" FileUtils.mv @a1_gem, @tempdir FileUtils.mv @aa1_gem, @tempdir @@ -294,7 +294,7 @@ def test_install_dependency_development Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new(:development => true) - inst.install 'b' + inst.install "b" end assert_equal %w[a-1 aa-1 b-1], inst.installed_gems.map {|s| s.full_name } @@ -303,7 +303,7 @@ def test_install_dependency_development def test_install_dependency_development_deep util_setup_gems - @aa1, @aa1_gem = util_gem 'aa', '1' + @aa1, @aa1_gem = util_gem "aa", "1" FileUtils.mv @a1_gem, @tempdir FileUtils.mv @aa1_gem, @tempdir @@ -314,7 +314,7 @@ def test_install_dependency_development_deep Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new(:development => true) - inst.install 'd' + inst.install "d" end assert_equal %w[a-1 aa-1 b-1 c-1 d-1], inst.installed_gems.map {|s| s.full_name } @@ -323,7 +323,7 @@ def test_install_dependency_development_deep def test_install_dependency_development_shallow util_setup_gems - @aa1, @aa1_gem = util_gem 'aa', '1' + @aa1, @aa1_gem = util_gem "aa", "1" FileUtils.mv @a1_gem, @tempdir FileUtils.mv @aa1_gem, @tempdir @@ -334,7 +334,7 @@ def test_install_dependency_development_shallow Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new(:development => true, :dev_shallow => true) - inst.install 'd' + inst.install "d" end assert_equal %w[c-1 d-1], inst.installed_gems.map {|s| s.full_name } @@ -350,29 +350,29 @@ def test_install_dependency_existing Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'b' + inst.install "b" end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name } end def test_install_dependency_existing_extension - extconf_rb = File.join @gemhome, 'gems', 'e-1', 'extconf.rb' + extconf_rb = File.join @gemhome, "gems", "e-1", "extconf.rb" FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |io| + File.open extconf_rb, "w" do |io| io.write <<-EXTCONF_RB require 'mkmf' create_makefile 'e' EXTCONF_RB end - e1 = util_spec 'e', '1', nil, 'extconf.rb' do |s| - s.extensions << 'extconf.rb' + e1 = util_spec "e", "1", nil, "extconf.rb" do |s| + s.extensions << "extconf.rb" end e1_gem = e1.cache_file - _, f1_gem = util_gem 'f', '1', 'e' => nil + _, f1_gem = util_gem "f", "1", "e" => nil Gem::Installer.at(e1_gem).install FileUtils.rm_r e1.extension_dir @@ -385,7 +385,7 @@ def test_install_dependency_existing_extension Dir.chdir @tempdir begin inst = Gem::DependencyInstaller.new - inst.install 'f' + inst.install "f" ensure Dir.chdir pwd end @@ -396,9 +396,9 @@ def test_install_dependency_existing_extension end def test_install_dependency_old - _, e1_gem = util_gem 'e', '1' - _, f1_gem = util_gem 'f', '1', 'e' => nil - _, f2_gem = util_gem 'f', '2' + _, e1_gem = util_gem "e", "1" + _, f1_gem = util_gem "f", "1", "e" => nil + _, f2_gem = util_gem "f", "2" FileUtils.mv e1_gem, @tempdir FileUtils.mv f1_gem, @tempdir @@ -407,7 +407,7 @@ def test_install_dependency_old Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'f' + inst.install "f" end assert_equal %w[f-2], inst.installed_gems.map {|s| s.full_name } @@ -421,7 +421,7 @@ def test_install_local Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :domain => :local - inst.install 'a-1.gem' + inst.install "a-1.gem" end assert_equal %w[a-1], inst.installed_gems.map {|s| s.full_name } @@ -435,7 +435,7 @@ def test_install_local_prerelease Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :domain => :local - inst.install 'a-1.a.gem' + inst.install "a-1.a.gem" end assert_equal %w[a-1.a], inst.installed_gems.map {|s| s.full_name } @@ -451,7 +451,7 @@ def test_install_local_dependency Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :domain => :local - inst.install 'b-1.gem' + inst.install "b-1.gem" end assert_equal %w[a-1 b-1], inst.installed_gems.map {|s| s.full_name } @@ -466,10 +466,10 @@ def test_install_local_dependency_installed inst = nil Dir.chdir @tempdir do - Gem::Installer.at('a-1.gem').install + Gem::Installer.at("a-1.gem").install inst = Gem::DependencyInstaller.new :domain => :local - inst.install 'b-1.gem' + inst.install "b-1.gem" end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name } @@ -482,7 +482,7 @@ def test_install_local_subdir Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :domain => :local - inst.install 'gems/a-1.gem' + inst.install "gems/a-1.gem" end assert_equal %w[a-1], inst.installed_gems.map {|s| s.full_name } @@ -491,12 +491,12 @@ def test_install_local_subdir def test_install_minimal_deps util_setup_gems - _, e1_gem = util_gem 'e', '1' do |s| - s.add_dependency 'b' + _, e1_gem = util_gem "e", "1" do |s| + s.add_dependency "b" end - _, b2_gem = util_gem 'b', '2' do |s| - s.add_dependency 'a' + _, b2_gem = util_gem "b", "2" do |s| + s.add_dependency "a" end FileUtils.mv @a1_gem, @tempdir @@ -508,15 +508,15 @@ def test_install_minimal_deps Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :ignore_dependencies => true - inst.install 'b', req('= 1') + inst.install "b", req("= 1") end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name }, - 'sanity check' + "sanity check" Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :minimal_deps => true - inst.install 'e' + inst.install "e" end assert_equal %w[a-1 e-1], inst.installed_gems.map {|s| s.full_name } @@ -525,12 +525,12 @@ def test_install_minimal_deps def test_install_no_minimal_deps util_setup_gems - _, e1_gem = util_gem 'e', '1' do |s| - s.add_dependency 'b' + _, e1_gem = util_gem "e", "1" do |s| + s.add_dependency "b" end - _, b2_gem = util_gem 'b', '2' do |s| - s.add_dependency 'a' + _, b2_gem = util_gem "b", "2" do |s| + s.add_dependency "a" end FileUtils.mv @a1_gem, @tempdir @@ -542,15 +542,15 @@ def test_install_no_minimal_deps Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :ignore_dependencies => true - inst.install 'b', req('= 1') + inst.install "b", req("= 1") end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name }, - 'sanity check' + "sanity check" Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :minimal_deps => false - inst.install 'e' + inst.install "e" end assert_equal %w[a-1 b-2 e-1], inst.installed_gems.map {|s| s.full_name } @@ -581,13 +581,13 @@ def test_install_env_shebang Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :env_shebang => true, :wrappers => true, :format_executable => false - inst.install 'a' + inst.install "a" end env = "/\\S+/env" unless Gem.win_platform? assert_match %r{\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n}, - File.read(File.join(@gemhome, 'bin', 'a_bin')) + File.read(File.join(@gemhome, "bin", "a_bin")) end def test_install_force @@ -595,12 +595,12 @@ def test_install_force FileUtils.mv @b1_gem, @tempdir si = util_setup_spec_fetcher @b1 - @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml + @fetcher.data["http://gems.example.com/gems/yaml"] = si.to_yaml inst = nil Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :force => true - inst.install 'b' + inst.install "b" end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name } @@ -616,7 +616,7 @@ def test_install_build_args Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new( :build_args => build_args) - inst.install 'a' + inst.install "a" end assert_equal build_args.join("\n"), File.read(inst.installed_gems.first.build_info_file).strip @@ -630,7 +630,7 @@ def test_install_ignore_dependencies Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :ignore_dependencies => true - inst.install 'b' + inst.install "b" end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name } @@ -645,37 +645,37 @@ def test_install_install_dir inst = Gem::Installer.at @a1.file_name inst.install - gemhome2 = File.join @tempdir, 'gemhome2' + gemhome2 = File.join @tempdir, "gemhome2" Dir.mkdir gemhome2 inst = nil Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :install_dir => gemhome2 - inst.install 'b' + inst.install "b" end assert_equal %w[a-1 b-1], inst.installed_gems.map {|s| s.full_name } - assert File.exist?(File.join(gemhome2, 'specifications', @a1.spec_name)) - assert File.exist?(File.join(gemhome2, 'cache', @a1.file_name)) + assert File.exist?(File.join(gemhome2, "specifications", @a1.spec_name)) + assert File.exist?(File.join(gemhome2, "cache", @a1.file_name)) end def test_install_domain_both util_setup_gems a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = a1_data FileUtils.mv @b1_gem, @tempdir inst = nil Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :domain => :both - inst.install 'b' + inst.install "b" end assert_equal %w[a-1 b-1], inst.installed_gems.map {|s| s.full_name } @@ -699,7 +699,7 @@ def test_install_domain_both_no_network Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :domain => :both - inst.install 'b' + inst.install "b" end assert_equal %w[a-1 b-1], inst.installed_gems.map {|s| s.full_name } @@ -714,7 +714,7 @@ def test_install_domain_local Dir.chdir @tempdir do e = assert_raise Gem::UnsatisfiableDependencyError do inst = Gem::DependencyInstaller.new :domain => :local - inst.install 'b' + inst.install "b" end expected = "Unable to resolve dependency: 'b (>= 0)' requires 'a (>= 0)'" @@ -728,14 +728,14 @@ def test_install_domain_remote util_setup_gems a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = a1_data inst = Gem::DependencyInstaller.new :domain => :remote - inst.install 'a' + inst.install "a" assert_equal %w[a-1], inst.installed_gems.map {|s| s.full_name } end @@ -751,19 +751,19 @@ def test_install_dual_repository Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :install_dir => gemhome2 - inst.install 'a' + inst.install "a" end assert_equal %w[a-1], inst.installed_gems.map {|s| s.full_name }, - 'sanity check' + "sanity check" - ENV['GEM_HOME'] = @gemhome - ENV['GEM_PATH'] = [@gemhome, gemhome2].join File::PATH_SEPARATOR + ENV["GEM_HOME"] = @gemhome + ENV["GEM_PATH"] = [@gemhome, gemhome2].join File::PATH_SEPARATOR Gem.clear_paths Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new - inst.install 'b' + inst.install "b" end assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name } @@ -778,7 +778,7 @@ def test_install_reinstall Dir.chdir @tempdir do inst = Gem::DependencyInstaller.new :force => true - inst.install 'a' + inst.install "a" end assert_equal %w[a-1], Gem::Specification.map(&:full_name) @@ -789,16 +789,16 @@ def test_install_remote util_setup_gems a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = a1_data inst = Gem::DependencyInstaller.new Dir.chdir @tempdir do - inst.install 'a' + inst.install "a" end assert_equal %w[a-1], inst.installed_gems.map {|s| s.full_name } @@ -808,11 +808,11 @@ def test_install_remote_dep util_setup_gems a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = a1_data inst = Gem::DependencyInstaller.new @@ -827,22 +827,22 @@ def test_install_remote_dep def test_install_remote_platform_newer util_setup_gems - a2_o, a2_o_gem = util_gem 'a', '2' do |s| + a2_o, a2_o_gem = util_gem "a", "2" do |s| s.platform = Gem::Platform.new %w[cpu other_platform 1] end si = util_setup_spec_fetcher @a1, a2_o - @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml + @fetcher.data["http://gems.example.com/gems/yaml"] = si.to_yaml a1_data = nil a2_o_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end - File.open a2_o_gem, 'rb' do |fp| + File.open a2_o_gem, "rb" do |fp| a2_o_data = fp.read end @@ -852,13 +852,13 @@ def test_install_remote_platform_newer a2_o_data inst = Gem::DependencyInstaller.new :domain => :remote - inst.install 'a' + inst.install "a" assert_equal %w[a-1], inst.installed_gems.map {|s| s.full_name } end def test_install_platform_is_ignored_when_a_file_is_specified - _, a_gem = util_gem 'a', '1' do |s| + _, a_gem = util_gem "a", "1" do |s| s.platform = Gem::Platform.new %w[cpu other_platform 1] end @@ -868,26 +868,26 @@ def test_install_platform_is_ignored_when_a_file_is_specified assert_equal %w[a-1-cpu-other_platform-1], inst.installed_gems.map {|s| s.full_name } end - require 'rubygems/openssl' + require "rubygems/openssl" if Gem::HAVE_OPENSSL def test_install_security_policy util_setup_gems - data = File.open(@a1_gem, 'rb') {|f| f.read } - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = data + data = File.open(@a1_gem, "rb") {|f| f.read } + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = data - data = File.open(@b1_gem, 'rb') {|f| f.read } - @fetcher.data['http://gems.example.com/gems/b-1.gem'] = data + data = File.open(@b1_gem, "rb") {|f| f.read } + @fetcher.data["http://gems.example.com/gems/b-1.gem"] = data policy = Gem::Security::HighSecurity inst = Gem::DependencyInstaller.new :security_policy => policy e = assert_raise Gem::Security::Exception do - inst.install 'b' + inst.install "b" end - assert_equal 'unsigned gems are not allowed by the High Security policy', + assert_equal "unsigned gems are not allowed by the High Security policy", e.message assert_equal %w[], inst.installed_gems.map {|s| s.full_name } @@ -899,28 +899,28 @@ def test_install_security_policy def test_install_no_wrappers util_setup_gems - @fetcher.data['http://gems.example.com/gems/a-1.gem'] = read_binary(@a1_gem) + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = read_binary(@a1_gem) inst = Gem::DependencyInstaller.new :wrappers => false, :format_executable => false - inst.install 'a' + inst.install "a" refute_match(%r{This file was generated by RubyGems.}, - File.read(File.join(@gemhome, 'bin', 'a_bin'))) + File.read(File.join(@gemhome, "bin", "a_bin"))) end end def test_install_version util_setup_d - data = File.open(@d2_gem, 'rb') {|f| f.read } - @fetcher.data['http://gems.example.com/gems/d-2.gem'] = data + data = File.open(@d2_gem, "rb") {|f| f.read } + @fetcher.data["http://gems.example.com/gems/d-2.gem"] = data - data = File.open(@d1_gem, 'rb') {|f| f.read } - @fetcher.data['http://gems.example.com/gems/d-1.gem'] = data + data = File.open(@d1_gem, "rb") {|f| f.read } + @fetcher.data["http://gems.example.com/gems/d-1.gem"] = data inst = Gem::DependencyInstaller.new - inst.install 'd', '= 1' + inst.install "d", "= 1" assert_equal %w[d-1], inst.installed_gems.map {|s| s.full_name } end @@ -928,26 +928,26 @@ def test_install_version def test_install_version_default util_setup_d - data = File.open(@d2_gem, 'rb') {|f| f.read } - @fetcher.data['http://gems.example.com/gems/d-2.gem'] = data + data = File.open(@d2_gem, "rb") {|f| f.read } + @fetcher.data["http://gems.example.com/gems/d-2.gem"] = data - data = File.open(@d1_gem, 'rb') {|f| f.read } - @fetcher.data['http://gems.example.com/gems/d-1.gem'] = data + data = File.open(@d1_gem, "rb") {|f| f.read } + @fetcher.data["http://gems.example.com/gems/d-1.gem"] = data inst = Gem::DependencyInstaller.new - inst.install 'd' + inst.install "d" assert_equal %w[d-2], inst.installed_gems.map {|s| s.full_name } end def test_install_legacy_spec_with_nil_required_ruby_version - path = File.expand_path 'data/null-required-ruby-version.gemspec.rz', __dir__ + path = File.expand_path "data/null-required-ruby-version.gemspec.rz", __dir__ spec = Marshal.load Gem.read_binary(path) def spec.validate(*args); end util_build_gem spec - cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem" + cache_file = File.join @tempdir, "gems", "#{spec.original_name}.gem" FileUtils.mkdir_p File.dirname cache_file FileUtils.mv spec.cache_file, cache_file @@ -955,9 +955,9 @@ def spec.validate(*args); end data = Gem.read_binary(cache_file) - @fetcher.data['http://gems.example.com/gems/activesupport-1.0.0.gem'] = data + @fetcher.data["http://gems.example.com/gems/activesupport-1.0.0.gem"] = data - dep = Gem::Dependency.new 'activesupport' + dep = Gem::Dependency.new "activesupport" inst = Gem::DependencyInstaller.new inst.install dep @@ -966,13 +966,13 @@ def spec.validate(*args); end end def test_install_legacy_spec_with_nil_required_rubygems_version - path = File.expand_path 'data/null-required-rubygems-version.gemspec.rz', __dir__ + path = File.expand_path "data/null-required-rubygems-version.gemspec.rz", __dir__ spec = Marshal.load Gem.read_binary(path) def spec.validate(*args); end util_build_gem spec - cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem" + cache_file = File.join @tempdir, "gems", "#{spec.original_name}.gem" FileUtils.mkdir_p File.dirname cache_file FileUtils.mv spec.cache_file, cache_file @@ -980,9 +980,9 @@ def spec.validate(*args); end data = Gem.read_binary(cache_file) - @fetcher.data['http://gems.example.com/gems/activesupport-1.0.0.gem'] = data + @fetcher.data["http://gems.example.com/gems/activesupport-1.0.0.gem"] = data - dep = Gem::Dependency.new 'activesupport' + dep = Gem::Dependency.new "activesupport" inst = Gem::DependencyInstaller.new inst.install dep @@ -994,7 +994,7 @@ def test_find_gems_gems_with_sources util_setup_gems inst = Gem::DependencyInstaller.new - dep = Gem::Dependency.new 'b', '>= 0' + dep = Gem::Dependency.new "b", ">= 0" Gem::Specification.reset @@ -1015,7 +1015,7 @@ def test_find_gems_with_sources_local FileUtils.mv @a1_gem, @tempdir inst = Gem::DependencyInstaller.new - dep = Gem::Dependency.new 'a', '>= 0' + dep = Gem::Dependency.new "a", ">= 0" set = nil Dir.chdir @tempdir do @@ -1030,12 +1030,12 @@ def test_find_gems_with_sources_local remote, local = gems - assert_equal 'a-1', local.spec.full_name, 'local spec' + assert_equal "a-1", local.spec.full_name, "local spec" assert_equal File.join(@tempdir, @a1.file_name), - local.source.download(local.spec), 'local path' + local.source.download(local.spec), "local path" - assert_equal 'a-1', remote.spec.full_name, 'remote spec' - assert_equal Gem::Source.new(@gem_repo), remote.source, 'remote path' + assert_equal "a-1", remote.spec.full_name, "remote spec" + assert_equal Gem::Source.new(@gem_repo), remote.source, "remote path" end def test_find_gems_with_sources_prerelease @@ -1043,7 +1043,7 @@ def test_find_gems_with_sources_prerelease installer = Gem::DependencyInstaller.new - dependency = Gem::Dependency.new('a', Gem::Requirement.default) + dependency = Gem::Dependency.new("a", Gem::Requirement.default) set = Gem::Deprecate.skip_during do installer.find_gems_with_sources(dependency) @@ -1051,8 +1051,8 @@ def test_find_gems_with_sources_prerelease releases = set.all_specs - assert releases.any? {|s| s.name == 'a' and s.version.to_s == '1' } - refute releases.any? {|s| s.name == 'a' and s.version.to_s == '1.a' } + assert releases.any? {|s| s.name == "a" and s.version.to_s == "1" } + refute releases.any? {|s| s.name == "a" and s.version.to_s == "1.a" } dependency.prerelease = true @@ -1067,15 +1067,15 @@ def test_find_gems_with_sources_prerelease def test_find_gems_with_sources_with_best_only_and_platform util_setup_gems - a1_x86_mingw32, = util_gem 'a', '1' do |s| - s.platform = 'x86-mingw32' + a1_x86_mingw32, = util_gem "a", "1" do |s| + s.platform = "x86-mingw32" end util_setup_spec_fetcher @a1, a1_x86_mingw32 - Gem.platforms << Gem::Platform.new('x86-mingw32') + Gem.platforms << Gem::Platform.new("x86-mingw32") installer = Gem::DependencyInstaller.new - dependency = Gem::Dependency.new('a', Gem::Requirement.default) + dependency = Gem::Dependency.new("a", Gem::Requirement.default) set = Gem::Deprecate.skip_during do installer.find_gems_with_sources(dependency, true) @@ -1091,7 +1091,7 @@ def test_find_gems_with_sources_with_bad_source installer = Gem::DependencyInstaller.new - dep = Gem::Dependency.new('a') + dep = Gem::Dependency.new("a") out = Gem::Deprecate.skip_during do installer.find_gems_with_sources(dep) @@ -1108,7 +1108,7 @@ def test_resolve_dependencies FileUtils.mv @b1_gem, @tempdir inst = Gem::DependencyInstaller.new - request_set = inst.resolve_dependencies 'b', req('>= 0') + request_set = inst.resolve_dependencies "b", req(">= 0") requests = request_set.sorted_requests.map {|req| req.full_name } @@ -1122,7 +1122,7 @@ def test_resolve_dependencies_ignore_dependencies FileUtils.mv @b1_gem, @tempdir inst = Gem::DependencyInstaller.new :ignore_dependencies => true - request_set = inst.resolve_dependencies 'b', req('>= 0') + request_set = inst.resolve_dependencies "b", req(">= 0") requests = request_set.sorted_requests.map {|req| req.full_name } @@ -1134,12 +1134,12 @@ def test_resolve_dependencies_ignore_dependencies def test_resolve_dependencies_local util_setup_gems - @a2, @a2_gem = util_gem 'a', '2' + @a2, @a2_gem = util_gem "a", "2" FileUtils.mv @a1_gem, @tempdir FileUtils.mv @a2_gem, @tempdir inst = Gem::DependencyInstaller.new - request_set = inst.resolve_dependencies 'a-1.gem', req('>= 0') + request_set = inst.resolve_dependencies "a-1.gem", req(">= 0") requests = request_set.sorted_requests.map {|req| req.full_name } @@ -1147,8 +1147,8 @@ def test_resolve_dependencies_local end def util_setup_d - @d1, @d1_gem = util_gem 'd', '1' - @d2, @d2_gem = util_gem 'd', '2' + @d1, @d1_gem = util_gem "d", "1" + @d2, @d2_gem = util_gem "d", "2" util_setup_spec_fetcher(@d1, @d2) end diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb index 15c50de199f6..0dca8f8c3aff 100644 --- a/test/rubygems/test_gem_dependency_list.rb +++ b/test/rubygems/test_gem_dependency_list.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/dependency_list' +require_relative "helper" +require "rubygems/dependency_list" class TestGemDependencyList < Gem::TestCase def setup @@ -9,26 +9,26 @@ def setup @deplist = Gem::DependencyList.new # TODO: switch to util_spec - @a1 = util_spec 'a', '1' - @a2 = util_spec 'a', '2' - @a3 = util_spec 'a', '3' + @a1 = util_spec "a", "1" + @a2 = util_spec "a", "2" + @a3 = util_spec "a", "3" - @b1 = util_spec 'b', '1' do |s| - s.add_dependency 'a', '>= 1' + @b1 = util_spec "b", "1" do |s| + s.add_dependency "a", ">= 1" end - @b2 = util_spec 'b', '2' do |s| - s.add_dependency 'a', '>= 1' + @b2 = util_spec "b", "2" do |s| + s.add_dependency "a", ">= 1" end - @c1 = util_spec 'c', '1' do |s| - s.add_dependency 'b', '>= 1' + @c1 = util_spec "c", "1" do |s| + s.add_dependency "b", ">= 1" end - @c2 = util_spec 'c', '2' + @c2 = util_spec "c", "2" - @d1 = util_spec 'd', '1' do |s| - s.add_dependency 'c', '>= 1' + @d1 = util_spec "d", "1" do |s| + s.add_dependency "c", ">= 1" end end @@ -56,7 +56,7 @@ def test_dependency_order end def test_dependency_order_circle - @a1.add_dependency 'c', '>= 1' + @a1.add_dependency "c", ">= 1" @deplist.add @a1, @b1, @c1 order = @deplist.dependency_order @@ -65,14 +65,14 @@ def test_dependency_order_circle end def test_dependency_order_development - e1 = util_spec 'e', '1' - f1 = util_spec 'f', '1' - g1 = util_spec 'g', '1' + e1 = util_spec "e", "1" + f1 = util_spec "f", "1" + g1 = util_spec "g", "1" - @a1.add_dependency 'e' - @a1.add_dependency 'f' - @a1.add_dependency 'g' - g1.add_development_dependency 'a' + @a1.add_dependency "e" + @a1.add_dependency "f" + @a1.add_dependency "g" + g1.add_development_dependency "a" deplist = Gem::DependencyList.new true deplist.add @a1, e1, f1, g1 @@ -80,7 +80,7 @@ def test_dependency_order_development order = deplist.dependency_order assert_equal %w[g-1 a-1 f-1 e-1], order.map {|s| s.full_name }, - 'development on' + "development on" deplist2 = Gem::DependencyList.new deplist2.add @a1, e1, f1, g1 @@ -88,19 +88,19 @@ def test_dependency_order_development order = deplist2.dependency_order assert_equal %w[a-1 g-1 f-1 e-1], order.map {|s| s.full_name }, - 'development off' + "development off" end def test_dependency_order_diamond util_diamond - e1 = util_spec 'e', '1' + e1 = util_spec "e", "1" @deplist.add e1 - @a1.add_dependency 'e', '>= 1' + @a1.add_dependency "e", ">= 1" order = @deplist.dependency_order assert_equal %w[d-1 c-2 b-1 a-2 e-1], order.map {|s| s.full_name }, - 'deps of trimmed specs not included' + "deps of trimmed specs not included" end def test_dependency_order_no_dependencies @@ -121,15 +121,15 @@ def test_find_name end def test_ok_eh - assert @deplist.ok?, 'no dependencies' + assert @deplist.ok?, "no dependencies" @deplist.add @b2 - refute @deplist.ok?, 'unsatisfied dependency' + refute @deplist.ok?, "unsatisfied dependency" @deplist.add @a1 - assert @deplist.ok?, 'satisfied dependency' + assert @deplist.ok?, "satisfied dependency" end def test_why_not_ok_eh @@ -147,13 +147,13 @@ def test_why_not_ok_eh end def test_why_not_ok_eh_old_dependency - a = util_spec 'a', '1', - 'b' => '~> 1.0' + a = util_spec "a", "1", + "b" => "~> 1.0" - b0 = util_spec 'b', '1.0', - 'd' => '>= 0' + b0 = util_spec "b", "1.0", + "d" => ">= 0" - b1 = util_spec 'b', '1.1' + b1 = util_spec "b", "1.1" util_clear_gems @@ -165,25 +165,25 @@ def test_why_not_ok_eh_old_dependency end def test_ok_eh_mismatch - a1 = util_spec 'a', '1' - a2 = util_spec 'a', '2' + a1 = util_spec "a", "1" + a2 = util_spec "a", "2" - b = util_spec 'b', '1' do |s| - s.add_dependency 'a', '= 1' + b = util_spec "b", "1" do |s| + s.add_dependency "a", "= 1" end - c = util_spec 'c', '1' do |s| - s.add_dependency 'a', '= 2' + c = util_spec "c", "1" do |s| + s.add_dependency "a", "= 2" end - d = util_spec 'd', '1' do |s| - s.add_dependency 'b' - s.add_dependency 'c' + d = util_spec "d", "1" do |s| + s.add_dependency "b" + s.add_dependency "c" end @deplist.add a1, a2, b, c, d - assert @deplist.ok?, 'this will break on require' + assert @deplist.ok?, "this will break on require" end def test_ok_eh_redundant @@ -256,8 +256,8 @@ def test_tsort_each_child # d1 -> b1 -> a1 # d1 -> c2 -> a2 def util_diamond - @c2.add_dependency 'a', '>= 2' - @d1.add_dependency 'b' + @c2.add_dependency "a", ">= 2" + @d1.add_dependency "b" @deplist.add @a1, @a2, @b1, @c2, @d1 end diff --git a/test/rubygems/test_gem_dependency_resolution_error.rb b/test/rubygems/test_gem_dependency_resolution_error.rb index 0e4a2fe31a46..26b9e4ddc0a9 100644 --- a/test/rubygems/test_gem_dependency_resolution_error.rb +++ b/test/rubygems/test_gem_dependency_resolution_error.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemDependencyResolutionError < Gem::TestCase def setup @@ -7,10 +7,10 @@ def setup @DR = Gem::Resolver - @spec = util_spec 'a', 2 + @spec = util_spec "a", 2 - @a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil - @a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil + @a1_req = @DR::DependencyRequest.new dep("a", "= 1"), nil + @a2_req = @DR::DependencyRequest.new dep("a", "= 2"), nil @activated = @DR::ActivationRequest.new @spec, @a2_req diff --git a/test/rubygems/test_gem_doctor.rb b/test/rubygems/test_gem_doctor.rb index 583c735dd3be..d26a6ee3105f 100644 --- a/test/rubygems/test_gem_doctor.rb +++ b/test/rubygems/test_gem_doctor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/doctor' +require_relative "helper" +require "rubygems/doctor" class TestGemDoctor < Gem::TestCase def gem(name) @@ -15,20 +15,20 @@ def gem(name) end def test_doctor - a = gem 'a' - b = gem 'b' - c = gem 'c' + a = gem "a" + b = gem "b" + c = gem "c" Gem.use_paths @userhome, @gemhome FileUtils.rm b.spec_file - File.open c.spec_file, 'w' do |io| - io.write 'this will raise an exception when evaluated.' + File.open c.spec_file, "w" do |io| + io.write "this will raise an exception when evaluated." end - assert_path_exist File.join(a.gem_dir, 'Rakefile') - assert_path_exist File.join(a.gem_dir, 'lib', 'a.rb') + assert_path_exist File.join(a.gem_dir, "Rakefile") + assert_path_exist File.join(a.gem_dir, "lib", "a.rb") assert_path_exist b.gem_dir assert_path_not_exist b.spec_file @@ -44,8 +44,8 @@ def test_doctor end end - assert_path_exist File.join(a.gem_dir, 'Rakefile') - assert_path_exist File.join(a.gem_dir, 'lib', 'a.rb') + assert_path_exist File.join(a.gem_dir, "Rakefile") + assert_path_exist File.join(a.gem_dir, "lib", "a.rb") assert_path_not_exist b.gem_dir assert_path_not_exist b.spec_file @@ -68,20 +68,20 @@ def test_doctor end def test_doctor_dry_run - a = gem 'a' - b = gem 'b' - c = gem 'c' + a = gem "a" + b = gem "b" + c = gem "c" Gem.use_paths @userhome, @gemhome FileUtils.rm b.spec_file - File.open c.spec_file, 'w' do |io| - io.write 'this will raise an exception when evaluated.' + File.open c.spec_file, "w" do |io| + io.write "this will raise an exception when evaluated." end - assert_path_exist File.join(a.gem_dir, 'Rakefile') - assert_path_exist File.join(a.gem_dir, 'lib', 'a.rb') + assert_path_exist File.join(a.gem_dir, "Rakefile") + assert_path_exist File.join(a.gem_dir, "lib", "a.rb") assert_path_exist b.gem_dir assert_path_not_exist b.spec_file @@ -97,8 +97,8 @@ def test_doctor_dry_run end end - assert_path_exist File.join(a.gem_dir, 'Rakefile') - assert_path_exist File.join(a.gem_dir, 'lib', 'a.rb') + assert_path_exist File.join(a.gem_dir, "Rakefile") + assert_path_exist File.join(a.gem_dir, "lib", "a.rb") assert_path_exist b.gem_dir assert_path_not_exist b.spec_file @@ -121,7 +121,7 @@ def test_doctor_dry_run end def test_doctor_non_gem_home - other_dir = File.join @tempdir, 'other', 'dir' + other_dir = File.join @tempdir, "other", "dir" FileUtils.mkdir_p other_dir @@ -147,13 +147,13 @@ def test_doctor_non_gem_home def test_doctor_child_missing doctor = Gem::Doctor.new @gemhome - doctor.doctor_child 'missing', '' + doctor.doctor_child "missing", "" assert true # count end def test_doctor_badly_named_plugins - gem 'a' + gem "a" Gem.use_paths @gemhome.to_s @@ -183,12 +183,12 @@ def test_doctor_badly_named_plugins def test_gem_repository_eh doctor = Gem::Doctor.new @gemhome - refute doctor.gem_repository?, 'no gems installed' + refute doctor.gem_repository?, "no gems installed" - install_specs util_spec 'a' + install_specs util_spec "a" doctor = Gem::Doctor.new @gemhome - assert doctor.gem_repository?, 'gems installed' + assert doctor.gem_repository?, "gems installed" end end diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index 7e19782e6168..6adfd425506d 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -1,38 +1,38 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' -require 'rubygems/installer' +require_relative "helper" +require "rubygems/ext" +require "rubygems/installer" class TestGemExtBuilder < Gem::TestCase def setup super - @ext = File.join @tempdir, 'ext' - @dest_path = File.join @tempdir, 'prefix' + @ext = File.join @tempdir, "ext" + @dest_path = File.join @tempdir, "prefix" FileUtils.mkdir_p @ext FileUtils.mkdir_p @dest_path - @orig_DESTDIR = ENV['DESTDIR'] - @orig_make = ENV['make'] + @orig_DESTDIR = ENV["DESTDIR"] + @orig_make = ENV["make"] - @spec = util_spec 'a' + @spec = util_spec "a" - @builder = Gem::Ext::Builder.new @spec, '' + @builder = Gem::Ext::Builder.new @spec, "" end def teardown - ENV['DESTDIR'] = @orig_DESTDIR - ENV['make'] = @orig_make + ENV["DESTDIR"] = @orig_DESTDIR + ENV["make"] = @orig_make super end def test_class_make - ENV['DESTDIR'] = 'destination' + ENV["DESTDIR"] = "destination" results = [] - File.open File.join(@ext, 'Makefile'), 'w' do |io| + File.open File.join(@ext, "Makefile"), "w" do |io| io.puts <<-MAKEFILE all: \t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}" @@ -61,10 +61,10 @@ def test_class_make end def test_class_make_no_clean - ENV['DESTDIR'] = 'destination' + ENV["DESTDIR"] = "destination" results = [] - File.open File.join(@ext, 'Makefile'), 'w' do |io| + File.open File.join(@ext, "Makefile"), "w" do |io| io.puts <<-MAKEFILE all: \t@#{Gem.ruby} -e "puts %Q{all: \#{ENV['DESTDIR']}}" @@ -84,9 +84,9 @@ def test_class_make_no_clean end def test_custom_make_with_options - ENV['make'] = 'make V=1' + ENV["make"] = "make V=1" results = [] - File.open File.join(@ext, 'Makefile'), 'w' do |io| + File.open File.join(@ext, "Makefile"), "w" do |io| io.puts <<-MAKEFILE all: \t@#{Gem.ruby} -e "puts 'all: OK'" @@ -106,16 +106,16 @@ def test_custom_make_with_options end def test_build_extensions - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning - @spec.extensions << 'ext/extconf.rb' + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + @spec.extensions << "ext/extconf.rb" - ext_dir = File.join @spec.gem_dir, 'ext' + ext_dir = File.join @spec.gem_dir, "ext" FileUtils.mkdir_p ext_dir - extconf_rb = File.join ext_dir, 'extconf.rb' + extconf_rb = File.join ext_dir, "extconf.rb" - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' require 'mkmf' @@ -123,11 +123,11 @@ def test_build_extensions RUBY end - ext_lib_dir = File.join ext_dir, 'lib' + ext_lib_dir = File.join ext_dir, "lib" FileUtils.mkdir ext_lib_dir - FileUtils.touch File.join ext_lib_dir, 'a.rb' - FileUtils.mkdir File.join ext_lib_dir, 'a' - FileUtils.touch File.join ext_lib_dir, 'a', 'b.rb' + FileUtils.touch File.join ext_lib_dir, "a.rb" + FileUtils.mkdir File.join ext_lib_dir, "a" + FileUtils.touch File.join ext_lib_dir, "a", "b.rb" use_ui @ui do @builder.build_extensions @@ -135,20 +135,20 @@ def test_build_extensions assert_path_exist @spec.extension_dir assert_path_exist @spec.gem_build_complete_path - assert_path_exist File.join @spec.extension_dir, 'gem_make.out' - assert_path_exist File.join @spec.extension_dir, 'a.rb' - assert_path_exist File.join @spec.gem_dir, 'lib', 'a.rb' - assert_path_exist File.join @spec.gem_dir, 'lib', 'a', 'b.rb' + assert_path_exist File.join @spec.extension_dir, "gem_make.out" + assert_path_exist File.join @spec.extension_dir, "a.rb" + assert_path_exist File.join @spec.gem_dir, "lib", "a.rb" + assert_path_exist File.join @spec.gem_dir, "lib", "a", "b.rb" end def test_build_extensions_with_gemhome_with_space - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning - new_gemhome = File.join @tempdir, 'gem home' + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + new_gemhome = File.join @tempdir, "gem home" File.rename(@gemhome, new_gemhome) @gemhome = new_gemhome Gem.use_paths(@gemhome) - @spec = util_spec 'a' - @builder = Gem::Ext::Builder.new @spec, '' + @spec = util_spec "a" + @builder = Gem::Ext::Builder.new @spec, "" test_build_extensions end @@ -163,17 +163,17 @@ def Gem.install_extension_in_lib false end end - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning - @spec.extensions << 'ext/extconf.rb' + @spec.extensions << "ext/extconf.rb" - ext_dir = File.join @spec.gem_dir, 'ext' + ext_dir = File.join @spec.gem_dir, "ext" FileUtils.mkdir_p ext_dir - extconf_rb = File.join ext_dir, 'extconf.rb' + extconf_rb = File.join ext_dir, "extconf.rb" - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' require 'mkmf' @@ -181,11 +181,11 @@ def Gem.install_extension_in_lib RUBY end - ext_lib_dir = File.join ext_dir, 'lib' + ext_lib_dir = File.join ext_dir, "lib" FileUtils.mkdir ext_lib_dir - FileUtils.touch File.join ext_lib_dir, 'a.rb' - FileUtils.mkdir File.join ext_lib_dir, 'a' - FileUtils.touch File.join ext_lib_dir, 'a', 'b.rb' + FileUtils.touch File.join ext_lib_dir, "a.rb" + FileUtils.mkdir File.join ext_lib_dir, "a" + FileUtils.touch File.join ext_lib_dir, "a", "b.rb" use_ui @ui do @builder.build_extensions @@ -193,10 +193,10 @@ def Gem.install_extension_in_lib assert_path_exist @spec.extension_dir assert_path_exist @spec.gem_build_complete_path - assert_path_exist File.join @spec.extension_dir, 'gem_make.out' - assert_path_exist File.join @spec.extension_dir, 'a.rb' - assert_path_not_exist File.join @spec.gem_dir, 'lib', 'a.rb' - assert_path_not_exist File.join @spec.gem_dir, 'lib', 'a', 'b.rb' + assert_path_exist File.join @spec.extension_dir, "gem_make.out" + assert_path_exist File.join @spec.extension_dir, "a.rb" + assert_path_not_exist File.join @spec.gem_dir, "lib", "a.rb" + assert_path_not_exist File.join @spec.gem_dir, "lib", "a", "b.rb" ensure class << Gem remove_method :install_extension_in_lib @@ -210,10 +210,10 @@ def test_build_extensions_none @builder.build_extensions end - assert_equal '', @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.output + assert_equal "", @ui.error - assert_path_not_exist File.join @spec.extension_dir, 'gem_make.out' + assert_path_not_exist File.join @spec.extension_dir, "gem_make.out" end def test_build_extensions_rebuild_failure @@ -234,7 +234,7 @@ def test_build_extensions_rebuild_failure def test_build_extensions_extconf_bad cwd = Dir.pwd - @spec.extensions << 'extconf.rb' + @spec.extensions << "extconf.rb" FileUtils.mkdir_p @spec.gem_dir @@ -246,9 +246,9 @@ def test_build_extensions_extconf_bad assert_match(/\AERROR: Failed to build gem native extension.$/, e.message) assert_equal "Building native extensions. This could take a while...\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error - gem_make_out = File.join @spec.extension_dir, 'gem_make.out' + gem_make_out = File.join @spec.extension_dir, "gem_make.out" cmd_make_out = File.read(gem_make_out) assert_match %r{#{Regexp.escape Gem.ruby} .* extconf\.rb}, cmd_make_out @@ -261,7 +261,7 @@ def test_build_extensions_extconf_bad def test_build_extensions_unsupported FileUtils.mkdir_p @spec.gem_dir - gem_make_out = File.join @spec.extension_dir, 'gem_make.out' + gem_make_out = File.join @spec.extension_dir, "gem_make.out" @spec.extensions << nil e = assert_raise Gem::Ext::BuildError do @@ -272,7 +272,7 @@ def test_build_extensions_unsupported assert_match(/^\s*No builder for extension ''$/, e.message) assert_equal "Building native extensions. This could take a while...\n", @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error assert_equal "No builder for extension ''\n", File.read(gem_make_out) @@ -284,7 +284,7 @@ def test_build_extensions_unsupported def test_build_extensions_with_build_args args = ["--aa", "--bb"] @builder.build_args = args - @spec.extensions << 'extconf.rb' + @spec.extensions << "extconf.rb" FileUtils.mkdir_p @spec.gem_dir @@ -315,14 +315,14 @@ def test_build_extensions_with_build_args end def test_initialize - build_info_dir = File.join @gemhome, 'build_info' + build_info_dir = File.join @gemhome, "build_info" FileUtils.mkdir_p build_info_dir build_info_file = File.join build_info_dir, "#{@spec.full_name}.info" - File.open build_info_file, 'w' do |io| - io.puts '--with-foo-dir=/nonexistent' + File.open build_info_file, "w" do |io| + io.puts "--with-foo-dir=/nonexistent" end builder = Gem::Ext::Builder.new @spec diff --git a/test/rubygems/test_gem_ext_cargo_builder.rb b/test/rubygems/test_gem_ext_cargo_builder.rb index 2da98c03e237..5a940b07a82b 100644 --- a/test/rubygems/test_gem_ext_cargo_builder.rb +++ b/test/rubygems/test_gem_ext_cargo_builder.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' +require_relative "helper" +require "rubygems/ext" class TestGemExtCargoBuilder < Gem::TestCase def setup super @rust_envs = { - 'CARGO_HOME' => ENV.fetch('CARGO_HOME', File.join(@orig_env['HOME'], '.cargo')), - 'RUSTUP_HOME' => ENV.fetch('RUSTUP_HOME', File.join(@orig_env['HOME'], '.rustup')), + "CARGO_HOME" => ENV.fetch("CARGO_HOME", File.join(@orig_env["HOME"], ".cargo")), + "RUSTUP_HOME" => ENV.fetch("RUSTUP_HOME", File.join(@orig_env["HOME"], ".rustup")), } end def setup_rust_gem(name) - @ext = File.join(@tempdir, 'ext') - @dest_path = File.join(@tempdir, 'prefix') + @ext = File.join(@tempdir, "ext") + @dest_path = File.join(@tempdir, "prefix") @fixture_dir = Pathname.new(File.expand_path("test_gem_ext_cargo_builder/#{name}/", __dir__)) FileUtils.mkdir_p @dest_path @@ -26,14 +26,14 @@ def test_build_staticlib skip_unsupported_platforms! setup_rust_gem "rust_ruby_example" - content = @fixture_dir.join('Cargo.toml').read.gsub("cdylib", "staticlib") - File.write(File.join(@ext, 'Cargo.toml'), content) + content = @fixture_dir.join("Cargo.toml").read.gsub("cdylib", "staticlib") + File.write(File.join(@ext, "Cargo.toml"), content) output = [] Dir.chdir @ext do ENV.update(@rust_envs) - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) assert_raise(Gem::Ext::CargoBuilder::DylibNotFoundError) do builder.build nil, @dest_path, output @@ -49,7 +49,7 @@ def test_build_cdylib Dir.chdir @ext do ENV.update(@rust_envs) - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) builder.build nil, @dest_path, output end @@ -58,7 +58,7 @@ def test_build_cdylib bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}") assert_match "Finished release [optimized] target(s)", output - assert_ffi_handle bundle, 'Init_rust_ruby_example' + assert_ffi_handle bundle, "Init_rust_ruby_example" rescue Exception => e pp output if output @@ -73,7 +73,7 @@ def test_build_dev_profile Dir.chdir @ext do ENV.update(@rust_envs) - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) builder.profile = :dev builder.build nil, @dest_path, output @@ -83,7 +83,7 @@ def test_build_dev_profile bundle = File.join(@dest_path, "debug/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}") assert_match "Finished dev [unoptimized + debuginfo] target(s)", output - assert_ffi_handle bundle, 'Init_rust_ruby_example' + assert_ffi_handle bundle, "Init_rust_ruby_example" rescue Exception => e pp output if output @@ -96,12 +96,12 @@ def test_build_fail output = [] - FileUtils.rm(File.join(@ext, 'src/lib.rs')) + FileUtils.rm(File.join(@ext, "src/lib.rs")) error = assert_raise(Gem::InstallError) do Dir.chdir @ext do ENV.update(@rust_envs) - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) builder.build nil, @dest_path, output end @@ -109,20 +109,20 @@ def test_build_fail output = output.join "\n" - assert_match 'cargo failed', error.message + assert_match "cargo failed", error.message end def test_full_integration skip_unsupported_platforms! setup_rust_gem "rust_ruby_example" - require 'open3' + require "open3" Dir.chdir @ext do - require 'tmpdir' + require "tmpdir" env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home) - gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)] + gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path("../../bin/gem", __dir__)] Dir.mktmpdir("rust_ruby_example") do |dir| built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem")) @@ -141,10 +141,10 @@ def test_custom_name setup_rust_gem "custom_name" Dir.chdir @ext do - require 'tmpdir' + require "tmpdir" env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home) - gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)] + gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path("../../bin/gem", __dir__)] Dir.mktmpdir("custom_name") do |dir| built_gem = File.expand_path(File.join(dir, "custom_name.gem")) @@ -163,15 +163,15 @@ def test_custom_name def skip_unsupported_platforms! pend "jruby not supported" if java_platform? - pend "truffleruby not supported (yet)" if RUBY_ENGINE == 'truffleruby' - pend "mswin not supported (yet)" if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') - system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out]) - pend 'cargo not present' unless $?.success? + pend "truffleruby not supported (yet)" if RUBY_ENGINE == "truffleruby" + pend "mswin not supported (yet)" if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") + system(@rust_envs, "cargo", "-V", out: IO::NULL, err: [:child, :out]) + pend "cargo not present" unless $?.success? pend "ruby.h is not provided by ruby repo" if ruby_repo? end def assert_ffi_handle(bundle, name) - require 'fiddle' + require "fiddle" dylib_handle = Fiddle.dlopen bundle assert_nothing_raised { dylib_handle[name] } end diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb b/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb index 63ac2e5ce644..21c4fd1c8dec 100644 --- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb +++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb @@ -1,17 +1,17 @@ -if ENV['RUBYOPT'] or defined? Gem - ENV.delete 'RUBYOPT' +if ENV["RUBYOPT"] or defined? Gem + ENV.delete "RUBYOPT" - require 'rbconfig' - cmd = [RbConfig.ruby, '--disable-gems', 'build.rb', *ARGV] + require "rbconfig" + cmd = [RbConfig.ruby, "--disable-gems", "build.rb", *ARGV] exec(*cmd) end -require 'tmpdir' +require "tmpdir" -lp = File.expand_path('../../../../lib', __dir__) -gem = ["ruby", "-I#{lp}", File.expand_path('../../../../bin/gem', __dir__)] -gemspec = File.expand_path('custom_name.gemspec', __dir__) +lp = File.expand_path("../../../../lib", __dir__) +gem = ["ruby", "-I#{lp}", File.expand_path("../../../../bin/gem", __dir__)] +gemspec = File.expand_path("custom_name.gemspec", __dir__) Dir.mktmpdir("custom_name") do |dir| built_gem = File.expand_path(File.join(dir, "custom_name.gem")) diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec b/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec index 1ecdae2c3328..1f8e270e9658 100644 --- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec @@ -6,5 +6,5 @@ Gem::Specification.new do |s| s.authors = ["Ian Ker-Seymer"] s.files = ["Cargo.toml", "Cargo.lock", "src/lib.rs"] - s.metadata['cargo_crate_name'] = 'custom-name-ext' + s.metadata["cargo_crate_name"] = "custom-name-ext" end diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb index 869bbb5de82f..81b12f99ec02 100644 --- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb +++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb @@ -1,17 +1,17 @@ -if ENV['RUBYOPT'] or defined? Gem - ENV.delete 'RUBYOPT' +if ENV["RUBYOPT"] or defined? Gem + ENV.delete "RUBYOPT" - require 'rbconfig' - cmd = [RbConfig.ruby, '--disable-gems', 'build.rb', *ARGV] + require "rbconfig" + cmd = [RbConfig.ruby, "--disable-gems", "build.rb", *ARGV] exec(*cmd) end -require 'tmpdir' +require "tmpdir" -lp = File.expand_path('../../../../lib', __dir__) -gem = ["ruby", "-I#{lp}", File.expand_path('../../../../bin/gem', __dir__)] -gemspec = File.expand_path('rust_ruby_example.gemspec', __dir__) +lp = File.expand_path("../../../../lib", __dir__) +gem = ["ruby", "-I#{lp}", File.expand_path("../../../../bin/gem", __dir__)] +gemspec = File.expand_path("rust_ruby_example.gemspec", __dir__) Dir.mktmpdir("rust_ruby_example") do |dir| built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem")) diff --git a/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb b/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb index 3abcb83fa927..88581ea4d803 100644 --- a/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +++ b/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' -require 'rubygems/ext/cargo_builder/link_flag_converter' +require_relative "helper" +require "rubygems/ext" +require "rubygems/ext/cargo_builder/link_flag_converter" class TestGemExtCargoBuilderLinkFlagConverter < Gem::TestCase CASES = { diff --git a/test/rubygems/test_gem_ext_cargo_builder_unit.rb b/test/rubygems/test_gem_ext_cargo_builder_unit.rb index f6712e44a105..4484f48ca9bf 100644 --- a/test/rubygems/test_gem_ext_cargo_builder_unit.rb +++ b/test/rubygems/test_gem_ext_cargo_builder_unit.rb @@ -1,72 +1,72 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' +require_relative "helper" +require "rubygems/ext" class TestGemExtCargoBuilderUnit < Gem::TestCase def test_cargo_command_passes_args skip_unsupported_platforms! - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) - command = builder.cargo_command(Dir.pwd, @tempdir, ['--all-features']) + command = builder.cargo_command(Dir.pwd, @tempdir, ["--all-features"]) - assert_includes command, '--all-features' + assert_includes command, "--all-features" end def test_cargo_command_locks_in_release_profile skip_unsupported_platforms! - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) builder.profile = :release command = builder.cargo_command(Dir.pwd, @tempdir) - assert_includes command, '--locked' + assert_includes command, "--locked" end def test_cargo_command_does_not_lock_in_dev_profile skip_unsupported_platforms! - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) builder.profile = :dev command = builder.cargo_command(Dir.pwd, @tempdir) - assert_not_includes command, '--locked' + assert_not_includes command, "--locked" end def test_cargo_command_passes_respects_cargo_env_var skip_unsupported_platforms! - old_cargo = ENV['CARGO'] - ENV['CARGO'] = 'mycargo' - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + old_cargo = ENV["CARGO"] + ENV["CARGO"] = "mycargo" + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) command = builder.cargo_command(Dir.pwd, @tempdir) - assert_includes command, 'mycargo' + assert_includes command, "mycargo" ensure - ENV['CARGO'] = old_cargo + ENV["CARGO"] = old_cargo end def test_build_env_includes_rbconfig skip_unsupported_platforms! - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) env = builder.build_env - assert_equal env.fetch('RBCONFIG_RUBY_SO_NAME'), RbConfig::CONFIG['RUBY_SO_NAME'] + assert_equal env.fetch("RBCONFIG_RUBY_SO_NAME"), RbConfig::CONFIG["RUBY_SO_NAME"] end def test_cargo_command_passes_respects_cargo_build_target skip_unsupported_platforms! - old_cargo = ENV['CARGO_BUILD_TARGET'] - ENV['CARGO_BUILD_TARGET'] = 'x86_64-unknown-linux-gnu' - spec = Gem::Specification.new 'rust_ruby_example', '0.1.0' + old_cargo = ENV["CARGO_BUILD_TARGET"] + ENV["CARGO_BUILD_TARGET"] = "x86_64-unknown-linux-gnu" + spec = Gem::Specification.new "rust_ruby_example", "0.1.0" builder = Gem::Ext::CargoBuilder.new(spec) - command = builder.cargo_command(Dir.pwd, @tempdir, ['--locked']) + command = builder.cargo_command(Dir.pwd, @tempdir, ["--locked"]) - assert_includes command, '--target' - assert_includes command, 'x86_64-unknown-linux-gnu' + assert_includes command, "--target" + assert_includes command, "x86_64-unknown-linux-gnu" ensure - ENV['CARGO_BUILD_TARGET'] = old_cargo + ENV["CARGO_BUILD_TARGET"] = old_cargo end def skip_unsupported_platforms! diff --git a/test/rubygems/test_gem_ext_cmake_builder.rb b/test/rubygems/test_gem_ext_cmake_builder.rb index b4d7cf2d3041..ee84b8e7289c 100644 --- a/test/rubygems/test_gem_ext_cmake_builder.rb +++ b/test/rubygems/test_gem_ext_cmake_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' +require_relative "helper" +require "rubygems/ext" class TestGemExtCmakeBuilder < Gem::TestCase def setup @@ -12,21 +12,21 @@ def setup require "open3" begin - _, status = Open3.capture2e('cmake') - pend 'cmake not present' unless status.success? + _, status = Open3.capture2e("cmake") + pend "cmake not present" unless status.success? rescue Errno::ENOENT - pend 'cmake not present' + pend "cmake not present" end - @ext = File.join @tempdir, 'ext' - @dest_path = File.join @tempdir, 'prefix' + @ext = File.join @tempdir, "ext" + @dest_path = File.join @tempdir, "prefix" FileUtils.mkdir_p @ext FileUtils.mkdir_p @dest_path end def test_self_build - File.open File.join(@ext, 'CMakeLists.txt'), 'w' do |cmakelists| + File.open File.join(@ext, "CMakeLists.txt"), "w" do |cmakelists| cmakelists.write <<-EO_CMAKE cmake_minimum_required(VERSION 2.6) project(self_build NONE) @@ -34,7 +34,7 @@ def test_self_build EO_CMAKE end - FileUtils.touch File.join(@ext, 'test.txt') + FileUtils.touch File.join(@ext, "test.txt") output = [] @@ -44,8 +44,8 @@ def test_self_build assert_match %r{^cmake \. -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output assert_match %r{#{Regexp.escape @ext}}, output - assert_contains_make_command '', output - assert_contains_make_command 'install', output + assert_contains_make_command "", output + assert_contains_make_command "install", output assert_match %r{test\.txt}, output end @@ -60,14 +60,14 @@ def test_self_build_fail shell_error_msg = %r{(CMake Error: .*)} - assert_match 'cmake failed', error.message + assert_match "cmake failed", error.message assert_match %r{^cmake . -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output assert_match %r{#{shell_error_msg}}, output end def test_self_build_has_makefile - File.open File.join(@ext, 'Makefile'), 'w' do |makefile| + File.open File.join(@ext, "Makefile"), "w" do |makefile| makefile.puts "all:\n\t@echo ok\ninstall:\n\t@echo ok" end @@ -77,7 +77,7 @@ def test_self_build_has_makefile output = output.join "\n" - assert_contains_make_command '', output - assert_contains_make_command 'install', output + assert_contains_make_command "", output + assert_contains_make_command "install", output end end diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb index 76ccfe2dc454..191b332ddad1 100644 --- a/test/rubygems/test_gem_ext_configure_builder.rb +++ b/test/rubygems/test_gem_ext_configure_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' +require_relative "helper" +require "rubygems/ext" class TestGemExtConfigureBuilder < Gem::TestCase def setup @@ -9,8 +9,8 @@ def setup @makefile_body = "clean:\n\t@echo ok\nall:\n\t@echo ok\ninstall:\n\t@echo ok" - @ext = File.join @tempdir, 'ext' - @dest_path = File.join @tempdir, 'prefix' + @ext = File.join @tempdir, "ext" + @dest_path = File.join @tempdir, "prefix" FileUtils.mkdir_p @ext FileUtils.mkdir_p @dest_path @@ -19,7 +19,7 @@ def setup def test_self_build pend("test_self_build skipped on MS Windows (VC++)") if vc_windows? - File.open File.join(@ext, './configure'), 'w' do |configure| + File.open File.join(@ext, "./configure"), "w" do |configure| configure.puts "#!/bin/sh\necho \"#{@makefile_body}\" > Makefile" end @@ -31,13 +31,13 @@ def test_self_build assert_equal "sh ./configure --prefix\\=#{@dest_path}", output.shift assert_equal "", output.shift assert_match(/^current directory:/, output.shift) - assert_contains_make_command 'clean', output.shift + assert_contains_make_command "clean", output.shift assert_match(/^ok$/m, output.shift) assert_match(/^current directory:/, output.shift) - assert_contains_make_command '', output.shift + assert_contains_make_command "", output.shift assert_match(/^ok$/m, output.shift) assert_match(/^current directory:/, output.shift) - assert_contains_make_command 'install', output.shift + assert_contains_make_command "install", output.shift assert_match(/^ok$/m, output.shift) end @@ -52,7 +52,7 @@ def test_self_build_fail shell_error_msg = %r{(\./configure: .*)|((?:[Cc]an't|cannot) open '?\./configure'?(?:: No such file or directory)?)} sh_prefix_configure = "sh ./configure --prefix\\=" - assert_match 'configure failed', error.message + assert_match "configure failed", error.message assert_match(/^current directory:/, output.shift) assert_equal "#{sh_prefix_configure}#{@dest_path}", output.shift @@ -65,15 +65,15 @@ def test_self_build_has_makefile pend("test_self_build_has_makefile skipped - nmake not found") end - File.open File.join(@ext, 'Makefile'), 'w' do |makefile| + File.open File.join(@ext, "Makefile"), "w" do |makefile| makefile.puts @makefile_body end output = [] Gem::Ext::ConfigureBuilder.build nil, @dest_path, output, [], nil, @ext - assert_contains_make_command 'clean', output[1] - assert_contains_make_command '', output[4] - assert_contains_make_command 'install', output[7] + assert_contains_make_command "clean", output[1] + assert_contains_make_command "", output[4] + assert_contains_make_command "install", output[7] end end diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb index 38d07aa52b77..e6b980a96bbd 100644 --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' +require_relative "helper" +require "rubygems/ext" class TestGemExtExtConfBuilder < Gem::TestCase def setup super - @ext = File.join @tempdir, 'ext' - @dest_path = File.join @tempdir, 'prefix' + @ext = File.join @tempdir, "ext" + @dest_path = File.join @tempdir, "prefix" FileUtils.mkdir_p @ext FileUtils.mkdir_p @dest_path @@ -23,13 +23,13 @@ def test_class_build pend("test_class_build skipped - nmake not found") end - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + File.open File.join(@ext, "extconf.rb"), "w" do |extconf| extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" end output = [] - result = Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output, [], nil, @ext + result = Gem::Ext::ExtConfBuilder.build "extconf.rb", @dest_path, output, [], nil, @ext assert_same result, output @@ -37,11 +37,11 @@ def test_class_build assert_match(/^#{Gem.ruby}.* extconf.rb/, output[1]) assert_equal "creating Makefile\n", output[2] assert_match(/^current directory:/, output[3]) - assert_contains_make_command 'clean', output[4] - assert_contains_make_command '', output[7] - assert_contains_make_command 'install', output[10] - assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb')) - assert_empty Dir.glob(File.join(@ext, '.gem.*')) + assert_contains_make_command "clean", output[4] + assert_contains_make_command "", output[7] + assert_contains_make_command "install", output[10] + assert_empty Dir.glob(File.join(@ext, "siteconf*.rb")) + assert_empty Dir.glob(File.join(@ext, ".gem.*")) end def test_class_build_rbconfig_make_prog @@ -50,49 +50,49 @@ def test_class_build_rbconfig_make_prog end configure_args do - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + File.open File.join(@ext, "extconf.rb"), "w" do |extconf| extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" end output = [] - Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output, [], nil, @ext + Gem::Ext::ExtConfBuilder.build "extconf.rb", @dest_path, output, [], nil, @ext assert_equal "creating Makefile\n", output[2] - assert_contains_make_command 'clean', output[4] - assert_contains_make_command '', output[7] - assert_contains_make_command 'install', output[10] + assert_contains_make_command "clean", output[4] + assert_contains_make_command "", output[7] + assert_contains_make_command "install", output[10] end end def test_class_build_env_MAKE - env_make = ENV.delete 'make' - ENV['make'] = nil + env_make = ENV.delete "make" + ENV["make"] = nil - env_MAKE = ENV.delete 'MAKE' - ENV['MAKE'] = 'anothermake' + env_MAKE = ENV.delete "MAKE" + ENV["MAKE"] = "anothermake" if java_platform? pend("failing on jruby") end - configure_args '' do - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + configure_args "" do + File.open File.join(@ext, "extconf.rb"), "w" do |extconf| extconf.puts "require 'mkmf'\ncreate_makefile 'foo'" end output = [] assert_raise Gem::InstallError do - Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output, [], nil, @ext + Gem::Ext::ExtConfBuilder.build "extconf.rb", @dest_path, output, [], nil, @ext end assert_equal "creating Makefile\n", output[2] - assert_contains_make_command 'clean', output[4] + assert_contains_make_command "clean", output[4] end ensure - ENV['MAKE'] = env_MAKE - ENV['make'] = env_make + ENV["MAKE"] = env_MAKE + ENV["make"] = env_make end def test_class_build_extconf_fail @@ -100,7 +100,7 @@ def test_class_build_extconf_fail pend("test_class_build_extconf_fail skipped - nmake not found") end - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + File.open File.join(@ext, "extconf.rb"), "w" do |extconf| extconf.puts "require 'mkmf'" extconf.puts "have_library 'nonexistent' or abort 'need libnonexistent'" extconf.puts "create_makefile 'foo'" @@ -109,16 +109,16 @@ def test_class_build_extconf_fail output = [] error = assert_raise Gem::InstallError do - Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output, [], nil, @ext + Gem::Ext::ExtConfBuilder.build "extconf.rb", @dest_path, output, [], nil, @ext end - assert_equal 'extconf failed, exit code 1', error.message + assert_equal "extconf failed, exit code 1", error.message assert_match(/^#{Gem.ruby}.* extconf.rb/, output[1]) - assert_match(File.join(@dest_path, 'mkmf.log'), output[4]) + assert_match(File.join(@dest_path, "mkmf.log"), output[4]) assert_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n") - assert_path_exist File.join @dest_path, 'mkmf.log' + assert_path_exist File.join @dest_path, "mkmf.log" end def test_class_build_extconf_success_without_warning @@ -126,7 +126,7 @@ def test_class_build_extconf_success_without_warning pend("test_class_build_extconf_fail skipped - nmake not found") end - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + File.open File.join(@ext, "extconf.rb"), "w" do |extconf| extconf.puts "require 'mkmf'" extconf.puts "File.open('mkmf.log', 'w'){|f| f.write('a')}" extconf.puts "create_makefile 'foo'" @@ -134,11 +134,11 @@ def test_class_build_extconf_success_without_warning output = [] - Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output, [], nil, @ext + Gem::Ext::ExtConfBuilder.build "extconf.rb", @dest_path, output, [], nil, @ext refute_includes(output, "To see why this extension failed to compile, please check the mkmf.log which can be found here:\n") - assert_path_exist File.join @dest_path, 'mkmf.log' + assert_path_exist File.join @dest_path, "mkmf.log" end def test_class_build_unconventional @@ -146,7 +146,7 @@ def test_class_build_unconventional pend("test_class_build skipped - nmake not found") end - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf| + File.open File.join(@ext, "extconf.rb"), "w" do |extconf| extconf.puts <<-'EXTCONF' include RbConfig @@ -174,12 +174,12 @@ def test_class_build_unconventional output = [] - Gem::Ext::ExtConfBuilder.build 'extconf.rb', @dest_path, output, [], nil, @ext + Gem::Ext::ExtConfBuilder.build "extconf.rb", @dest_path, output, [], nil, @ext - assert_contains_make_command 'clean', output[4] - assert_contains_make_command '', output[7] - assert_contains_make_command 'install', output[10] - assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb')) + assert_contains_make_command "clean", output[4] + assert_contains_make_command "", output[7] + assert_contains_make_command "install", output[10] + assert_empty Dir.glob(File.join(@ext, "siteconf*.rb")) end def test_class_make @@ -188,8 +188,8 @@ def test_class_make end output = [] - makefile_path = File.join(@ext, 'Makefile') - File.open makefile_path, 'w' do |makefile| + makefile_path = File.join(@ext, "Makefile") + File.open makefile_path, "w" do |makefile| makefile.puts "# π" makefile.puts "RUBYARCHDIR = $(foo)$(target_prefix)" makefile.puts "RUBYLIBDIR = $(bar)$(target_prefix)" @@ -200,30 +200,30 @@ def test_class_make Gem::Ext::ExtConfBuilder.make @ext, output, @ext - assert_contains_make_command 'clean', output[1] - assert_contains_make_command '', output[4] - assert_contains_make_command 'install', output[7] + assert_contains_make_command "clean", output[1] + assert_contains_make_command "", output[4] + assert_contains_make_command "install", output[7] end def test_class_make_no_Makefile error = assert_raise Gem::InstallError do - Gem::Ext::ExtConfBuilder.make @ext, ['output'], @ext + Gem::Ext::ExtConfBuilder.make @ext, ["output"], @ext end - assert_equal 'Makefile not found', error.message + assert_equal "Makefile not found", error.message end def configure_args(args = nil) - configure_args = RbConfig::CONFIG['configure_args'] - RbConfig::CONFIG['configure_args'] = args if args + configure_args = RbConfig::CONFIG["configure_args"] + RbConfig::CONFIG["configure_args"] = args if args yield ensure if configure_args - RbConfig::CONFIG['configure_args'] = configure_args + RbConfig::CONFIG["configure_args"] = configure_args else - RbConfig::CONFIG.delete 'configure_args' + RbConfig::CONFIG.delete "configure_args" end end end diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb index 3d8922eed540..3ed818a7f8df 100644 --- a/test/rubygems/test_gem_ext_rake_builder.rb +++ b/test/rubygems/test_gem_ext_rake_builder.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/ext' +require_relative "helper" +require "rubygems/ext" class TestGemExtRakeBuilder < Gem::TestCase def setup super - @ext = File.join @tempdir, 'ext' - @dest_path = File.join @tempdir, 'prefix' + @ext = File.join @tempdir, "ext" + @dest_path = File.join @tempdir, "prefix" FileUtils.mkdir_p @ext FileUtils.mkdir_p @dest_path end def test_class_build - create_temp_mkrf_file('task :default') + create_temp_mkrf_file("task :default") output = [] build_rake_in do |rake| - Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output, [], nil, @ext + Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output, [], nil, @ext output = output.join "\n" @@ -32,12 +32,12 @@ def test_class_build # # It should not fail with a non-empty args list either def test_class_build_with_args - create_temp_mkrf_file('task :default') + create_temp_mkrf_file("task :default") output = [] build_rake_in do |rake| - non_empty_args_list = [''] - Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output, non_empty_args_list, nil, @ext + non_empty_args_list = [""] + Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output, non_empty_args_list, nil, @ext output = output.join "\n" @@ -48,25 +48,25 @@ def test_class_build_with_args end def test_class_no_openssl_override - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL - create_temp_mkrf_file('task :default') + create_temp_mkrf_file("task :default") - rake = util_spec 'rake' do |s| + rake = util_spec "rake" do |s| s.executables = %w[rake] s.files = %w[bin/rake] end output = [] - write_file File.join(@tempdir, 'bin', 'rake') do |fp| + write_file File.join(@tempdir, "bin", "rake") do |fp| fp.puts "#!/usr/bin/ruby" fp.puts "require 'openssl'; puts OpenSSL" end install_gem rake - Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', @dest_path, output, [''], nil, @ext + Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output, [""], nil, @ext output = output.join "\n" @@ -101,7 +101,7 @@ def test_class_build_fail end def create_temp_mkrf_file(rakefile_content) - File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf| + File.open File.join(@ext, "mkrf_conf.rb"), "w" do |mkrf_conf| mkrf_conf.puts <<-EO_MKRF File.open("Rakefile","w") do |f| f.puts "#{rakefile_content}" diff --git a/test/rubygems/test_gem_gem_runner.rb b/test/rubygems/test_gem_gem_runner.rb index 6f5361cf2f00..f0128febc828 100644 --- a/test/rubygems/test_gem_gem_runner.rb +++ b/test/rubygems/test_gem_gem_runner.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemGemRunner < Gem::TestCase def setup super - require 'rubygems/command' + require "rubygems/command" @orig_args = Gem::Command.build_args @orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup @orig_extra_args = Gem::Command.extra_args.dup - require 'rubygems/gem_runner' + require "rubygems/gem_runner" @runner = Gem::GemRunner.new end @@ -25,15 +25,15 @@ def teardown def test_do_configuration Gem.clear_paths - temp_conf = File.join @tempdir, '.gemrc' + temp_conf = File.join @tempdir, ".gemrc" - other_gem_path = File.join @tempdir, 'other_gem_path' - other_gem_home = File.join @tempdir, 'other_gem_home' + other_gem_path = File.join @tempdir, "other_gem_path" + other_gem_home = File.join @tempdir, "other_gem_home" Gem.ensure_gem_subdirectories other_gem_path Gem.ensure_gem_subdirectories other_gem_home - File.open temp_conf, 'w' do |fp| + File.open temp_conf, "w" do |fp| fp.puts "gem: --commands" fp.puts "gemhome: #{other_gem_home}" fp.puts "gempath:" diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb index 9bfc22a20253..2ca5b402d95c 100644 --- a/test/rubygems/test_gem_gemcutter_utilities.rb +++ b/test/rubygems/test_gem_gemcutter_utilities.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems' -require 'rubygems/command' -require 'rubygems/gemcutter_utilities' +require_relative "helper" +require "rubygems" +require "rubygems/command" +require "rubygems/gemcutter_utilities" class TestGemGemcutterUtilities < Gem::TestCase def setup @@ -13,17 +13,17 @@ def setup # below needed for random testing, class property Gem.configuration.disable_default_gem_server = nil - ENV['RUBYGEMS_HOST'] = nil - ENV['GEM_HOST_OTP_CODE'] = nil + ENV["RUBYGEMS_HOST"] = nil + ENV["GEM_HOST_OTP_CODE"] = nil Gem.configuration.rubygems_api_key = nil - @cmd = Gem::Command.new '', 'summary' + @cmd = Gem::Command.new "", "summary" @cmd.extend Gem::GemcutterUtilities end def teardown - ENV['RUBYGEMS_HOST'] = nil - ENV['GEM_HOST_OTP_CODE'] = nil + ENV["RUBYGEMS_HOST"] = nil + ENV["GEM_HOST_OTP_CODE"] = nil Gem.configuration.rubygems_api_key = nil credential_teardown @@ -33,11 +33,11 @@ def teardown def test_alternate_key_alternate_host keys = { - :rubygems_api_key => 'KEY', + :rubygems_api_key => "KEY", "http://rubygems.engineyard.com" => "EYKEY", } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end @@ -45,25 +45,25 @@ def test_alternate_key_alternate_host Gem.configuration.load_api_keys - assert_equal 'EYKEY', @cmd.api_key + assert_equal "EYKEY", @cmd.api_key end def test_api_key - keys = { :rubygems_api_key => 'KEY' } + keys = { :rubygems_api_key => "KEY" } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys - assert_equal 'KEY', @cmd.api_key + assert_equal "KEY", @cmd.api_key end def test_api_key_override - keys = { :rubygems_api_key => 'KEY', :other => 'OTHER' } + keys = { :rubygems_api_key => "KEY", :other => "OTHER" } - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end @@ -72,28 +72,28 @@ def test_api_key_override @cmd.add_key_option @cmd.handle_options %w[--key other] - assert_equal 'OTHER', @cmd.api_key + assert_equal "OTHER", @cmd.api_key end def test_host - assert_equal 'https://rubygems.org', @cmd.host + assert_equal "https://rubygems.org", @cmd.host end def test_host_RUBYGEMS_HOST - ENV['RUBYGEMS_HOST'] = 'https://other.example' + ENV["RUBYGEMS_HOST"] = "https://other.example" - assert_equal 'https://other.example', @cmd.host + assert_equal "https://other.example", @cmd.host end def test_host_RUBYGEMS_HOST_empty - ENV['RUBYGEMS_HOST'] = '' + ENV["RUBYGEMS_HOST"] = "" - assert_equal 'https://rubygems.org', @cmd.host + assert_equal "https://rubygems.org", @cmd.host end def test_sign_in - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - util_sign_in [api_key, 200, 'OK'] + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" + util_sign_in [api_key, 200, "OK"] assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output assert @fetcher.last_request["authorization"] @@ -104,9 +104,9 @@ def test_sign_in end def test_sign_in_with_host - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" - util_sign_in [api_key, 200, 'OK'], 'http://example.com', ['http://example.com'] + util_sign_in [api_key, 200, "OK"], "http://example.com", ["http://example.com"] assert_match "Enter your http://example.com credentials.", @sign_in_ui.output @@ -114,13 +114,13 @@ def test_sign_in_with_host assert_match %r{Signed in.}, @sign_in_ui.output credentials = load_yaml_file Gem.configuration.credentials_path - assert_equal api_key, credentials['http://example.com'] + assert_equal api_key, credentials["http://example.com"] end def test_sign_in_with_host_nil - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" - util_sign_in [api_key, 200, 'OK'], nil, [nil] + util_sign_in [api_key, 200, "OK"], nil, [nil] assert_match "Enter your RubyGems.org credentials.", @sign_in_ui.output @@ -132,8 +132,8 @@ def test_sign_in_with_host_nil end def test_sign_in_with_host_ENV - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - util_sign_in [api_key, 200, 'OK'], 'http://example.com' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" + util_sign_in [api_key, 200, "OK"], "http://example.com" assert_match "Enter your http://example.com credentials.", @sign_in_ui.output @@ -141,35 +141,35 @@ def test_sign_in_with_host_ENV assert_match %r{Signed in.}, @sign_in_ui.output credentials = load_yaml_file Gem.configuration.credentials_path - assert_equal api_key, credentials['http://example.com'] + assert_equal api_key, credentials["http://example.com"] end def test_sign_in_skips_with_existing_credentials - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" Gem.configuration.rubygems_api_key = api_key - util_sign_in [api_key, 200, 'OK'] + util_sign_in [api_key, 200, "OK"] assert_equal "", @sign_in_ui.output end def test_sign_in_skips_with_key_override - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - Gem.configuration.api_keys[:KEY] = 'other' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" + Gem.configuration.api_keys[:KEY] = "other" @cmd.options[:key] = :KEY - util_sign_in [api_key, 200, 'OK'] + util_sign_in [api_key, 200, "OK"] assert_equal "", @sign_in_ui.output end def test_sign_in_with_other_credentials_doesnt_overwrite_other_keys - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - other_api_key = 'f46dbb18bb6a9c97cdc61b5b85c186a17403cdcbf' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" + other_api_key = "f46dbb18bb6a9c97cdc61b5b85c186a17403cdcbf" - File.open Gem.configuration.credentials_path, 'w' do |f| + File.open Gem.configuration.credentials_path, "w" do |f| f.write Hash[:other_api_key, other_api_key].to_yaml end - util_sign_in [api_key, 200, 'OK'] + util_sign_in [api_key, 200, "OK"] assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output assert_match %r{Signed in.}, @sign_in_ui.output @@ -181,7 +181,7 @@ def test_sign_in_with_other_credentials_doesnt_overwrite_other_keys def test_sign_in_with_bad_credentials assert_raise Gem::MockGemUi::TermError do - util_sign_in ['Access Denied.', 403, 'Forbidden'] + util_sign_in ["Access Denied.", 403, "Forbidden"] end assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output @@ -189,50 +189,50 @@ def test_sign_in_with_bad_credentials end def test_signin_with_env_otp_code - ENV['GEM_HOST_OTP_CODE'] = '111111' - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + ENV["GEM_HOST_OTP_CODE"] = "111111" + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" - util_sign_in [api_key, 200, 'OK'] + util_sign_in [api_key, 200, "OK"] - assert_match 'Signed in with API key:', @sign_in_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_match "Signed in with API key:", @sign_in_ui.output + assert_equal "111111", @fetcher.last_request["OTP"] end def test_sign_in_with_correct_otp_code - api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" response_fail = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." util_sign_in(proc do @call_count ||= 0 - (@call_count += 1).odd? ? [response_fail, 401, 'Unauthorized'] : [api_key, 200, 'OK'] + (@call_count += 1).odd? ? [response_fail, 401, "Unauthorized"] : [api_key, 200, "OK"] end, nil, [], "111111\n") - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @sign_in_ui.output - assert_match 'Code: ', @sign_in_ui.output - assert_match 'Signed in with API key:', @sign_in_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @sign_in_ui.output + assert_match "Code: ", @sign_in_ui.output + assert_match "Signed in with API key:", @sign_in_ui.output + assert_equal "111111", @fetcher.last_request["OTP"] end def test_sign_in_with_incorrect_otp_code response = "You have enabled multifactor authentication but your request doesn't have the correct OTP code. Please check it and retry." assert_raise Gem::MockGemUi::TermError do - util_sign_in [response, 401, 'Unauthorized'], nil, [], "111111\n" + util_sign_in [response, 401, "Unauthorized"], nil, [], "111111\n" end - assert_match 'You have enabled multi-factor authentication. Please enter OTP code.', @sign_in_ui.output - assert_match 'Code: ', @sign_in_ui.output + assert_match "You have enabled multi-factor authentication. Please enter OTP code.", @sign_in_ui.output + assert_match "Code: ", @sign_in_ui.output assert_match response, @sign_in_ui.output - assert_equal '111111', @fetcher.last_request['OTP'] + assert_equal "111111", @fetcher.last_request["OTP"] end - def util_sign_in(response, host = nil, args = [], extra_input = '') - email = 'you@example.com' - password = 'secret' - profile_response = [ "mfa: disabled\n" , 200, 'OK'] + def util_sign_in(response, host = nil, args = [], extra_input = "") + email = "you@example.com" + password = "secret" + profile_response = [ "mfa: disabled\n" , 200, "OK"] if host - ENV['RUBYGEMS_HOST'] = host + ENV["RUBYGEMS_HOST"] = host else host = Gem.host end @@ -254,13 +254,13 @@ def util_sign_in(response, host = nil, args = [], extra_input = '') end def test_verify_api_key - keys = { :other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' } - File.open Gem.configuration.credentials_path, 'w' do |f| + keys = { :other => "a5fdbb6ba150cbb83aad2bb2fede64cf040453903" } + File.open Gem.configuration.credentials_path, "w" do |f| f.write keys.to_yaml end Gem.configuration.load_api_keys - assert_equal 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903', + assert_equal "a5fdbb6ba150cbb83aad2bb2fede64cf040453903", @cmd.verify_api_key(:other) end diff --git a/test/rubygems/test_gem_impossible_dependencies_error.rb b/test/rubygems/test_gem_impossible_dependencies_error.rb index 971be151df42..59395f0bbd48 100644 --- a/test/rubygems/test_gem_impossible_dependencies_error.rb +++ b/test/rubygems/test_gem_impossible_dependencies_error.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemImpossibleDependenciesError < Gem::TestCase def test_message_conflict - request = dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8' + request = dependency_request dep("net-ssh", ">= 2.0.13"), "rye", "0.9.8" conflicts = [] @@ -11,9 +11,9 @@ def test_message_conflict # requested-by entries, but they are suitable for testing the message. # See #485 to construct a correct conflict. net_ssh_2_2_2 = - dependency_request dep('net-ssh', '>= 2.6.5'), 'net-ssh', '2.2.2', request + dependency_request dep("net-ssh", ">= 2.6.5"), "net-ssh", "2.2.2", request net_ssh_2_6_5 = - dependency_request dep('net-ssh', '~> 2.2.2'), 'net-ssh', '2.6.5', request + dependency_request dep("net-ssh", "~> 2.2.2"), "net-ssh", "2.6.5", request conflict1 = Gem::Resolver::Conflict.new \ net_ssh_2_6_5, net_ssh_2_6_5.requester diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb index 24afae5fcc7f..cfdff6e4c58d 100644 --- a/test/rubygems/test_gem_indexer.rb +++ b/test/rubygems/test_gem_indexer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/indexer' +require_relative "helper" +require "rubygems/indexer" class TestGemIndexer < Gem::TestCase def setup @@ -8,25 +8,25 @@ def setup util_make_gems - @d2_0 = util_spec 'd', '2.0' do |s| + @d2_0 = util_spec "d", "2.0" do |s| s.date = Gem::Specification::TODAY - 86400 * 3 end util_build_gem @d2_0 - @d2_0_a = util_spec 'd', '2.0.a' + @d2_0_a = util_spec "d", "2.0.a" util_build_gem @d2_0_a - @d2_0_b = util_spec 'd', '2.0.b' + @d2_0_b = util_spec "d", "2.0.b" util_build_gem @d2_0_b - @default = new_default_spec 'default', 2 + @default = new_default_spec "default", 2 install_default_gems @default - @indexerdir = File.join(@tempdir, 'indexer') + @indexerdir = File.join(@tempdir, "indexer") - gems = File.join(@indexerdir, 'gems') + gems = File.join(@indexerdir, "gems") FileUtils.mkdir_p gems - FileUtils.mv Dir[File.join(@gemhome, "cache", '*.gem')], gems + FileUtils.mv Dir[File.join(@gemhome, "cache", "*.gem")], gems @indexer = Gem::Indexer.new(@indexerdir) end @@ -79,7 +79,7 @@ def test_build_indices ["pl", Gem::Version.new("1"), "i386-linux"], ["x", Gem::Version.new("1"), "ruby"]] - assert_equal expected, latest_specs, 'latest_specs' + assert_equal expected, latest_specs, "latest_specs" end def test_generate_index @@ -87,7 +87,7 @@ def test_generate_index @indexer.generate_index end - quickdir = File.join @indexerdir, 'quick' + quickdir = File.join @indexerdir, "quick" marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}" assert_directory_exists quickdir @@ -114,15 +114,15 @@ def test_generate_index_modern @indexer.generate_index end - refute_indexed @indexerdir, 'yaml' - refute_indexed @indexerdir, 'yaml.Z' + refute_indexed @indexerdir, "yaml" + refute_indexed @indexerdir, "yaml.Z" refute_indexed @indexerdir, "Marshal.#{@marshal_version}" refute_indexed @indexerdir, "Marshal.#{@marshal_version}.Z" - quickdir = File.join @indexerdir, 'quick' + quickdir = File.join @indexerdir, "quick" marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}" - assert_directory_exists quickdir, 'quickdir should be directory' + assert_directory_exists quickdir, "quickdir should be directory" assert_directory_exists marshal_quickdir refute_indexed quickdir, "index" @@ -165,7 +165,7 @@ def test_generate_index_modern_back_to_back use_ui @ui do @indexer.generate_index end - quickdir = File.join @indexerdir, 'quick' + quickdir = File.join @indexerdir, "quick" marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}" assert_directory_exists quickdir @@ -196,7 +196,7 @@ def test_generate_index_ui assert_match %r{^Complete$}, @ui.output assert_match %r{^Compressing indices$}, @ui.output - assert_equal '', @ui.error + assert_equal "", @ui.error end def test_generate_index_specs @@ -210,30 +210,30 @@ def test_generate_index_specs specs = Marshal.load specs_dump expected = [ - ['a', Gem::Version.new(1), 'ruby'], - ['a', Gem::Version.new(2), 'ruby'], - ['a_evil', Gem::Version.new(9), 'ruby'], - ['b', Gem::Version.new(2), 'ruby'], - ['c', Gem::Version.new('1.2'), 'ruby'], - ['d', Gem::Version.new('2.0'), 'ruby'], - ['dep_x', Gem::Version.new(1), 'ruby'], - ['pl', Gem::Version.new(1), 'i386-linux'], - ['x', Gem::Version.new(1), 'ruby'], + ["a", Gem::Version.new(1), "ruby"], + ["a", Gem::Version.new(2), "ruby"], + ["a_evil", Gem::Version.new(9), "ruby"], + ["b", Gem::Version.new(2), "ruby"], + ["c", Gem::Version.new("1.2"), "ruby"], + ["d", Gem::Version.new("2.0"), "ruby"], + ["dep_x", Gem::Version.new(1), "ruby"], + ["pl", Gem::Version.new(1), "i386-linux"], + ["x", Gem::Version.new(1), "ruby"], ] assert_equal expected, specs assert_same specs[0].first, specs[1].first, - 'identical names not identical' + "identical names not identical" assert_same specs[0][1], specs[-1][1], - 'identical versions not identical' + "identical versions not identical" assert_same specs[0].last, specs[1].last, - 'identical platforms not identical' + "identical platforms not identical" refute_same specs[1][1], specs[5][1], - 'different versions not different' + "different versions not different" end def test_generate_index_latest_specs @@ -247,23 +247,23 @@ def test_generate_index_latest_specs latest_specs = Marshal.load latest_specs_dump expected = [ - ['a', Gem::Version.new(2), 'ruby'], - ['a_evil', Gem::Version.new(9), 'ruby'], - ['b', Gem::Version.new(2), 'ruby'], - ['c', Gem::Version.new('1.2'), 'ruby'], - ['d', Gem::Version.new('2.0'), 'ruby'], - ['dep_x', Gem::Version.new(1), 'ruby'], - ['pl', Gem::Version.new(1), 'i386-linux'], - ['x', Gem::Version.new(1), 'ruby'], + ["a", Gem::Version.new(2), "ruby"], + ["a_evil", Gem::Version.new(9), "ruby"], + ["b", Gem::Version.new(2), "ruby"], + ["c", Gem::Version.new("1.2"), "ruby"], + ["d", Gem::Version.new("2.0"), "ruby"], + ["dep_x", Gem::Version.new(1), "ruby"], + ["pl", Gem::Version.new(1), "i386-linux"], + ["x", Gem::Version.new(1), "ruby"], ] assert_equal expected, latest_specs assert_same latest_specs[0][1], latest_specs[2][1], - 'identical versions not identical' + "identical versions not identical" assert_same latest_specs[0].last, latest_specs[1].last, - 'identical platforms not identical' + "identical platforms not identical" end def test_generate_index_prerelease_specs @@ -276,9 +276,9 @@ def test_generate_index_prerelease_specs prerelease_specs_dump = Gem.read_binary prerelease_specs_path prerelease_specs = Marshal.load prerelease_specs_dump - assert_equal [['a', Gem::Version.new('3.a'), 'ruby'], - ['d', Gem::Version.new('2.0.a'), 'ruby'], - ['d', Gem::Version.new('2.0.b'), 'ruby']], + assert_equal [["a", Gem::Version.new("3.a"), "ruby"], + ["d", Gem::Version.new("2.0.a"), "ruby"], + ["d", Gem::Version.new("2.0.b"), "ruby"]], prerelease_specs end @@ -288,7 +288,7 @@ def test_generate_index_prerelease_specs def with_system_gems Gem::Specification.reset - sys_gem = util_spec 'systemgem', '1.0' + sys_gem = util_spec "systemgem", "1.0" util_build_gem sys_gem install_default_gems sys_gem yield @@ -300,21 +300,21 @@ def test_update_index @indexer.generate_index end - quickdir = File.join @indexerdir, 'quick' + quickdir = File.join @indexerdir, "quick" marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}" assert_directory_exists quickdir assert_directory_exists marshal_quickdir - @d2_1 = util_spec 'd', '2.1' + @d2_1 = util_spec "d", "2.1" util_build_gem @d2_1 @d2_1_tuple = [@d2_1.name, @d2_1.version, @d2_1.original_platform] - @d2_1_a = util_spec 'd', '2.2.a' + @d2_1_a = util_spec "d", "2.2.a" util_build_gem @d2_1_a @d2_1_a_tuple = [@d2_1_a.name, @d2_1_a.version, @d2_1_a.original_platform] - gems = File.join @indexerdir, 'gems' + gems = File.join @indexerdir, "gems" FileUtils.mv @d2_1.cache_file, gems FileUtils.mv @d2_1_a.cache_file, gems diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb index a499c2be3be2..e2225a1eba38 100644 --- a/test/rubygems/test_gem_install_update_options.rb +++ b/test/rubygems/test_gem_install_update_options.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require_relative 'installer_test_case' -require 'rubygems/install_update_options' -require 'rubygems/command' -require 'rubygems/dependency_installer' +require_relative "installer_test_case" +require "rubygems/install_update_options" +require "rubygems/command" +require "rubygems/dependency_installer" class TestGemInstallUpdateOptions < Gem::InstallerTestCase def setup super - @cmd = Gem::Command.new 'dummy', 'dummy', + @cmd = Gem::Command.new "dummy", "dummy", Gem::DependencyInstaller::DEFAULT_OPTIONS @cmd.extend Gem::InstallUpdateOptions @cmd.add_install_update_options @@ -38,7 +38,7 @@ def test_add_install_update_options def test_build_root @cmd.handle_options %w[--build-root build_root] - assert_equal File.expand_path('build_root'), @cmd.options[:build_root] + assert_equal File.expand_path("build_root"), @cmd.options[:build_root] end def test_doc @@ -92,7 +92,7 @@ def test_document_rdoc end def test_security_policy - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @cmd.handle_options %w[-P HighSecurity] @@ -100,7 +100,7 @@ def test_security_policy end def test_security_policy_unknown - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @cmd.add_install_update_options @@ -111,7 +111,7 @@ def test_security_policy_unknown end def test_user_install_enabled - @spec = quick_gem 'a' do |spec| + @spec = quick_gem "a" do |spec| util_make_exec spec end @@ -124,12 +124,12 @@ def test_user_install_enabled @installer = Gem::Installer.at @gem, @cmd.options @installer.install - assert_path_exist File.join(Gem.user_dir, 'gems') - assert_path_exist File.join(Gem.user_dir, 'gems', @spec.full_name) + assert_path_exist File.join(Gem.user_dir, "gems") + assert_path_exist File.join(Gem.user_dir, "gems", @spec.full_name) end def test_user_install_disabled_read_only - @spec = quick_gem 'a' do |spec| + @spec = quick_gem "a" do |spec| util_make_exec spec end @@ -137,9 +137,9 @@ def test_user_install_disabled_read_only @gem = @spec.cache_file if win_platform? - pend('test_user_install_disabled_read_only test skipped on MS Windows') + pend("test_user_install_disabled_read_only test skipped on MS Windows") elsif Process.uid.zero? - pend('test_user_install_disabled_read_only test skipped in root privilege') + pend("test_user_install_disabled_read_only test skipped in root privilege") else @cmd.handle_options %w[--no-user-install] @@ -159,7 +159,7 @@ def test_user_install_disabled_read_only end def test_vendor - vendordir(File.join(@tempdir, 'vendor')) do + vendordir(File.join(@tempdir, "vendor")) do @cmd.handle_options %w[--vendor] assert @cmd.options[:vendor] @@ -173,7 +173,7 @@ def test_vendor_missing @cmd.handle_options %w[--vendor] end - assert_equal 'invalid option: --vendor your platform is not supported', + assert_equal "invalid option: --vendor your platform is not supported", e.message refute @cmd.options[:vendor] diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 46bb6965c724..46003175784c 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'installer_test_case' +require_relative "installer_test_case" class TestGemInstaller < Gem::InstallerTestCase def setup @@ -21,7 +21,7 @@ def test_app_script_text load_relative "no" do installer = setup_base_installer - util_make_exec @spec, '' + util_make_exec @spec, "" expected = <<-EOF #!#{Gem.ruby} @@ -55,7 +55,7 @@ def test_app_script_text end EOF - wrapper = installer.app_script_text 'executable' + wrapper = installer.app_script_text "executable" assert_equal expected, wrapper end end @@ -66,12 +66,12 @@ def test_check_executable_overwrite installer.generate_bin @spec = Gem::Specification.new do |s| - s.files = ['lib/code.rb'] + s.files = ["lib/code.rb"] s.name = "a" s.version = "3" s.summary = "summary" s.description = "desc" - s.require_path = 'lib' + s.require_path = "lib" end util_make_exec @@ -79,7 +79,7 @@ def test_check_executable_overwrite installer.wrappers = true installer.generate_bin - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec wrapper = File.read installed_exec @@ -98,7 +98,7 @@ def test_check_executable_overwrite_default_bin_dir installer.generate_bin end - conflicted = File.join @gemhome, 'bin', 'executable' + conflicted = File.join @gemhome, "bin", "executable" assert_match %r{\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z}, e.message end @@ -111,15 +111,15 @@ def test_check_executable_overwrite_format_executable installer.generate_bin @spec = Gem::Specification.new do |s| - s.files = ['lib/code.rb'] + s.files = ["lib/code.rb"] s.name = "a" s.version = "3" s.summary = "summary" s.description = "desc" - s.require_path = 'lib' + s.require_path = "lib" end - File.open File.join(util_inst_bindir, 'executable'), 'w' do |io| + File.open File.join(util_inst_bindir, "executable"), "w" do |io| io.write <<-EXEC #!/usr/local/bin/ruby # @@ -130,14 +130,14 @@ def test_check_executable_overwrite_format_executable end util_make_exec - Gem::Installer.exec_format = 'foo-%s-bar' + Gem::Installer.exec_format = "foo-%s-bar" installer.gem_dir = @spec.gem_dir installer.wrappers = true installer.format_executable = true installer.generate_bin # should not raise - installed_exec = File.join util_inst_bindir, 'foo-executable-bar' + installed_exec = File.join util_inst_bindir, "foo-executable-bar" assert_path_exist installed_exec wrapper = File.read installed_exec @@ -172,7 +172,7 @@ def test_check_executable_overwrite_other_gem_force installer.generate_bin - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec wrapper = File.read installed_exec @@ -187,7 +187,7 @@ def test_check_executable_overwrite_other_non_gem installer.generate_bin - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec wrapper = File.read installed_exec @@ -203,8 +203,8 @@ def test_check_that_user_bin_dir_is_in_path bin_dir = bin_dir.downcase end - orig_PATH, ENV['PATH'] = - ENV['PATH'], [ENV['PATH'], bin_dir].join(File::PATH_SEPARATOR) + orig_PATH, ENV["PATH"] = + ENV["PATH"], [ENV["PATH"], bin_dir].join(File::PATH_SEPARATOR) use_ui @ui do installer.check_that_user_bin_dir_is_in_path @@ -214,7 +214,7 @@ def test_check_that_user_bin_dir_is_in_path return unless win_platform? - ENV['PATH'] = [orig_PATH, bin_dir.tr(File::SEPARATOR, File::ALT_SEPARATOR)].join(File::PATH_SEPARATOR) + ENV["PATH"] = [orig_PATH, bin_dir.tr(File::SEPARATOR, File::ALT_SEPARATOR)].join(File::PATH_SEPARATOR) use_ui @ui do installer.check_that_user_bin_dir_is_in_path @@ -222,17 +222,17 @@ def test_check_that_user_bin_dir_is_in_path assert_empty @ui.error ensure - ENV['PATH'] = orig_PATH + ENV["PATH"] = orig_PATH end def test_check_that_user_bin_dir_is_in_path_tilde pend "Tilde is PATH is not supported under MS Windows" if win_platform? - orig_PATH, ENV['PATH'] = - ENV['PATH'], [ENV['PATH'], '~/bin'].join(File::PATH_SEPARATOR) + orig_PATH, ENV["PATH"] = + ENV["PATH"], [ENV["PATH"], "~/bin"].join(File::PATH_SEPARATOR) installer = setup_base_installer - installer.bin_dir.replace File.join @userhome, 'bin' + installer.bin_dir.replace File.join @userhome, "bin" use_ui @ui do installer.check_that_user_bin_dir_is_in_path @@ -240,7 +240,7 @@ def test_check_that_user_bin_dir_is_in_path_tilde assert_empty @ui.error ensure - ENV['PATH'] = orig_PATH unless win_platform? + ENV["PATH"] = orig_PATH unless win_platform? end def test_check_that_user_bin_dir_is_in_path_not_in_path @@ -262,22 +262,22 @@ def test_check_that_user_bin_dir_is_in_path_not_in_path def test_ensure_dependency installer = setup_base_installer - util_spec 'a' + util_spec "a" - dep = Gem::Dependency.new 'a', '>= 2' + dep = Gem::Dependency.new "a", ">= 2" assert installer.ensure_dependency(@spec, dep) - dep = Gem::Dependency.new 'b', '> 2' + dep = Gem::Dependency.new "b", "> 2" e = assert_raise Gem::InstallError do installer.ensure_dependency @spec, dep end - assert_equal 'a requires b (> 2)', e.message + assert_equal "a requires b (> 2)", e.message end def test_ensure_loadable_spec - a, a_gem = util_gem 'a', 2 do |s| - s.add_dependency 'garbage ~> 5' + a, a_gem = util_gem "a", 2 do |s| + s.add_dependency "garbage ~> 5" end installer = Gem::Installer.at a_gem @@ -291,10 +291,10 @@ def test_ensure_loadable_spec end def test_ensure_loadable_spec_security_policy - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL - _, a_gem = util_gem 'a', 2 do |s| - s.add_dependency 'garbage ~> 5' + _, a_gem = util_gem "a", 2 do |s| + s.add_dependency "garbage ~> 5" end policy = Gem::Security::HighSecurity @@ -310,7 +310,7 @@ def test_extract_files installer.extract_files - assert_path_exist File.join @spec.gem_dir, 'bin/executable' + assert_path_exist File.join @spec.gem_dir, "bin/executable" end def test_generate_bin_bindir @@ -319,12 +319,12 @@ def test_generate_bin_bindir installer.wrappers = true @spec.executables = %w[executable] - @spec.bindir = 'bin' + @spec.bindir = "bin" - exec_file = installer.formatted_program_filename 'executable' + exec_file = installer.formatted_program_filename "executable" exec_path = File.join @spec.gem_dir, exec_file - File.open exec_path, 'w' do |f| - f.puts '#!/usr/bin/ruby' + File.open exec_path, "w" do |f| + f.puts "#!/usr/bin/ruby" end installer.gem_dir = @spec.gem_dir @@ -332,7 +332,7 @@ def test_generate_bin_bindir installer.generate_bin assert_directory_exists util_inst_bindir - installed_exec = File.join(util_inst_bindir, 'executable') + installed_exec = File.join(util_inst_bindir, "executable") assert_path_exist installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? @@ -352,7 +352,7 @@ def test_generate_bin_bindir_with_user_install_warning :install_dir => "/non/existent", } - inst = Gem::Installer.at '', options + inst = Gem::Installer.at "", options Gem::Installer.path_warning = false @@ -375,7 +375,7 @@ def test_generate_bin_script installer.generate_bin assert_directory_exists util_inst_bindir - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? @@ -391,10 +391,10 @@ def test_generate_bin_script_format util_make_exec installer.gem_dir = @spec.gem_dir - Gem::Installer.exec_format = 'foo-%s-bar' + Gem::Installer.exec_format = "foo-%s-bar" installer.generate_bin assert_directory_exists util_inst_bindir - installed_exec = File.join util_inst_bindir, 'foo-executable-bar' + installed_exec = File.join util_inst_bindir, "foo-executable-bar" assert_path_exist installed_exec ensure Gem::Installer.exec_format = nil @@ -407,10 +407,10 @@ def test_generate_bin_script_format_disabled util_make_exec installer.gem_dir = @spec.gem_dir - Gem::Installer.exec_format = 'foo-%s-bar' + Gem::Installer.exec_format = "foo-%s-bar" installer.generate_bin assert_directory_exists util_inst_bindir - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec ensure Gem::Installer.exec_format = nil @@ -422,19 +422,19 @@ def test_generate_bin_script_install_dir installer.wrappers = true gem_dir = File.join("#{@gemhome}2", "gems", @spec.full_name) - gem_bindir = File.join gem_dir, 'bin' + gem_bindir = File.join gem_dir, "bin" FileUtils.mkdir_p gem_bindir - File.open File.join(gem_bindir, 'executable'), 'w' do |f| + File.open File.join(gem_bindir, "executable"), "w" do |f| f.puts "#!/bin/ruby" end installer.gem_home = "#{@gemhome}2" installer.gem_dir = gem_dir - installer.bin_dir = File.join "#{@gemhome}2", 'bin' + installer.bin_dir = File.join "#{@gemhome}2", "bin" installer.generate_bin - installed_exec = File.join("#{@gemhome}2", "bin", 'executable') + installed_exec = File.join("#{@gemhome}2", "bin", "executable") assert_path_exist installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? @@ -450,7 +450,7 @@ def test_generate_bin_script_no_execs installer.wrappers = true installer.generate_bin - assert_path_not_exist util_inst_bindir, 'bin dir was created when not needed' + assert_path_not_exist util_inst_bindir, "bin dir was created when not needed" end def test_generate_bin_script_no_perms @@ -462,9 +462,9 @@ def test_generate_bin_script_no_perms Dir.mkdir util_inst_bindir if win_platform? - pend('test_generate_bin_script_no_perms skipped on MS Windows') + pend("test_generate_bin_script_no_perms skipped on MS Windows") elsif Process.uid.zero? - pend('test_generate_bin_script_no_perms skipped in root privilege') + pend("test_generate_bin_script_no_perms skipped in root privilege") else FileUtils.chmod 0000, util_inst_bindir @@ -482,16 +482,16 @@ def test_generate_bin_script_no_shebang installer.wrappers = true @spec.executables = %w[executable] - gem_dir = File.join @gemhome, 'gems', @spec.full_name - gem_bindir = File.join gem_dir, 'bin' + gem_dir = File.join @gemhome, "gems", @spec.full_name + gem_bindir = File.join gem_dir, "bin" FileUtils.mkdir_p gem_bindir - File.open File.join(gem_bindir, 'executable'), 'w' do |f| + File.open File.join(gem_bindir, "executable"), "w" do |f| f.puts "blah blah blah" end installer.generate_bin - installed_exec = File.join @gemhome, 'bin', 'executable' + installed_exec = File.join @gemhome, "bin", "executable" assert_path_exist installed_exec assert_equal mask, File.stat(installed_exec).mode unless win_platform? @@ -507,9 +507,9 @@ def test_generate_bin_script_wrappers installer.wrappers = true util_make_exec installer.gem_dir = @spec.gem_dir - installed_exec = File.join(util_inst_bindir, 'executable') + installed_exec = File.join(util_inst_bindir, "executable") - real_exec = File.join @spec.gem_dir, 'bin', 'executable' + real_exec = File.join @spec.gem_dir, "bin", "executable" # fake --no-wrappers for previous install unless Gem.win_platform? @@ -525,7 +525,7 @@ def test_generate_bin_script_wrappers assert_match %r{generated by RubyGems}, File.read(installed_exec) refute_match %r{generated by RubyGems}, File.read(real_exec), - 'real executable overwritten' + "real executable overwritten" end def test_generate_bin_symlink @@ -539,9 +539,9 @@ def test_generate_bin_symlink installer.generate_bin assert_directory_exists util_inst_bindir - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_equal true, File.symlink?(installed_exec) - assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'), + assert_equal(File.join(@spec.gem_dir, "bin", "executable"), File.readlink(installed_exec)) end @@ -566,9 +566,9 @@ def test_generate_bin_symlink_no_perms Dir.mkdir util_inst_bindir if win_platform? - pend('test_generate_bin_symlink_no_perms skipped on MS Windows') + pend("test_generate_bin_symlink_no_perms skipped on MS Windows") elsif Process.uid.zero? - pend('test_user_install_disabled_read_only test skipped in root privilege') + pend("test_user_install_disabled_read_only test skipped in root privilege") else FileUtils.chmod 0000, util_inst_bindir @@ -590,24 +590,24 @@ def test_generate_bin_symlink_update_newer installer.gem_dir = @spec.gem_dir installer.generate_bin - installed_exec = File.join(util_inst_bindir, 'executable') - assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'), + installed_exec = File.join(util_inst_bindir, "executable") + assert_equal(File.join(@spec.gem_dir, "bin", "executable"), File.readlink(installed_exec)) @spec = Gem::Specification.new do |s| - s.files = ['lib/code.rb'] + s.files = ["lib/code.rb"] s.name = "a" s.version = "3" s.summary = "summary" s.description = "desc" - s.require_path = 'lib' + s.require_path = "lib" end util_make_exec installer.gem_dir = @spec.gem_dir installer.generate_bin - installed_exec = File.join(util_inst_bindir, 'executable') - assert_equal(@spec.bin_file('executable'), + installed_exec = File.join(util_inst_bindir, "executable") + assert_equal(@spec.bin_file("executable"), File.readlink(installed_exec), "Ensure symlink moved to latest version") end @@ -622,17 +622,17 @@ def test_generate_bin_symlink_update_older installer.gem_dir = @spec.gem_dir installer.generate_bin - installed_exec = File.join(util_inst_bindir, 'executable') - assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'), + installed_exec = File.join(util_inst_bindir, "executable") + assert_equal(File.join(@spec.gem_dir, "bin", "executable"), File.readlink(installed_exec)) spec = Gem::Specification.new do |s| - s.files = ['lib/code.rb'] + s.files = ["lib/code.rb"] s.name = "a" s.version = "1" s.summary = "summary" s.description = "desc" - s.require_path = 'lib' + s.require_path = "lib" end util_make_exec @@ -643,8 +643,8 @@ def test_generate_bin_symlink_update_older installer.generate_bin - installed_exec = File.join util_inst_bindir, 'executable' - expected = File.join @spec.gem_dir, 'bin', 'executable' + installed_exec = File.join util_inst_bindir, "executable" + expected = File.join @spec.gem_dir, "bin", "executable" assert_equal(expected, File.readlink(installed_exec), "Ensure symlink not moved") @@ -661,16 +661,16 @@ def test_generate_bin_symlink_update_remove_wrapper installer.generate_bin - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec @spec = Gem::Specification.new do |s| - s.files = ['lib/code.rb'] + s.files = ["lib/code.rb"] s.name = "a" s.version = "3" s.summary = "summary" s.description = "desc" - s.require_path = 'lib' + s.require_path = "lib" end util_make_exec @@ -680,8 +680,8 @@ def test_generate_bin_symlink_update_remove_wrapper installer.generate_bin - installed_exec = File.join util_inst_bindir, 'executable' - assert_equal(@spec.bin_file('executable'), + installed_exec = File.join util_inst_bindir, "executable" + assert_equal(@spec.bin_file("executable"), File.readlink(installed_exec), "Ensure symlink moved to latest version") end @@ -691,7 +691,7 @@ def test_generate_bin_symlink_win32 Gem.win_platform = true old_alt_separator = File::ALT_SEPARATOR File.__send__(:remove_const, :ALT_SEPARATOR) - File.const_set(:ALT_SEPARATOR, '\\') + File.const_set(:ALT_SEPARATOR, "\\") installer = setup_base_installer @@ -704,7 +704,7 @@ def test_generate_bin_symlink_win32 end assert_directory_exists util_inst_bindir - installed_exec = File.join(util_inst_bindir, 'executable') + installed_exec = File.join(util_inst_bindir, "executable") assert_path_exist installed_exec if symlink_supported? @@ -726,7 +726,7 @@ def test_generate_bin_symlink_win32 def test_generate_bin_uses_default_shebang pend "Symlinks not supported or not enabled" unless symlink_supported? - load_relative 'no' do + load_relative "no" do installer = setup_base_installer installer.wrappers = true @@ -762,7 +762,7 @@ def test_generate_bin_with_dangling_symlink def test_generate_plugins installer = util_setup_installer do |spec| - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -773,18 +773,18 @@ def test_generate_plugins installer.install end - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" FileUtils.rm plugin_path installer.generate_plugins - assert File.exist?(plugin_path), 'plugin not written' + assert File.exist?(plugin_path), "plugin not written" end def test_generate_plugins_with_install_dir - spec = quick_gem 'a' do |s| - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + spec = quick_gem "a" do |s| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -793,17 +793,17 @@ def test_generate_plugins_with_install_dir util_build_gem spec - plugin_path = File.join "#{@gemhome}2", 'plugins', 'a_plugin.rb' + plugin_path = File.join "#{@gemhome}2", "plugins", "a_plugin.rb" installer = util_installer spec, "#{@gemhome}2" assert_equal spec, installer.install - assert File.exist?(plugin_path), 'plugin not written to install_dir' + assert File.exist?(plugin_path), "plugin not written to install_dir" end def test_generate_plugins_with_user_install - spec = quick_gem 'a' do |s| - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + spec = quick_gem "a" do |s| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -813,19 +813,19 @@ def test_generate_plugins_with_user_install util_build_gem spec File.chmod(0555, Gem.plugindir) - system_path = File.join(Gem.plugindir, 'a_plugin.rb') - user_path = File.join(Gem.plugindir(Gem.user_dir), 'a_plugin.rb') + system_path = File.join(Gem.plugindir, "a_plugin.rb") + user_path = File.join(Gem.plugindir(Gem.user_dir), "a_plugin.rb") installer = util_installer spec, Gem.dir, :user assert_equal spec, installer.install - assert !File.exist?(system_path), 'plugin incorrectly written to system plugins_dir' - assert File.exist?(user_path), 'plugin not written to user plugins_dir' + assert !File.exist?(system_path), "plugin incorrectly written to system plugins_dir" + assert File.exist?(user_path), "plugin not written to user plugins_dir" end def test_generate_plugins_with_build_root - spec = quick_gem 'a' do |s| - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + spec = quick_gem "a" do |s| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -835,17 +835,17 @@ def test_generate_plugins_with_build_root util_build_gem spec File.chmod(0555, Gem.plugindir) - system_path = File.join(Gem.plugindir, 'a_plugin.rb') + system_path = File.join(Gem.plugindir, "a_plugin.rb") - build_root = File.join(@tempdir, 'build_root') - build_root_path = File.join(build_root, Gem.plugindir.gsub(/^[a-zA-Z]:/, ''), 'a_plugin.rb') + build_root = File.join(@tempdir, "build_root") + build_root_path = File.join(build_root, Gem.plugindir.gsub(/^[a-zA-Z]:/, ""), "a_plugin.rb") installer = Gem::Installer.at spec.cache_file, :build_root => build_root assert_equal spec, installer.install - assert !File.exist?(system_path), 'plugin written incorrect written to system plugins_dir' - assert File.exist?(build_root_path), 'plugin not written to build_root' + assert !File.exist?(system_path), "plugin written incorrect written to system plugins_dir" + assert File.exist?(build_root_path), "plugin not written to build_root" refute_includes File.read(build_root_path), build_root end @@ -853,49 +853,49 @@ def test_generate_plugins_with_build_root def test_keeps_plugins_up_to_date # NOTE: version a-2 is already installed by setup hooks - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end build_rake_in do util_setup_installer do |spec| - spec.version = '1' + spec.version = "1" spec.files += %w[lib/rubygems_plugin.rb] end.install - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' - refute File.exist?(plugin_path), 'old version installed while newer version without plugin also installed, but plugin written' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" + refute File.exist?(plugin_path), "old version installed while newer version without plugin also installed, but plugin written" util_setup_installer do |spec| - spec.version = '2' + spec.version = "2" spec.files += %w[lib/rubygems_plugin.rb] end.install - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' - assert File.exist?(plugin_path), 'latest version reinstalled, but plugin not written' - assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'written plugin has incorrect content' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" + assert File.exist?(plugin_path), "latest version reinstalled, but plugin not written" + assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content" util_setup_installer do |spec| - spec.version = '3' + spec.version = "3" spec.files += %w[lib/rubygems_plugin.rb] end.install - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' - assert File.exist?(plugin_path), 'latest version installed, but plugin removed' - assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'written plugin has incorrect content' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" + assert File.exist?(plugin_path), "latest version installed, but plugin removed" + assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content" util_setup_installer do |spec| - spec.version = '4' + spec.version = "4" end.install - refute File.exist?(plugin_path), 'new version installed without a plugin while older version with a plugin installed, but plugin not removed' + refute File.exist?(plugin_path), "new version installed without a plugin while older version with a plugin installed, but plugin not removed" end end def test_generates_plugins_dir_under_install_dir_if_not_there Gem.use_paths "#{@gemhome}2" # Set GEM_HOME to an uninitialized repo - @spec = util_spec 'a' + @spec = util_spec "a" path = Gem::Package.build @spec @@ -904,8 +904,8 @@ def test_generates_plugins_dir_under_install_dir_if_not_there end def test_initialize - spec = util_spec 'a' do |s| - s.platform = Gem::Platform.new 'mswin32' + spec = util_spec "a" do |s| + s.platform = Gem::Platform.new "mswin32" end gem = File.join @tempdir, spec.file_name @@ -916,8 +916,8 @@ def test_initialize installer = Gem::Installer.at gem - assert_equal File.join(@gemhome, 'gems', spec.full_name), installer.gem_dir - assert_equal File.join(@gemhome, 'bin'), installer.bin_dir + assert_equal File.join(@gemhome, "gems", spec.full_name), installer.gem_dir + assert_equal File.join(@gemhome, "bin"), installer.bin_dir end def test_initialize_user_install @@ -925,7 +925,7 @@ def test_initialize_user_install installer = Gem::Installer.at @gem, :user_install => true - assert_equal File.join(Gem.user_dir, 'gems', @spec.full_name), + assert_equal File.join(Gem.user_dir, "gems", @spec.full_name), installer.gem_dir assert_equal Gem.bindir(Gem.user_dir), installer.bin_dir end @@ -936,7 +936,7 @@ def test_initialize_user_install_bin_dir installer = Gem::Installer.at @gem, :user_install => true, :bin_dir => @tempdir - assert_equal File.join(Gem.user_dir, 'gems', @spec.full_name), + assert_equal File.join(Gem.user_dir, "gems", @spec.full_name), installer.gem_dir assert_equal @tempdir, installer.bin_dir end @@ -944,26 +944,26 @@ def test_initialize_user_install_bin_dir def test_install installer = util_setup_installer - gemdir = File.join @gemhome, 'gems', @spec.full_name - cache_file = File.join @gemhome, 'cache', @spec.file_name - stub_exe = File.join @gemhome, 'bin', 'executable' - rakefile = File.join gemdir, 'ext', 'a', 'Rakefile' - spec_file = File.join @gemhome, 'specifications', @spec.spec_name + gemdir = File.join @gemhome, "gems", @spec.full_name + cache_file = File.join @gemhome, "cache", @spec.file_name + stub_exe = File.join @gemhome, "bin", "executable" + rakefile = File.join gemdir, "ext", "a", "Rakefile" + spec_file = File.join @gemhome, "specifications", @spec.spec_name Gem.pre_install do - assert_path_not_exist cache_file, 'cache file must not exist yet' + assert_path_not_exist cache_file, "cache file must not exist yet" true end Gem.post_build do - assert_path_exist gemdir, 'gem install dir must exist' - assert_path_exist rakefile, 'gem executable must exist' - assert_path_not_exist stub_exe, 'gem executable must not exist' + assert_path_exist gemdir, "gem install dir must exist" + assert_path_exist rakefile, "gem executable must exist" + assert_path_not_exist stub_exe, "gem executable must not exist" true end Gem.post_install do - assert_path_exist cache_file, 'cache file must exist' + assert_path_exist cache_file, "cache file must exist" end @newspec = nil @@ -975,15 +975,15 @@ def test_install assert_equal @spec, @newspec assert_path_exist gemdir - assert_path_exist stub_exe, 'gem executable must exist' + assert_path_exist stub_exe, "gem executable must exist" - exe = File.join gemdir, 'bin', 'executable' + exe = File.join gemdir, "bin", "executable" assert_path_exist exe exe_mode = File.stat(exe).mode & 0111 assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform? - assert_path_exist File.join gemdir, 'lib', 'code.rb' + assert_path_exist File.join gemdir, "lib", "code.rb" assert_path_exist rakefile @@ -1000,7 +1000,7 @@ def test_install_creates_working_binstub installer.wrappers = true - gemdir = File.join @gemhome, 'gems', @spec.full_name + gemdir = File.join @gemhome, "gems", @spec.full_name @newspec = nil build_rake_in do @@ -1009,7 +1009,7 @@ def test_install_creates_working_binstub end end - exe = File.join gemdir, 'bin', 'executable' + exe = File.join gemdir, "bin", "executable" e = assert_raise RuntimeError do instance_eval File.read(exe) @@ -1023,10 +1023,10 @@ def test_conflicting_binstubs # build old version that has a bin file installer = util_setup_gem do |spec| - File.open File.join('bin', 'executable'), 'w' do |f| + File.open File.join("bin", "executable"), "w" do |f| f.puts "require 'code'" end - File.open File.join('lib', 'code.rb'), 'w' do |f| + File.open File.join("lib", "code.rb"), "w" do |f| f.puts 'raise "I have an executable"' end end @@ -1038,15 +1038,15 @@ def test_conflicting_binstubs end end - old_bin_file = File.join installer.bin_dir, 'executable' + old_bin_file = File.join installer.bin_dir, "executable" # build new version that doesn't have a bin file installer = util_setup_gem do |spec| - FileUtils.rm File.join('bin', 'executable') - spec.files.delete File.join('bin', 'executable') - spec.executables.delete 'executable' + FileUtils.rm File.join("bin", "executable") + spec.files.delete File.join("bin", "executable") + spec.executables.delete "executable" spec.version = @spec.version.bump - File.open File.join('lib', 'code.rb'), 'w' do |f| + File.open File.join("lib", "code.rb"), "w" do |f| f.puts 'raise "I do not have an executable"' end end @@ -1063,7 +1063,7 @@ def test_conflicting_binstubs # We expect the bin stub to activate the version that actually contains # the binstub. - assert_match('I have an executable', e.message) + assert_match("I have an executable", e.message) end def test_install_creates_binstub_that_understand_version @@ -1078,7 +1078,7 @@ def test_install_creates_binstub_that_understand_version end end - exe = File.join @gemhome, 'bin', 'executable' + exe = File.join @gemhome, "bin", "executable" ARGV.unshift "_3.0_" @@ -1096,17 +1096,17 @@ def test_install_creates_binstub_that_understand_version end def test_install_creates_binstub_that_prefers_user_installed_gem_to_default - default_spec = new_default_spec('default', '2', nil, 'exe/executable') - default_spec.executables = 'executable' + default_spec = new_default_spec("default", "2", nil, "exe/executable") + default_spec.executables = "executable" install_default_gems default_spec - exe = File.join @gemhome, 'bin', 'executable' + exe = File.join @gemhome, "bin", "executable" assert_path_exist exe, "default gem's executable not installed" installer = util_setup_installer do |spec| - spec.name = 'default' - spec.version = '2' + spec.name = "default" + spec.version = "2" end util_clear_gems @@ -1139,7 +1139,7 @@ def test_install_creates_binstub_that_dont_trust_encoding end end - exe = File.join @gemhome, 'bin', 'executable' + exe = File.join @gemhome, "bin", "executable" extra_arg = "\xE4pfel".dup.force_encoding("UTF-8") ARGV.unshift extra_arg @@ -1166,16 +1166,16 @@ def test_install_with_no_prior_files end end - gemdir = File.join(@gemhome, 'gems', @spec.full_name) - assert_path_exist File.join gemdir, 'lib', 'code.rb' + gemdir = File.join(@gemhome, "gems", @spec.full_name) + assert_path_exist File.join gemdir, "lib", "code.rb" installer = util_setup_installer # Morph spec to have lib/other.rb instead of code.rb and recreate - @spec.files = File.join('lib', 'other.rb') + @spec.files = File.join("lib", "other.rb") Dir.chdir @tempdir do - File.open File.join('lib', 'other.rb'), 'w' do |f| - f.puts '1' + File.open File.join("lib", "other.rb"), "w" do |f| + f.puts "1" end use_ui ui do @@ -1190,14 +1190,14 @@ def test_install_with_no_prior_files end end - assert_path_exist File.join gemdir, 'lib', 'other.rb' - assert_path_not_exist File.join gemdir, 'lib', 'code.rb', + assert_path_exist File.join gemdir, "lib", "other.rb" + assert_path_not_exist File.join gemdir, "lib", "code.rb", "code.rb from prior install of same gem shouldn't remain here" end def test_install_force - _, missing_dep_gem = util_gem 'missing_dep', '1' do |s| - s.add_dependency 'doesnt_exist', '1' + _, missing_dep_gem = util_gem "missing_dep", "1" do |s| + s.add_dependency "doesnt_exist", "1" end use_ui @ui do @@ -1205,12 +1205,12 @@ def test_install_force installer.install end - gem_dir = File.join(@gemhome, 'gems', 'missing_dep-1') + gem_dir = File.join(@gemhome, "gems", "missing_dep-1") assert_path_exist gem_dir end def test_install_build_root - build_root = File.join(@tempdir, 'build_root') + build_root = File.join(@tempdir, "build_root") @gem = setup_base_gem installer = Gem::Installer.at @gem, :build_root => build_root @@ -1221,22 +1221,22 @@ def test_install_build_root def test_install_missing_dirs installer = setup_base_installer - FileUtils.rm_rf File.join(Gem.dir, 'doc') - FileUtils.rm_rf File.join(Gem.dir, 'specifications') + FileUtils.rm_rf File.join(Gem.dir, "doc") + FileUtils.rm_rf File.join(Gem.dir, "specifications") use_ui @ui do installer.install end - assert_directory_exists File.join(Gem.dir, 'doc') - assert_directory_exists File.join(Gem.dir, 'specifications') + assert_directory_exists File.join(Gem.dir, "doc") + assert_directory_exists File.join(Gem.dir, "specifications") - assert_path_exist File.join @gemhome, 'cache', @spec.file_name - assert_path_exist File.join @gemhome, 'specifications', @spec.spec_name + assert_path_exist File.join @gemhome, "cache", @spec.file_name + assert_path_exist File.join @gemhome, "specifications", @spec.spec_name end def test_install_post_build_false - @spec = util_spec 'a' + @spec = util_spec "a" util_build_gem @spec @@ -1256,10 +1256,10 @@ def test_install_post_build_false assert_equal "post-build hook at #{location} failed for a-2", e.message end - spec_file = File.join @gemhome, 'specifications', @spec.spec_name + spec_file = File.join @gemhome, "specifications", @spec.spec_name assert_path_not_exist spec_file - gem_dir = File.join @gemhome, 'gems', @spec.full_name + gem_dir = File.join @gemhome, "gems", @spec.full_name assert_path_not_exist gem_dir end @@ -1274,15 +1274,15 @@ def test_install_post_build_nil installer.install end - spec_file = File.join @gemhome, 'specifications', @spec.spec_name + spec_file = File.join @gemhome, "specifications", @spec.spec_name assert_path_exist spec_file - gem_dir = File.join @gemhome, 'gems', @spec.full_name + gem_dir = File.join @gemhome, "gems", @spec.full_name assert_path_exist gem_dir end def test_install_pre_install_false - @spec = util_spec 'a' + @spec = util_spec "a" util_build_gem @spec @@ -1302,7 +1302,7 @@ def test_install_pre_install_false assert_equal "pre-install hook at #{location} failed for a-2", e.message end - spec_file = File.join @gemhome, 'specifications', @spec.spec_name + spec_file = File.join @gemhome, "specifications", @spec.spec_name assert_path_not_exist spec_file end @@ -1317,13 +1317,13 @@ def test_install_pre_install_nil installer.install end - spec_file = File.join @gemhome, 'specifications', @spec.spec_name + spec_file = File.join @gemhome, "specifications", @spec.spec_name assert_path_exist spec_file end def test_install_with_message @spec = setup_base_spec - @spec.post_install_message = 'I am a shiny gem!' + @spec.post_install_message = "I am a shiny gem!" use_ui @ui do path = Gem::Package.build @spec @@ -1337,7 +1337,7 @@ def test_install_with_message def test_install_with_skipped_message @spec = setup_base_spec - @spec.post_install_message = 'I am a shiny gem!' + @spec.post_install_message = "I am a shiny gem!" use_ui @ui do path = Gem::Package.build @spec @@ -1370,7 +1370,7 @@ def test_install_extension_dir installer.install end - expected_makefile = File.join gemhome2, 'gems', @spec.full_name, 'Makefile' + expected_makefile = File.join gemhome2, "gems", @spec.full_name, "Makefile" assert_path_exist expected_makefile end @@ -1435,11 +1435,11 @@ def test_install_user_extension_dir installer.install end - expected_makefile = File.join Gem.user_dir, 'gems', @spec.full_name, 'Makefile' + expected_makefile = File.join Gem.user_dir, "gems", @spec.full_name, "Makefile" assert_path_exist expected_makefile assert_path_exist expected_extension_dir - assert_path_not_exist File.join expected_extension_dir, 'gem_make.out' + assert_path_not_exist File.join expected_extension_dir, "gem_make.out" end def test_find_lib_file_after_install @@ -1469,7 +1469,7 @@ def test_find_lib_file_after_install end Dir.mkdir File.join(@tempdir, "lib") - write_file File.join(@tempdir, 'lib', "b.rb") do |io| + write_file File.join(@tempdir, "lib", "b.rb") do |io| io.write "# b.rb" end @@ -1483,14 +1483,14 @@ def test_find_lib_file_after_install end expected = File.join @spec.full_require_paths.find {|path| - File.exist? File.join path, 'b.rb' - }, 'b.rb' - assert_equal expected, @spec.matches_for_glob('b.rb').first + File.exist? File.join path, "b.rb" + }, "b.rb" + assert_equal expected, @spec.matches_for_glob("b.rb").first end def test_install_extension_and_script pend "Makefile creation crashes on jruby" if Gem.java_platform? - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning @spec = setup_base_spec @spec.extensions << "extconf.rb" @@ -1566,15 +1566,15 @@ def test_install_extension_flat end assert_path_exist so rescue - puts '-' * 78 - puts File.read File.join(@gemhome, 'gems', 'a-2', 'Makefile') - puts '-' * 78 + puts "-" * 78 + puts File.read File.join(@gemhome, "gems", "a-2", "Makefile") + puts "-" * 78 - path = File.join(@gemhome, 'gems', 'a-2', 'gem_make.out') + path = File.join(@gemhome, "gems", "a-2", "gem_make.out") if File.exist?(path) puts File.read(path) - puts '-' * 78 + puts "-" * 78 end raise @@ -1584,12 +1584,12 @@ def test_install_extension_flat def test_installation_satisfies_dependency_eh installer = setup_base_installer - util_spec 'a' + util_spec "a" - dep = Gem::Dependency.new 'a', '>= 2' + dep = Gem::Dependency.new "a", ">= 2" assert installer.installation_satisfies_dependency?(dep) - dep = Gem::Dependency.new 'a', '> 2' + dep = Gem::Dependency.new "a", "> 2" refute installer.installation_satisfies_dependency?(dep) end @@ -1598,15 +1598,15 @@ def test_installation_satisfies_dependency_eh_development installer.options[:development] = true installer.options[:dev_shallow] = true - util_spec 'a' + util_spec "a" - dep = Gem::Dependency.new 'a', :development + dep = Gem::Dependency.new "a", :development assert installer.installation_satisfies_dependency?(dep) end def test_pre_install_checks_dependencies installer = setup_base_installer - @spec.add_dependency 'b', '> 5' + @spec.add_dependency "b", "> 5" installer = util_setup_gem installer.force = false @@ -1619,7 +1619,7 @@ def test_pre_install_checks_dependencies def test_pre_install_checks_dependencies_ignore installer = util_setup_installer - @spec.add_dependency 'b', '> 5' + @spec.add_dependency "b", "> 5" installer.ignore_dependencies = true build_rake_in do @@ -1633,16 +1633,16 @@ def test_pre_install_checks_dependencies_install_dir gemhome2 = "#{@gemhome}2" @gem = setup_base_gem - @spec.add_dependency 'd' + @spec.add_dependency "d" - quick_gem 'd', 2 + quick_gem "d", 2 gem = File.join @gemhome, @spec.file_name FileUtils.mv @gemhome, gemhome2 FileUtils.mkdir @gemhome - FileUtils.mv File.join(gemhome2, 'cache', @spec.file_name), gem + FileUtils.mv File.join(gemhome2, "cache", @spec.file_name), gem # Don't leak any already activated gems into the installer, require # that it work everything out on it's own. @@ -1658,7 +1658,7 @@ def test_pre_install_checks_dependencies_install_dir end def test_pre_install_checks_malicious_name - spec = util_spec '../malicious', '1' + spec = util_spec "../malicious", "1" def spec.full_name # so the spec is buildable "malicious-1" end @@ -1666,19 +1666,19 @@ def spec.validate(packaging, strict); end util_build_gem spec - gem = File.join(@gemhome, 'cache', spec.file_name) + gem = File.join(@gemhome, "cache", spec.file_name) use_ui @ui do installer = Gem::Installer.at gem e = assert_raise Gem::InstallError do installer.pre_install_checks end - assert_equal '# has an invalid name', e.message + assert_equal "# has an invalid name", e.message end end def test_pre_install_checks_malicious_name_before_eval - spec = util_spec "malicious\n::Object.const_set(:FROM_EVAL, true)#", '1' + spec = util_spec "malicious\n::Object.const_set(:FROM_EVAL, true)#", "1" def spec.full_name # so the spec is buildable "malicious-1" end @@ -1686,7 +1686,7 @@ def spec.validate(*args); end util_build_gem spec - gem = File.join(@gemhome, 'cache', spec.file_name) + gem = File.join(@gemhome, "cache", spec.file_name) use_ui @ui do installer = Gem::Installer.at gem @@ -1699,7 +1699,7 @@ def spec.validate(*args); end end def test_pre_install_checks_malicious_require_paths_before_eval - spec = util_spec "malicious", '1' + spec = util_spec "malicious", "1" def spec.full_name # so the spec is buildable "malicious-1" end @@ -1708,7 +1708,7 @@ def spec.validate(*args); end util_build_gem spec - gem = File.join(@gemhome, 'cache', spec.file_name) + gem = File.join(@gemhome, "cache", spec.file_name) use_ui @ui do installer = Gem::Installer.at gem @@ -1722,7 +1722,7 @@ def spec.validate(*args); end def test_pre_install_checks_malicious_extensions_before_eval pend "mswin environment disallow to create file contained the carriage return code." if Gem.win_platform? - spec = util_spec "malicious", '1' + spec = util_spec "malicious", "1" def spec.full_name # so the spec is buildable "malicious-1" end @@ -1731,7 +1731,7 @@ def spec.validate(*args); end util_build_gem spec - gem = File.join(@gemhome, 'cache', spec.file_name) + gem = File.join(@gemhome, "cache", spec.file_name) use_ui @ui do installer = Gem::Installer.at gem @@ -1743,7 +1743,7 @@ def spec.validate(*args); end end def test_pre_install_checks_malicious_specification_version_before_eval - spec = util_spec "malicious", '1' + spec = util_spec "malicious", "1" def spec.full_name # so the spec is buildable "malicious-1" end @@ -1752,7 +1752,7 @@ def spec.validate(*args); end util_build_gem spec - gem = File.join(@gemhome, 'cache', spec.file_name) + gem = File.join(@gemhome, "cache", spec.file_name) use_ui @ui do installer = Gem::Installer.at gem @@ -1764,16 +1764,16 @@ def spec.validate(*args); end end def test_pre_install_checks_malicious_dependencies_before_eval - spec = util_spec "malicious", '1' + spec = util_spec "malicious", "1" def spec.full_name # so the spec is buildable "malicious-1" end def spec.validate(*args); end - spec.add_dependency "b\nfoo", '> 5' + spec.add_dependency "b\nfoo", "> 5" util_build_gem spec - gem = File.join(@gemhome, 'cache', spec.file_name) + gem = File.join(@gemhome, "cache", spec.file_name) use_ui @ui do installer = Gem::Installer.at gem @@ -1811,7 +1811,7 @@ def test_shebang util_make_exec @spec, "#!/usr/bin/ruby" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby}", shebang end @@ -1821,15 +1821,15 @@ def test_process_options installer = setup_base_installer assert_nil installer.build_root - assert_equal File.join(@gemhome, 'bin'), installer.bin_dir + assert_equal File.join(@gemhome, "bin"), installer.bin_dir assert_equal @gemhome, installer.gem_home end def test_process_options_build_root - build_root = File.join @tempdir, 'build_root' - bin_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'bin') - gem_home = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, '')) - plugins_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'plugins') + build_root = File.join @tempdir, "build_root" + bin_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""), "bin") + gem_home = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, "")) + plugins_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""), "plugins") @gem = setup_base_gem installer = use_ui(@ui) { Gem::Installer.at @gem, :build_root => build_root } @@ -1848,24 +1848,24 @@ def test_process_options_build_root end def test_shebang_arguments - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby} -ws", shebang end end def test_shebang_arguments_with_load_relative - load_relative 'yes' do + load_relative "yes" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" shebang_lines = shebang.split "\n" @@ -1875,47 +1875,47 @@ def test_shebang_arguments_with_load_relative end def test_shebang_empty - load_relative 'no' do + load_relative "no" do installer = setup_base_installer - util_make_exec @spec, '' + util_make_exec @spec, "" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby}", shebang end end def test_shebang_env - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/env ruby" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby}", shebang end end def test_shebang_env_arguments - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/env ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby} -ws", shebang end end def test_shebang_env_arguments_with_load_relative - load_relative 'yes' do + load_relative "yes" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/env ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" shebang_lines = shebang.split "\n" @@ -1927,10 +1927,10 @@ def test_shebang_env_arguments_with_load_relative def test_shebang_env_shebang installer = setup_base_installer - util_make_exec @spec, '' + util_make_exec @spec, "" installer.env_shebang = true - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" bin_env = get_bin_env @@ -1939,36 +1939,36 @@ def test_shebang_env_shebang end def test_shebang_nested - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/opt/local/ruby/bin/ruby" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby}", shebang end end def test_shebang_nested_arguments - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby} -ws", shebang end end def test_shebang_nested_arguments_with_load_relative - load_relative 'yes' do + load_relative "yes" do installer = setup_base_installer util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" shebang_lines = shebang.split "\n" @@ -1978,36 +1978,36 @@ def test_shebang_nested_arguments_with_load_relative end def test_shebang_version - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/ruby18" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby}", shebang end end def test_shebang_version_arguments - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/ruby18 -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby} -ws", shebang end end def test_shebang_version_arguments_with_load_relative - load_relative 'yes' do + load_relative "yes" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/ruby18 -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" shebang_lines = shebang.split "\n" @@ -2017,36 +2017,36 @@ def test_shebang_version_arguments_with_load_relative end def test_shebang_version_env - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/env ruby18" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby}", shebang end end def test_shebang_version_env_arguments - load_relative 'no' do + load_relative "no" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/env ruby18 -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!#{Gem.ruby} -ws", shebang end end def test_shebang_version_env_arguments_with_load_relative - load_relative 'yes' do + load_relative "yes" do installer = setup_base_installer util_make_exec @spec, "#!/usr/bin/env ruby18 -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" shebang_lines = shebang.split "\n" @@ -2059,13 +2059,13 @@ def test_shebang_custom installer = setup_base_installer conf = Gem::ConfigFile.new [] - conf[:custom_shebang] = 'test' + conf[:custom_shebang] = "test" Gem.configuration = conf util_make_exec @spec, "#!/usr/bin/ruby" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!test", shebang end @@ -2083,13 +2083,13 @@ def test_shebang_custom_with_expands bin_env = get_bin_env conf = Gem::ConfigFile.new [] - conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name' + conf[:custom_shebang] = "1 $env 2 $ruby 3 $exec 4 $name" Gem.configuration = conf util_make_exec @spec, "#!/usr/bin/ruby" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} 3 executable 4 a", shebang end @@ -2099,13 +2099,13 @@ def test_shebang_custom_with_expands_and_arguments bin_env = get_bin_env conf = Gem::ConfigFile.new [] - conf[:custom_shebang] = '1 $env 2 $ruby 3 $exec' + conf[:custom_shebang] = "1 $env 2 $ruby 3 $exec" Gem.configuration = conf util_make_exec @spec, "#!/usr/bin/ruby -ws" - shebang = installer.shebang 'executable' + shebang = installer.shebang "executable" assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} -ws 3 executable", shebang end @@ -2113,14 +2113,14 @@ def test_shebang_custom_with_expands_and_arguments def test_unpack installer = util_setup_installer - dest = File.join @gemhome, 'gems', @spec.full_name + dest = File.join @gemhome, "gems", @spec.full_name Gem::Deprecate.skip_during do installer.unpack dest end - assert_path_exist File.join dest, 'lib', 'code.rb' - assert_path_exist File.join dest, 'bin', 'executable' + assert_path_exist File.join dest, "lib", "code.rb" + assert_path_exist File.join dest, "bin", "executable" end def test_write_build_info_file @@ -2163,12 +2163,12 @@ def test_write_build_info_file_install_dir assert_path_not_exist @spec.build_info_file assert_path_exist \ - File.join("#{@gemhome}2", 'build_info', "#{@spec.full_name}.info") + File.join("#{@gemhome}2", "build_info", "#{@spec.full_name}.info") end def test_write_cache_file @gem = setup_base_gem - cache_file = File.join @gemhome, 'cache', @spec.file_name + cache_file = File.join @gemhome, "cache", @spec.file_name gem = File.join @gemhome, @spec.file_name FileUtils.mv cache_file, gem @@ -2226,7 +2226,7 @@ def test_dir end def test_default_gem_loaded_from - spec = util_spec 'a' + spec = util_spec "a" installer = Gem::Installer.for_spec spec, :install_as_default => true installer.install assert_predicate spec, :default_gem? @@ -2235,7 +2235,7 @@ def test_default_gem_loaded_from def test_default_gem_without_wrappers installer = setup_base_installer - FileUtils.rm_rf File.join(Gem.default_dir, 'specifications') + FileUtils.rm_rf File.join(Gem.default_dir, "specifications") installer.wrappers = false installer.options[:install_as_default] = true @@ -2245,20 +2245,20 @@ def test_default_gem_without_wrappers installer.install end - assert_directory_exists File.join(@spec.gem_dir, 'bin') - installed_exec = File.join @spec.gem_dir, 'bin', 'executable' + assert_directory_exists File.join(@spec.gem_dir, "bin") + installed_exec = File.join @spec.gem_dir, "bin", "executable" assert_path_exist installed_exec - assert_directory_exists File.join(Gem.default_dir, 'specifications') - assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default') + assert_directory_exists File.join(Gem.default_dir, "specifications") + assert_directory_exists File.join(Gem.default_dir, "specifications", "default") - default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'a-2.gemspec') + default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "a-2.gemspec") assert_equal Gem::Version.new("2"), default_spec.version - assert_equal ['bin/executable'], default_spec.files + assert_equal ["bin/executable"], default_spec.files assert_directory_exists util_inst_bindir - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec wrapper = File.read installed_exec @@ -2284,7 +2284,7 @@ def test_default_gem_with_wrappers assert_directory_exists util_inst_bindir - installed_exec = File.join util_inst_bindir, 'executable' + installed_exec = File.join util_inst_bindir, "executable" assert_path_exist installed_exec wrapper = File.read installed_exec @@ -2292,8 +2292,8 @@ def test_default_gem_with_wrappers end def test_default_gem_with_exe_as_bindir - @spec = quick_gem 'c' do |spec| - util_make_exec spec, '#!/usr/bin/ruby', 'exe' + @spec = quick_gem "c" do |spec| + util_make_exec spec, "#!/usr/bin/ruby", "exe" end util_build_gem @spec @@ -2309,16 +2309,16 @@ def test_default_gem_with_exe_as_bindir installer.install end - assert_directory_exists File.join(@spec.gem_dir, 'exe') - installed_exec = File.join @spec.gem_dir, 'exe', 'executable' + assert_directory_exists File.join(@spec.gem_dir, "exe") + installed_exec = File.join @spec.gem_dir, "exe", "executable" assert_path_exist installed_exec - assert_directory_exists File.join(Gem.default_dir, 'specifications') - assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default') + assert_directory_exists File.join(Gem.default_dir, "specifications") + assert_directory_exists File.join(Gem.default_dir, "specifications", "default") - default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'c-2.gemspec') + default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "c-2.gemspec") assert_equal Gem::Version.new("2"), default_spec.version - assert_equal ['exe/executable'], default_spec.files + assert_equal ["exe/executable"], default_spec.files end def test_default_gem_to_specific_install_dir @@ -2330,17 +2330,17 @@ def test_default_gem_to_specific_install_dir installer.install end - assert_directory_exists File.join("#{@gemhome}2", 'specifications') - assert_directory_exists File.join("#{@gemhome}2", 'specifications', 'default') + assert_directory_exists File.join("#{@gemhome}2", "specifications") + assert_directory_exists File.join("#{@gemhome}2", "specifications", "default") - default_spec = eval File.read File.join("#{@gemhome}2", 'specifications', 'default', 'a-2.gemspec') + default_spec = eval File.read File.join("#{@gemhome}2", "specifications", "default", "a-2.gemspec") assert_equal Gem::Version.new("2"), default_spec.version - assert_equal ['bin/executable'], default_spec.files + assert_equal ["bin/executable"], default_spec.files end def test_package_attribute - gem = quick_gem 'c' do |spec| - util_make_exec spec, '#!/usr/bin/ruby', 'exe' + gem = quick_gem "c" do |spec| + util_make_exec spec, "#!/usr/bin/ruby", "exe" end installer = util_installer(gem, @gemhome) @@ -2349,8 +2349,8 @@ def test_package_attribute end def test_gem_attribute - gem = quick_gem 'c' do |spec| - util_make_exec spec, '#!/usr/bin/ruby', 'exe' + gem = quick_gem "c" do |spec| + util_make_exec spec, "#!/usr/bin/ruby", "exe" end installer = util_installer(gem, @gemhome) @@ -2361,14 +2361,14 @@ def test_gem_attribute private def util_execless - @spec = util_spec 'z' + @spec = util_spec "z" util_build_gem @spec util_installer @spec, @gemhome end def util_conflict_executable(wrappers) - conflict = quick_gem 'conflict' do |spec| + conflict = quick_gem "conflict" do |spec| util_make_exec spec end @@ -2384,11 +2384,11 @@ def mask end def load_relative(value) - orig_LIBRUBY_RELATIVE = RbConfig::CONFIG['LIBRUBY_RELATIVE'] - RbConfig::CONFIG['LIBRUBY_RELATIVE'] = value + orig_LIBRUBY_RELATIVE = RbConfig::CONFIG["LIBRUBY_RELATIVE"] + RbConfig::CONFIG["LIBRUBY_RELATIVE"] = value yield ensure - RbConfig::CONFIG['LIBRUBY_RELATIVE'] = orig_LIBRUBY_RELATIVE + RbConfig::CONFIG["LIBRUBY_RELATIVE"] = orig_LIBRUBY_RELATIVE end end diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb index 948d1e3981cf..0c662a3f506a 100644 --- a/test/rubygems/test_gem_local_remote_options.rb +++ b/test/rubygems/test_gem_local_remote_options.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/local_remote_options' -require 'rubygems/command' +require_relative "helper" +require "rubygems/local_remote_options" +require "rubygems/command" class TestGemLocalRemoteOptions < Gem::TestCase def setup super - @cmd = Gem::Command.new 'dummy', 'dummy' + @cmd = Gem::Command.new "dummy", "dummy" @cmd.extend Gem::LocalRemoteOptions end @@ -75,10 +75,10 @@ def test_remote_eh def test_source_option @cmd.add_source_option - s1 = URI.parse 'http://more-gems.example.com/' - s2 = URI.parse 'http://even-more-gems.example.com/' - s3 = URI.parse 'http://other-gems.example.com/some_subdir' - s4 = URI.parse 'http://more-gems.example.com/' # Intentional duplicate + s1 = URI.parse "http://more-gems.example.com/" + s2 = URI.parse "http://even-more-gems.example.com/" + s3 = URI.parse "http://other-gems.example.com/some_subdir" + s4 = URI.parse "http://more-gems.example.com/" # Intentional duplicate original_sources = Gem.sources.dup @@ -96,7 +96,7 @@ def test_short_source_option original_sources = Gem.sources.dup - source = URI.parse 'http://more-gems.example.com/' + source = URI.parse "http://more-gems.example.com/" @cmd.handle_options %W[-s #{source}] original_sources << source @@ -121,7 +121,7 @@ def test_update_sources_option def test_source_option_bad @cmd.add_source_option - s1 = 'htp://more-gems.example.com' + s1 = "htp://more-gems.example.com" assert_raise ArgumentError do @cmd.handle_options %W[--source #{s1}] diff --git a/test/rubygems/test_gem_name_tuple.rb b/test/rubygems/test_gem_name_tuple.rb index d87db9bc4544..6eca69084c1b 100644 --- a/test/rubygems/test_gem_name_tuple.rb +++ b/test/rubygems/test_gem_name_tuple.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/name_tuple' +require_relative "helper" +require "rubygems/name_tuple" class TestGemNameTuple < Gem::TestCase def test_full_name @@ -34,8 +34,8 @@ def test_spec_name end def test_spaceship - a = Gem::NameTuple.new 'a', Gem::Version.new(0), Gem::Platform::RUBY - a_p = Gem::NameTuple.new 'a', Gem::Version.new(0), Gem::Platform.local + a = Gem::NameTuple.new "a", Gem::Version.new(0), Gem::Platform::RUBY + a_p = Gem::NameTuple.new "a", Gem::Version.new(0), Gem::Platform.local assert_equal 1, a_p.<=>(a) end diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index e3dce87c9583..9e18dacba1a3 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require_relative 'package/tar_test_case' -require 'rubygems/openssl' +require_relative "package/tar_test_case" +require "rubygems/openssl" class TestGemPackage < Gem::Package::TarTestCase def setup super - @spec = quick_gem 'a' do |s| - s.description = 'π' + @spec = quick_gem "a" do |s| + s.description = "π" s.files = %w[lib/code.rb] end @@ -16,7 +16,7 @@ def setup @gem = @spec.cache_file - @destination = File.join @tempdir, 'extract' + @destination = File.join @tempdir, "extract" FileUtils.mkdir_p @destination end @@ -24,11 +24,11 @@ def setup def test_class_new_old_format pend "jruby can't require the simple_gem file" if Gem.java_platform? require_relative "simple_gem" - File.open 'old_format.gem', 'wb' do |io| + File.open "old_format.gem", "wb" do |io| io.write SIMPLE_GEM end - package = Gem::Package.new 'old_format.gem' + package = Gem::Package.new "old_format.gem" assert package.spec end @@ -36,17 +36,17 @@ def test_class_new_old_format def test_add_checksums gem_io = StringIO.new - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] spec.date = Time.at 0 - spec.rubygems_version = Gem::Version.new '0' + spec.rubygems_version = Gem::Version.new "0" - FileUtils.mkdir 'lib' + FileUtils.mkdir "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end package = Gem::Package.new spec.file_name @@ -69,11 +69,11 @@ def test_add_checksums reader.each_entry do |entry| case entry.full_name - when 'checksums.yaml.gz' then + when "checksums.yaml.gz" then Zlib::GzipReader.wrap entry do |io| checksums = io.read end - when 'data.tar.gz' then + when "data.tar.gz" then tar = entry.read end end @@ -88,13 +88,13 @@ def test_add_checksums metadata_sha512 = OpenSSL::Digest::SHA512.hexdigest s.string expected = { - 'SHA512' => { - 'metadata.gz' => metadata_sha512, - 'data.tar.gz' => OpenSSL::Digest::SHA512.hexdigest(tar), + "SHA512" => { + "metadata.gz" => metadata_sha512, + "data.tar.gz" => OpenSSL::Digest::SHA512.hexdigest(tar), }, - 'SHA256' => { - 'metadata.gz' => metadata_sha256, - 'data.tar.gz' => OpenSSL::Digest::SHA256.hexdigest(tar), + "SHA256" => { + "metadata.gz" => metadata_sha256, + "data.tar.gz" => OpenSSL::Digest::SHA256.hexdigest(tar), }, } @@ -105,12 +105,12 @@ def test_build_time_uses_source_date_epoch epoch = ENV["SOURCE_DATE_EPOCH"] ENV["SOURCE_DATE_EPOCH"] = "123456789" - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] spec.date = Time.at 0 - spec.rubygems_version = Gem::Version.new '0' + spec.rubygems_version = Gem::Version.new "0" package = Gem::Package.new spec.file_name @@ -123,11 +123,11 @@ def test_build_time_without_source_date_epoch epoch = ENV["SOURCE_DATE_EPOCH"] ENV["SOURCE_DATE_EPOCH"] = nil - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] - spec.rubygems_version = Gem::Version.new '0' + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] + spec.rubygems_version = Gem::Version.new "0" package = Gem::Package.new spec.file_name @@ -144,17 +144,17 @@ def test_add_files spec = Gem::Specification.new spec.files = %w[lib/code.rb lib/empty] - FileUtils.mkdir_p 'lib/empty' + FileUtils.mkdir_p "lib/empty" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end - File.open 'lib/extra.rb', 'w' do |io| - io.write '# lib/extra.rb' + File.open "lib/extra.rb", "w" do |io| + io.write "# lib/extra.rb" end - package = Gem::Package.new 'bogus.gem' + package = Gem::Package.new "bogus.gem" package.spec = spec tar = util_tar do |tar_io| @@ -178,16 +178,16 @@ def test_add_files_symlink spec = Gem::Specification.new spec.files = %w[lib/code.rb lib/code_sym.rb lib/code_sym2.rb] - FileUtils.mkdir_p 'lib' + FileUtils.mkdir_p "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end # NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb begin - File.symlink('code.rb', 'lib/code_sym.rb') - File.symlink('../lib/code.rb', 'lib/code_sym2.rb') + File.symlink("code.rb", "lib/code_sym.rb") + File.symlink("../lib/code.rb", "lib/code_sym2.rb") rescue Errno::EACCES => e if win_platform? pend "symlink - must be admin with no UAC on Windows" @@ -196,7 +196,7 @@ def test_add_files_symlink end end - package = Gem::Package.new 'bogus.gem' + package = Gem::Package.new "bogus.gem" package.spec = spec tar = util_tar do |tar_io| @@ -218,20 +218,20 @@ def test_add_files_symlink end assert_equal %w[lib/code.rb], files - assert_equal [{ 'lib/code_sym.rb' => 'code.rb' }, { 'lib/code_sym2.rb' => '../lib/code.rb' }], symlinks + assert_equal [{ "lib/code_sym.rb" => "code.rb" }, { "lib/code_sym2.rb" => "../lib/code.rb" }], symlinks end def test_build - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] spec.rubygems_version = :junk - FileUtils.mkdir 'lib' + FileUtils.mkdir "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end package = Gem::Package.new spec.file_name @@ -252,25 +252,25 @@ def test_build end def test_build_auto_signed - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL - FileUtils.mkdir_p File.join(Gem.user_home, '.gem') + FileUtils.mkdir_p File.join(Gem.user_home, ".gem") - private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' + private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" Gem::Security.write PRIVATE_KEY, private_key_path - public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" FileUtils.cp PUBLIC_CERT_PATH, public_cert_path - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] - FileUtils.mkdir 'lib' + FileUtils.mkdir "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end package = Gem::Package.new spec.file_name @@ -295,25 +295,25 @@ def test_build_auto_signed end def test_build_auto_signed_encrypted_key - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL - FileUtils.mkdir_p File.join(Gem.user_home, '.gem') + FileUtils.mkdir_p File.join(Gem.user_home, ".gem") - private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' + private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" FileUtils.cp ENCRYPTED_PRIVATE_KEY_PATH, private_key_path - public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" Gem::Security.write PUBLIC_CERT, public_cert_path - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] - FileUtils.mkdir 'lib' + FileUtils.mkdir "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end package = Gem::Package.new spec.file_name @@ -338,7 +338,7 @@ def test_build_auto_signed_encrypted_key end def test_build_invalid - spec = Gem::Specification.new 'build', '1' + spec = Gem::Specification.new "build", "1" package = Gem::Package.new spec.file_name package.spec = spec @@ -347,11 +347,11 @@ def test_build_invalid package.build end - assert_equal 'missing value for attribute summary', e.message + assert_equal "missing value for attribute summary", e.message end def test_build_invalid_arguments - spec = Gem::Specification.new 'build', '1' + spec = Gem::Specification.new "build", "1" package = Gem::Package.new spec.file_name package.spec = spec @@ -364,19 +364,19 @@ def test_build_invalid_arguments end def test_build_signed - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] spec.cert_chain = [PUBLIC_CERT.to_pem] spec.signing_key = PRIVATE_KEY - FileUtils.mkdir 'lib' + FileUtils.mkdir "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end package = Gem::Package.new spec.file_name @@ -401,19 +401,19 @@ def test_build_signed end def test_build_signed_encrypted_key - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL - spec = Gem::Specification.new 'build', '1' - spec.summary = 'build' - spec.authors = 'build' - spec.files = ['lib/code.rb'] + spec = Gem::Specification.new "build", "1" + spec.summary = "build" + spec.authors = "build" + spec.files = ["lib/code.rb"] spec.cert_chain = [PUBLIC_CERT.to_pem] spec.signing_key = ENCRYPTED_PRIVATE_KEY - FileUtils.mkdir 'lib' + FileUtils.mkdir "lib" - File.open 'lib/code.rb', 'w' do |io| - io.write '# lib/code.rb' + File.open "lib/code.rb", "w" do |io| + io.write "# lib/code.rb" end package = Gem::Package.new spec.file_name @@ -441,11 +441,11 @@ def test_raw_spec data_tgz = util_tar_gz {} gem = util_tar do |tar| - tar.add_file 'data.tar.gz', 0644 do |io| + tar.add_file "data.tar.gz", 0644 do |io| io.write data_tgz.string end - tar.add_file 'metadata.gz', 0644 do |io| + tar.add_file "metadata.gz", 0644 do |io| Zlib::GzipWriter.wrap io do |gzio| gzio.write @spec.to_yaml end @@ -475,7 +475,7 @@ def test_extract_files package.extract_files @destination - extracted = File.join @destination, 'lib/code.rb' + extracted = File.join @destination, "lib/code.rb" assert_path_exist extracted mask = 0100666 & (~File.umask) @@ -488,22 +488,22 @@ def test_extract_files_empty data_tgz = util_tar_gz {} gem = util_tar do |tar| - tar.add_file 'data.tar.gz', 0644 do |io| + tar.add_file "data.tar.gz", 0644 do |io| io.write data_tgz.string end - tar.add_file 'metadata.gz', 0644 do |io| + tar.add_file "metadata.gz", 0644 do |io| Zlib::GzipWriter.wrap io do |gzio| gzio.write @spec.to_yaml end end end - File.open 'empty.gem', 'wb' do |io| + File.open "empty.gem", "wb" do |io| io.write gem.string end - package = Gem::Package.new 'empty.gem' + package = Gem::Package.new "empty.gem" package.extract_files @destination @@ -514,8 +514,8 @@ def test_extract_tar_gz_absolute package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.add_file '/absolute.rb', 0644 do |io| - io.write 'hi' + tar.add_file "/absolute.rb", 0644 do |io| + io.write "hi" end end @@ -531,12 +531,12 @@ def test_extract_tar_gz_symlink_relative_path package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.add_file 'relative.rb', 0644 do |io| - io.write 'hi' + tar.add_file "relative.rb", 0644 do |io| + io.write "hi" end - tar.mkdir 'lib', 0755 - tar.add_symlink 'lib/foo.rb', '../relative.rb', 0644 + tar.mkdir "lib", 0755 + tar.add_symlink "lib/foo.rb", "../relative.rb", 0644 end begin @@ -549,11 +549,11 @@ def test_extract_tar_gz_symlink_relative_path end end - extracted = File.join @destination, 'lib/foo.rb' + extracted = File.join @destination, "lib/foo.rb" assert_path_exist extracted - assert_equal '../relative.rb', + assert_equal "../relative.rb", File.readlink(extracted) - assert_equal 'hi', + assert_equal "hi", File.read(extracted) end @@ -561,17 +561,17 @@ def test_extract_symlink_parent package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.mkdir 'lib', 0755 - tar.add_symlink 'lib/link', '../..', 0644 - tar.add_file 'lib/link/outside.txt', 0644 do |io| - io.write 'hi' + tar.mkdir "lib", 0755 + tar.add_symlink "lib/link", "../..", 0644 + tar.add_file "lib/link/outside.txt", 0644 do |io| + io.write "hi" end end # Extract into a subdirectory of @destination; if this test fails it writes # a file outside destination_subdir, but we want the file to remain inside # @destination so it will be cleaned up. - destination_subdir = File.join @destination, 'subdir' + destination_subdir = File.join @destination, "subdir" FileUtils.mkdir_p destination_subdir expected_exceptions = win_platform? ? [Gem::Package::SymlinkError, Errno::EACCES] : [Gem::Package::SymlinkError] @@ -595,18 +595,18 @@ def test_extract_symlink_parent_doesnt_delete_user_dir # Extract into a subdirectory of @destination; if this test fails it writes # a file outside destination_subdir, but we want the file to remain inside # @destination so it will be cleaned up. - destination_subdir = File.join @destination, 'subdir' + destination_subdir = File.join @destination, "subdir" FileUtils.mkdir_p destination_subdir - destination_user_dir = File.join @destination, 'user' - destination_user_subdir = File.join destination_user_dir, 'dir' + destination_user_dir = File.join @destination, "user" + destination_user_subdir = File.join destination_user_dir, "dir" FileUtils.mkdir_p destination_user_subdir pend "TMPDIR seems too long to add it as symlink into tar" if destination_user_dir.size > 90 tgz_io = util_tar_gz do |tar| - tar.add_symlink 'link', destination_user_dir, 16877 - tar.add_symlink 'link/dir', '.', 16877 + tar.add_symlink "link", destination_user_dir, 16877 + tar.add_symlink "link/dir", ".", 16877 end expected_exceptions = win_platform? ? [Gem::Package::SymlinkError, Errno::EACCES] : [Gem::Package::SymlinkError] @@ -629,19 +629,19 @@ def test_extract_tar_gz_directory package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.mkdir 'lib', 0755 - tar.add_file 'lib/foo.rb', 0644 do |io| - io.write 'hi' + tar.mkdir "lib", 0755 + tar.add_file "lib/foo.rb", 0644 do |io| + io.write "hi" end - tar.mkdir 'lib/foo', 0755 + tar.mkdir "lib/foo", 0755 end package.extract_tar_gz tgz_io, @destination - extracted = File.join @destination, 'lib/foo.rb' + extracted = File.join @destination, "lib/foo.rb" assert_path_exist extracted - extracted = File.join @destination, 'lib/foo' + extracted = File.join @destination, "lib/foo" assert_path_exist extracted end @@ -649,14 +649,14 @@ def test_extract_tar_gz_dot_slash package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.add_file './dot_slash.rb', 0644 do |io| - io.write 'hi' + tar.add_file "./dot_slash.rb", 0644 do |io| + io.write "hi" end end package.extract_tar_gz tgz_io, @destination - extracted = File.join @destination, 'dot_slash.rb' + extracted = File.join @destination, "dot_slash.rb" assert_path_exist extracted end @@ -664,14 +664,14 @@ def test_extract_tar_gz_dot_file package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.add_file '.dot_file.rb', 0644 do |io| - io.write 'hi' + tar.add_file ".dot_file.rb", 0644 do |io| + io.write "hi" end end package.extract_tar_gz tgz_io, @destination - extracted = File.join @destination, '.dot_file.rb' + extracted = File.join @destination, ".dot_file.rb" assert_path_exist extracted end @@ -680,14 +680,14 @@ def test_extract_tar_gz_case_insensitive package = Gem::Package.new @gem tgz_io = util_tar_gz do |tar| - tar.add_file 'foo/file.rb', 0644 do |io| - io.write 'hi' + tar.add_file "foo/file.rb", 0644 do |io| + io.write "hi" end end package.extract_tar_gz tgz_io, @destination.upcase - extracted = File.join @destination, 'foo/file.rb' + extracted = File.join @destination, "foo/file.rb" assert_path_exist extracted end end @@ -695,20 +695,20 @@ def test_extract_tar_gz_case_insensitive def test_install_location package = Gem::Package.new @gem - file = 'file.rb'.dup - file.taint if RUBY_VERSION < '2.7' + file = "file.rb".dup + file.taint if RUBY_VERSION < "2.7" destination = package.install_location file, @destination - assert_equal File.join(@destination, 'file.rb'), destination - refute destination.tainted? if RUBY_VERSION < '2.7' + assert_equal File.join(@destination, "file.rb"), destination + refute destination.tainted? if RUBY_VERSION < "2.7" end def test_install_location_absolute package = Gem::Package.new @gem e = assert_raise Gem::Package::PathError do - package.install_location '/absolute.rb', @destination + package.install_location "/absolute.rb", @destination end assert_equal("installing into parent path /absolute.rb of " + @@ -718,36 +718,36 @@ def test_install_location_absolute def test_install_location_dots package = Gem::Package.new @gem - file = 'file.rb' + file = "file.rb" - destination = File.join @destination, 'foo', '..', 'bar' + destination = File.join @destination, "foo", "..", "bar" - FileUtils.mkdir_p File.join @destination, 'foo' + FileUtils.mkdir_p File.join @destination, "foo" FileUtils.mkdir_p File.expand_path destination destination = package.install_location file, destination # this test only fails on ruby missing File.realpath - assert_equal File.join(@destination, 'bar', 'file.rb'), destination + assert_equal File.join(@destination, "bar", "file.rb"), destination end def test_install_location_extra_slash package = Gem::Package.new @gem - file = 'foo//file.rb'.dup - file.taint if RUBY_VERSION < '2.7' + file = "foo//file.rb".dup + file.taint if RUBY_VERSION < "2.7" destination = package.install_location file, @destination - assert_equal File.join(@destination, 'foo', 'file.rb'), destination - refute destination.tainted? if RUBY_VERSION < '2.7' + assert_equal File.join(@destination, "foo", "file.rb"), destination + refute destination.tainted? if RUBY_VERSION < "2.7" end def test_install_location_relative package = Gem::Package.new @gem e = assert_raise Gem::Package::PathError do - package.install_location '../relative.rb', @destination + package.install_location "../relative.rb", @destination end parent = File.expand_path File.join @destination, "../relative.rb" @@ -773,9 +773,9 @@ def test_install_location_suffix def test_load_spec entry = StringIO.new Gem::Util.gzip @spec.to_yaml - def entry.full_name() 'metadata.gz' end + def entry.full_name() "metadata.gz" end - package = Gem::Package.new 'nonexistent.gem' + package = Gem::Package.new "nonexistent.gem" spec = package.load_spec entry @@ -794,8 +794,8 @@ def test_verify def test_verify_checksum_bad data_tgz = util_tar_gz do |tar| - tar.add_file 'lib/code.rb', 0444 do |io| - io.write '# lib/code.rb' + tar.add_file "lib/code.rb", 0444 do |io| + io.write "# lib/code.rb" end end @@ -804,45 +804,45 @@ def test_verify_checksum_bad gem = util_tar do |tar| metadata_gz = Gem::Util.gzip @spec.to_yaml - tar.add_file 'metadata.gz', 0444 do |io| + tar.add_file "metadata.gz", 0444 do |io| io.write metadata_gz end - tar.add_file 'data.tar.gz', 0444 do |io| + tar.add_file "data.tar.gz", 0444 do |io| io.write data_tgz end bogus_checksums = { - 'SHA1' => { - 'data.tar.gz' => 'bogus', - 'metadata.gz' => 'bogus', + "SHA1" => { + "data.tar.gz" => "bogus", + "metadata.gz" => "bogus", }, } - tar.add_file 'checksums.yaml.gz', 0444 do |io| + tar.add_file "checksums.yaml.gz", 0444 do |io| Zlib::GzipWriter.wrap io do |gz_io| gz_io.write Psych.dump bogus_checksums end end end - File.open 'mismatch.gem', 'wb' do |io| + File.open "mismatch.gem", "wb" do |io| io.write gem.string end - package = Gem::Package.new 'mismatch.gem' + package = Gem::Package.new "mismatch.gem" e = assert_raise Gem::Package::FormatError do package.verify end - assert_equal 'SHA1 checksum mismatch for data.tar.gz in mismatch.gem', + assert_equal "SHA1 checksum mismatch for data.tar.gz in mismatch.gem", e.message end def test_verify_checksum_missing data_tgz = util_tar_gz do |tar| - tar.add_file 'lib/code.rb', 0444 do |io| - io.write '# lib/code.rb' + tar.add_file "lib/code.rb", 0444 do |io| + io.write "# lib/code.rb" end end @@ -851,7 +851,7 @@ def test_verify_checksum_missing gem = util_tar do |tar| metadata_gz = Gem::Util.gzip @spec.to_yaml - tar.add_file 'metadata.gz', 0444 do |io| + tar.add_file "metadata.gz", 0444 do |io| io.write metadata_gz end @@ -859,37 +859,37 @@ def test_verify_checksum_missing digest << metadata_gz checksums = { - 'SHA1' => { - 'metadata.gz' => digest.hexdigest, + "SHA1" => { + "metadata.gz" => digest.hexdigest, }, } - tar.add_file 'checksums.yaml.gz', 0444 do |io| + tar.add_file "checksums.yaml.gz", 0444 do |io| Zlib::GzipWriter.wrap io do |gz_io| gz_io.write Psych.dump checksums end end - tar.add_file 'data.tar.gz', 0444 do |io| + tar.add_file "data.tar.gz", 0444 do |io| io.write data_tgz end end - File.open 'data_checksum_missing.gem', 'wb' do |io| + File.open "data_checksum_missing.gem", "wb" do |io| io.write gem.string end - package = Gem::Package.new 'data_checksum_missing.gem' + package = Gem::Package.new "data_checksum_missing.gem" assert package.verify end def test_verify_corrupt pend "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform? - tf = Tempfile.open 'corrupt' do |io| - data = Gem::Util.gzip 'a' * 10 + tf = Tempfile.open "corrupt" do |io| + data = Gem::Util.gzip "a" * 10 io.write \ - tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now) + tar_file_header("metadata.gz", "\000x", 0644, data.length, Time.now) io.write data io.rewind @@ -907,19 +907,19 @@ def test_verify_corrupt end def test_verify_empty - FileUtils.touch 'empty.gem' + FileUtils.touch "empty.gem" - package = Gem::Package.new 'empty.gem' + package = Gem::Package.new "empty.gem" e = assert_raise Gem::Package::FormatError do package.verify end - assert_equal 'package metadata is missing in empty.gem', e.message + assert_equal "package metadata is missing in empty.gem", e.message end def test_verify_nonexistent - package = Gem::Package.new 'nonexistent.gem' + package = Gem::Package.new "nonexistent.gem" e = assert_raise Gem::Package::FormatError do package.verify @@ -930,19 +930,19 @@ def test_verify_nonexistent end def test_verify_duplicate_file - FileUtils.mkdir_p 'lib' - FileUtils.touch 'lib/code.rb' + FileUtils.mkdir_p "lib" + FileUtils.touch "lib/code.rb" build = Gem::Package.new @gem build.spec = @spec build.setup_signer - File.open @gem, 'wb' do |gem_io| + File.open @gem, "wb" do |gem_io| Gem::Package::TarWriter.new gem_io do |gem| build.add_metadata gem build.add_contents gem - gem.add_file_simple 'a.sig', 0444, 0 - gem.add_file_simple 'a.sig', 0444, 0 + gem.add_file_simple "a.sig", 0444, 0 + gem.add_file_simple "a.sig", 0444, 0 end end @@ -956,7 +956,7 @@ def test_verify_duplicate_file end def test_verify_security_policy - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL package = Gem::Package.new @gem package.security_policy = Gem::Security::HighSecurity @@ -965,21 +965,21 @@ def test_verify_security_policy package.verify end - assert_equal 'unsigned gems are not allowed by the High Security policy', + assert_equal "unsigned gems are not allowed by the High Security policy", e.message - refute package.instance_variable_get(:@spec), '@spec must not be loaded' - assert_empty package.instance_variable_get(:@files), '@files must empty' + refute package.instance_variable_get(:@spec), "@spec must not be loaded" + assert_empty package.instance_variable_get(:@files), "@files must empty" end def test_verify_security_policy_low_security - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @spec.cert_chain = [PUBLIC_CERT.to_pem] @spec.signing_key = PRIVATE_KEY - FileUtils.mkdir_p 'lib' - FileUtils.touch 'lib/code.rb' + FileUtils.mkdir_p "lib" + FileUtils.touch "lib/code.rb" build = Gem::Package.new @gem build.spec = @spec @@ -993,7 +993,7 @@ def test_verify_security_policy_low_security end def test_verify_security_policy_checksum_missing - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @spec.cert_chain = [PUBLIC_CERT.to_pem] @spec.signing_key = PRIVATE_KEY @@ -1002,23 +1002,23 @@ def test_verify_security_policy_checksum_missing build.spec = @spec build.setup_signer - FileUtils.mkdir 'lib' - FileUtils.touch 'lib/code.rb' + FileUtils.mkdir "lib" + FileUtils.touch "lib/code.rb" - File.open @gem, 'wb' do |gem_io| + File.open @gem, "wb" do |gem_io| Gem::Package::TarWriter.new gem_io do |gem| build.add_metadata gem build.add_contents gem # write bogus data.tar.gz to foil signature - bogus_data = Gem::Util.gzip 'hello' + bogus_data = Gem::Util.gzip "hello" fake_signer = Class.new do - def digest_name; 'SHA512'; end + def digest_name; "SHA512"; end def digest_algorithm; OpenSSL::Digest(:SHA512).new; end - def key; 'key'; end - def sign(*); 'fake_sig'; end + def key; "key"; end + def sign(*); "fake_sig"; end end - gem.add_file_signed 'data2.tar.gz', 0444, fake_signer.new do |io| + gem.add_file_signed "data2.tar.gz", 0444, fake_signer.new do |io| io.write bogus_data end @@ -1035,24 +1035,24 @@ def sign(*); 'fake_sig'; end package.verify end - assert_equal 'invalid signature', e.message + assert_equal "invalid signature", e.message - refute package.instance_variable_get(:@spec), '@spec must not be loaded' - assert_empty package.instance_variable_get(:@files), '@files must empty' + refute package.instance_variable_get(:@spec), "@spec must not be loaded" + assert_empty package.instance_variable_get(:@files), "@files must empty" end def test_verify_truncate - File.open 'bad.gem', 'wb' do |io| + File.open "bad.gem", "wb" do |io| io.write File.read(@gem, 1024) # don't care about newlines end - package = Gem::Package.new 'bad.gem' + package = Gem::Package.new "bad.gem" e = assert_raise Gem::Package::FormatError do package.verify end - assert_equal 'package content (data.tar.gz) is missing in bad.gem', + assert_equal "package content (data.tar.gz) is missing in bad.gem", e.message end @@ -1060,7 +1060,7 @@ def test_verify_truncate def test_verify_entry entry = Object.new - def entry.full_name() raise ArgumentError, 'whatever' end + def entry.full_name() raise ArgumentError, "whatever" end package = Gem::Package.new @gem diff --git a/test/rubygems/test_gem_package_old.rb b/test/rubygems/test_gem_package_old.rb index 945340a96ace..d65d1edad65a 100644 --- a/test/rubygems/test_gem_package_old.rb +++ b/test/rubygems/test_gem_package_old.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" unless Gem.java_platform? # jruby can't require the simple_gem file - require 'rubygems/simple_gem' + require "rubygems/simple_gem" class TestGemPackageOld < Gem::TestCase def setup super - File.open 'old_format.gem', 'wb' do |io| + File.open "old_format.gem", "wb" do |io| io.write SIMPLE_GEM end - @package = Gem::Package::Old.new 'old_format.gem' - @destination = File.join @tempdir, 'extract' + @package = Gem::Package::Old.new "old_format.gem" + @destination = File.join @tempdir, "extract" FileUtils.mkdir_p @destination end @@ -23,7 +23,7 @@ def test_contents end def test_contents_security_policy - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @package.security_policy = Gem::Security::AlmostNoSecurity @@ -35,7 +35,7 @@ def test_contents_security_policy def test_extract_files @package.extract_files @destination - extracted = File.join @destination, 'lib/foo.rb' + extracted = File.join @destination, "lib/foo.rb" assert_path_exist extracted mask = 0100644 & (~File.umask) @@ -44,7 +44,7 @@ def test_extract_files end def test_extract_files_security_policy - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @package.security_policy = Gem::Security::AlmostNoSecurity @@ -54,11 +54,11 @@ def test_extract_files_security_policy end def test_spec - assert_equal 'testing', @package.spec.name + assert_equal "testing", @package.spec.name end def test_spec_security_policy - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL @package.security_policy = Gem::Security::AlmostNoSecurity @@ -68,7 +68,7 @@ def test_spec_security_policy end def test_verify - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL assert @package.verify @@ -82,8 +82,8 @@ def test_verify @package.verify end - assert_equal 'old format gems do not contain signatures ' + - 'and cannot be verified', + assert_equal "old format gems do not contain signatures " + + "and cannot be verified", e.message end end diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb index 0e72a72d6a3f..3ff4f0b30b21 100644 --- a/test/rubygems/test_gem_package_tar_header.rb +++ b/test/rubygems/test_gem_package_tar_header.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require_relative 'package/tar_test_case' -require 'rubygems/package' +require_relative "package/tar_test_case" +require "rubygems/package" class TestGemPackageTarHeader < Gem::Package::TarTestCase def setup super header = { - :name => 'x', + :name => "x", :mode => 0644, :uid => 1000, :gid => 10000, :size => 100, :mtime => 12345, - :typeflag => '0', - :linkname => 'link', - :uname => 'user', - :gname => 'group', + :typeflag => "0", + :linkname => "link", + :uname => "user", + :gname => "group", :devmajor => 1, :devminor => 2, - :prefix => 'y', + :prefix => "y", } @tar_header = Gem::Package::TarHeader.new header @@ -36,62 +36,62 @@ def test_self_from end def test_initialize - assert_equal '', @tar_header.checksum, 'checksum' - assert_equal 1, @tar_header.devmajor, 'devmajor' - assert_equal 2, @tar_header.devminor, 'devminor' - assert_equal 10000, @tar_header.gid, 'gid' - assert_equal 'group', @tar_header.gname, 'gname' - assert_equal 'link', @tar_header.linkname, 'linkname' - assert_equal 'ustar', @tar_header.magic, 'magic' - assert_equal 0644, @tar_header.mode, 'mode' - assert_equal 12345, @tar_header.mtime, 'mtime' - assert_equal 'x', @tar_header.name, 'name' - assert_equal 'y', @tar_header.prefix, 'prefix' - assert_equal 100, @tar_header.size, 'size' - assert_equal '0', @tar_header.typeflag, 'typeflag' - assert_equal 1000, @tar_header.uid, 'uid' - assert_equal 'user', @tar_header.uname, 'uname' - assert_equal '00', @tar_header.version, 'version' - - refute_empty @tar_header, 'empty' + assert_equal "", @tar_header.checksum, "checksum" + assert_equal 1, @tar_header.devmajor, "devmajor" + assert_equal 2, @tar_header.devminor, "devminor" + assert_equal 10000, @tar_header.gid, "gid" + assert_equal "group", @tar_header.gname, "gname" + assert_equal "link", @tar_header.linkname, "linkname" + assert_equal "ustar", @tar_header.magic, "magic" + assert_equal 0644, @tar_header.mode, "mode" + assert_equal 12345, @tar_header.mtime, "mtime" + assert_equal "x", @tar_header.name, "name" + assert_equal "y", @tar_header.prefix, "prefix" + assert_equal 100, @tar_header.size, "size" + assert_equal "0", @tar_header.typeflag, "typeflag" + assert_equal 1000, @tar_header.uid, "uid" + assert_equal "user", @tar_header.uname, "uname" + assert_equal "00", @tar_header.version, "version" + + refute_empty @tar_header, "empty" end def test_initialize_bad assert_raise ArgumentError do - Gem::Package::TarHeader.new :name => '', :size => '', :mode => '' + Gem::Package::TarHeader.new :name => "", :size => "", :mode => "" end assert_raise ArgumentError do - Gem::Package::TarHeader.new :name => '', :size => '', :prefix => '' + Gem::Package::TarHeader.new :name => "", :size => "", :prefix => "" end assert_raise ArgumentError do - Gem::Package::TarHeader.new :name => '', :prefix => '', :mode => '' + Gem::Package::TarHeader.new :name => "", :prefix => "", :mode => "" end assert_raise ArgumentError do - Gem::Package::TarHeader.new :prefix => '', :size => '', :mode => '' + Gem::Package::TarHeader.new :prefix => "", :size => "", :mode => "" end end def test_initialize_typeflag header = { - :mode => '', - :name => '', - :prefix => '', - :size => '', - :typeflag => '', + :mode => "", + :name => "", + :prefix => "", + :size => "", + :typeflag => "", } tar_header = Gem::Package::TarHeader.new header - assert_equal '0', tar_header.typeflag + assert_equal "0", tar_header.typeflag end def test_empty_eh refute_empty @tar_header - @tar_header = Gem::Package::TarHeader.new :name => 'x', :prefix => '', + @tar_header = Gem::Package::TarHeader.new :name => "x", :prefix => "", :mode => 0, :size => 0, :empty => true @@ -135,11 +135,11 @@ def test_to_s end def test_update_checksum - assert_equal '', @tar_header.checksum + assert_equal "", @tar_header.checksum @tar_header.update_checksum - assert_equal '012467', @tar_header.checksum + assert_equal "012467", @tar_header.checksum end def test_from_bad_octal @@ -165,7 +165,7 @@ def test_from_bad_octal def test_big_uid_gid stream = StringIO.new( - <<-EOF.dup.force_encoding('binary').split("\n").join + <<-EOF.dup.force_encoding("binary").split("\n").join GeoIP2-City_20190528/ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 @@ -197,7 +197,7 @@ def test_big_uid_gid assert_equal 1991400094, tar_header.uid assert_equal 1991400094, tar_header.gid - assert_equal 'GeoIP2-City_20190528/', tar_header.name + assert_equal "GeoIP2-City_20190528/", tar_header.name assert_equal 0755, tar_header.mode assert_equal 0, tar_header.size assert_equal 1559064640, tar_header.mtime @@ -206,7 +206,7 @@ def test_big_uid_gid def test_spaces_in_headers stream = StringIO.new( - <<-EOF.dup.force_encoding('binary').split("\n").join + <<-EOF.dup.force_encoding("binary").split("\n").join Access_Points_09202018.csv \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 diff --git a/test/rubygems/test_gem_package_tar_reader.rb b/test/rubygems/test_gem_package_tar_reader.rb index 277b552f1bc2..86ffff4fe52e 100644 --- a/test/rubygems/test_gem_package_tar_reader.rb +++ b/test/rubygems/test_gem_package_tar_reader.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'package/tar_test_case' -require 'rubygems/package' +require_relative "package/tar_test_case" +require "rubygems/package" class TestGemPackageTarReader < Gem::Package::TarTestCase def test_each_entry @@ -25,7 +25,7 @@ def test_each_entry end def test_rewind - content = ('a'..'z').to_a.join(" ") + content = ("a".."z").to_a.join(" ") str = tar_file_header("lib/foo", "", 010644, content.size, Time.now) + @@ -56,10 +56,10 @@ def test_seek io = TempIO.new tar Gem::Package::TarReader.new io do |tar_reader| - tar_reader.seek 'baz/bar' do |entry| + tar_reader.seek "baz/bar" do |entry| assert_kind_of Gem::Package::TarReader::Entry, entry - assert_equal 'baz/bar', entry.full_name + assert_equal "baz/bar", entry.full_name end assert_equal 0, io.pos @@ -75,8 +75,8 @@ def test_seek_missing io = TempIO.new tar Gem::Package::TarReader.new io do |tar_reader| - tar_reader.seek 'nonexistent' do |entry| - flunk 'entry missing but entry-found block was run' + tar_reader.seek "nonexistent" do |entry| + flunk "entry missing but entry-found block was run" end assert_equal 0, io.pos diff --git a/test/rubygems/test_gem_package_tar_reader_entry.rb b/test/rubygems/test_gem_package_tar_reader_entry.rb index 1be587014617..ffb45421781a 100644 --- a/test/rubygems/test_gem_package_tar_reader_entry.rb +++ b/test/rubygems/test_gem_package_tar_reader_entry.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative 'package/tar_test_case' -require 'rubygems/package' +require_relative "package/tar_test_case" +require "rubygems/package" class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase def setup super - @contents = ('a'..'z').to_a.join * 100 + @contents = ("a".."z").to_a.join * 100 @tar = String.new @tar << tar_file_header("lib/foo", "", 0, @contents.size, Time.now) @@ -43,19 +43,19 @@ def test_close assert @entry.bytes_read e = assert_raise(IOError) { @entry.eof? } - assert_equal 'closed Gem::Package::TarReader::Entry', e.message + assert_equal "closed Gem::Package::TarReader::Entry", e.message e = assert_raise(IOError) { @entry.getc } - assert_equal 'closed Gem::Package::TarReader::Entry', e.message + assert_equal "closed Gem::Package::TarReader::Entry", e.message e = assert_raise(IOError) { @entry.pos } - assert_equal 'closed Gem::Package::TarReader::Entry', e.message + assert_equal "closed Gem::Package::TarReader::Entry", e.message e = assert_raise(IOError) { @entry.read } - assert_equal 'closed Gem::Package::TarReader::Entry', e.message + assert_equal "closed Gem::Package::TarReader::Entry", e.message e = assert_raise(IOError) { @entry.rewind } - assert_equal 'closed Gem::Package::TarReader::Entry', e.message + assert_equal "closed Gem::Package::TarReader::Entry", e.message end def test_closed_eh @@ -71,7 +71,7 @@ def test_eof_eh end def test_full_name - assert_equal 'lib/foo', @entry.full_name + assert_equal "lib/foo", @entry.full_name end def test_full_name_null @@ -82,7 +82,7 @@ def test_full_name_null @entry.full_name end - assert_equal 'tar is corrupt, name contains null byte', e.message + assert_equal "tar is corrupt, name contains null byte", e.message end def test_getc diff --git a/test/rubygems/test_gem_package_tar_writer.rb b/test/rubygems/test_gem_package_tar_writer.rb index 31a91fa21abd..5dcb90c14e47 100644 --- a/test/rubygems/test_gem_package_tar_writer.rb +++ b/test/rubygems/test_gem_package_tar_writer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'package/tar_test_case' -require 'rubygems/package/tar_writer' +require_relative "package/tar_test_case" +require "rubygems/package/tar_writer" class TestGemPackageTarWriter < Gem::Package::TarTestCase def setup @@ -11,7 +11,7 @@ def setup # is not set. Gem.instance_variable_set(:'@default_source_date_epoch', nil) - @data = 'abcde12345' + @data = "abcde12345" @io = TempIO.new @tar_writer = Gem::Package::TarWriter.new @io @epoch = ENV["SOURCE_DATE_EPOCH"] @@ -28,11 +28,11 @@ def teardown def test_add_file Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file 'x', 0644 do |f| - f.write 'a' * 10 + @tar_writer.add_file "x", 0644 do |f| + f.write "a" * 10 end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now), @io.string[0, 512]) end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] @@ -42,18 +42,18 @@ def test_add_file def test_add_file_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" Time.stub :now, Time.at(1458518157) do - @tar_writer.mkdir 'foo', 0644 + @tar_writer.mkdir "foo", 0644 - assert_headers_equal tar_dir_header('foo', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), + assert_headers_equal tar_dir_header("foo", "", 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), @io.string[0, 512] end end def test_add_symlink Time.stub :now, Time.at(1458518157) do - @tar_writer.add_symlink 'x', 'y', 0644 + @tar_writer.add_symlink "x", "y", 0644 - assert_headers_equal(tar_symlink_header('x', '', 0644, Time.now, 'y'), + assert_headers_equal(tar_symlink_header("x", "", 0644, Time.now, "y"), @io.string[0, 512]) end assert_equal 512, @io.pos @@ -62,9 +62,9 @@ def test_add_symlink def test_add_symlink_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" Time.stub :now, Time.at(1458518157) do - @tar_writer.add_symlink 'x', 'y', 0644 + @tar_writer.add_symlink "x", "y", 0644 - assert_headers_equal(tar_symlink_header('x', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, 'y'), + assert_headers_equal(tar_symlink_header("x", "", 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, "y"), @io.string[0, 512]) end end @@ -73,19 +73,19 @@ def test_add_file_digest digest_algorithms = Digest::SHA1.new, Digest::SHA512.new Time.stub :now, Time.at(1458518157) do - digests = @tar_writer.add_file_digest 'x', 0644, digest_algorithms do |io| - io.write 'a' * 10 + digests = @tar_writer.add_file_digest "x", 0644, digest_algorithms do |io| + io.write "a" * 10 end - assert_equal '3495ff69d34671d1e15b33a63c1379fdedd3a32a', - digests['SHA1'].hexdigest - assert_equal '4714870aff6c97ca09d135834fdb58a6389a50c1' \ - '1fef8ec4afef466fb60a23ac6b7a9c92658f14df' \ - '4993d6b40a4e4d8424196afc347e97640d68de61' \ - 'e1cf14b0', - digests['SHA512'].hexdigest + assert_equal "3495ff69d34671d1e15b33a63c1379fdedd3a32a", + digests["SHA1"].hexdigest + assert_equal "4714870aff6c97ca09d135834fdb58a6389a50c1" \ + "1fef8ec4afef466fb60a23ac6b7a9c92658f14df" \ + "4993d6b40a4e4d8424196afc347e97640d68de61" \ + "e1cf14b0", + digests["SHA512"].hexdigest - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now), @io.string[0, 512]) end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] @@ -96,19 +96,19 @@ def test_add_file_digest_multiple digest_algorithms = [Digest::SHA1.new, Digest::SHA512.new] Time.stub :now, Time.at(1458518157) do - digests = @tar_writer.add_file_digest 'x', 0644, digest_algorithms do |io| - io.write 'a' * 10 + digests = @tar_writer.add_file_digest "x", 0644, digest_algorithms do |io| + io.write "a" * 10 end - assert_equal '3495ff69d34671d1e15b33a63c1379fdedd3a32a', - digests['SHA1'].hexdigest - assert_equal '4714870aff6c97ca09d135834fdb58a6389a50c1' \ - '1fef8ec4afef466fb60a23ac6b7a9c92658f14df' \ - '4993d6b40a4e4d8424196afc347e97640d68de61' \ - 'e1cf14b0', - digests['SHA512'].hexdigest + assert_equal "3495ff69d34671d1e15b33a63c1379fdedd3a32a", + digests["SHA1"].hexdigest + assert_equal "4714870aff6c97ca09d135834fdb58a6389a50c1" \ + "1fef8ec4afef466fb60a23ac6b7a9c92658f14df" \ + "4993d6b40a4e4d8424196afc347e97640d68de61" \ + "e1cf14b0", + digests["SHA512"].hexdigest - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now), @io.string[0, 512]) end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] @@ -116,26 +116,26 @@ def test_add_file_digest_multiple end def test_add_file_signer - pend 'openssl is missing' unless Gem::HAVE_OPENSSL + pend "openssl is missing" unless Gem::HAVE_OPENSSL signer = Gem::Security::Signer.new PRIVATE_KEY, [PUBLIC_CERT] Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_signed 'x', 0644, signer do |io| - io.write 'a' * 10 + @tar_writer.add_file_signed "x", 0644, signer do |io| + io.write "a" * 10 end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now), @io.string[0, 512]) assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] digest = signer.digest_algorithm.new - digest.update 'a' * 10 + digest.update "a" * 10 signature = signer.sign digest.digest - assert_headers_equal(tar_file_header('x.sig', '', 0444, signature.length, + assert_headers_equal(tar_file_header("x.sig", "", 0444, signature.length, Time.now), @io.string[1024, 512]) assert_equal "#{signature}#{"\0" * (512 - signature.length)}", @@ -149,11 +149,11 @@ def test_add_file_signer_empty signer = Gem::Security::Signer.new nil, nil Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_signed 'x', 0644, signer do |io| - io.write 'a' * 10 + @tar_writer.add_file_signed "x", 0644, signer do |io| + io.write "a" * 10 end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now), @io.string[0, 512]) end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] @@ -163,11 +163,11 @@ def test_add_file_signer_empty def test_add_file_simple Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_simple 'x', 0644, 10 do |io| + @tar_writer.add_file_simple "x", 0644, 10 do |io| io.write "a" * 10 end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.now), @io.string[0, 512]) assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] @@ -178,20 +178,20 @@ def test_add_file_simple def test_add_file_simple_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_simple 'x', 0644, 10 do |io| + @tar_writer.add_file_simple "x", 0644, 10 do |io| io.write "a" * 10 end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), + assert_headers_equal(tar_file_header("x", "", 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), @io.string[0, 512]) end end def test_add_file_simple_padding Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_simple 'x', 0, 100 + @tar_writer.add_file_simple "x", 0, 100 - assert_headers_equal tar_file_header('x', '', 0, 100, Time.now), + assert_headers_equal tar_file_header("x", "", 0, 100, Time.now), @io.string[0, 512] end @@ -222,34 +222,34 @@ def test_close e = assert_raise IOError do @tar_writer.close end - assert_equal 'closed Gem::Package::TarWriter', e.message + assert_equal "closed Gem::Package::TarWriter", e.message e = assert_raise IOError do @tar_writer.flush end - assert_equal 'closed Gem::Package::TarWriter', e.message + assert_equal "closed Gem::Package::TarWriter", e.message e = assert_raise IOError do - @tar_writer.add_file 'x', 0 + @tar_writer.add_file "x", 0 end - assert_equal 'closed Gem::Package::TarWriter', e.message + assert_equal "closed Gem::Package::TarWriter", e.message e = assert_raise IOError do - @tar_writer.add_file_simple 'x', 0, 0 + @tar_writer.add_file_simple "x", 0, 0 end - assert_equal 'closed Gem::Package::TarWriter', e.message + assert_equal "closed Gem::Package::TarWriter", e.message e = assert_raise IOError do - @tar_writer.mkdir 'x', 0 + @tar_writer.mkdir "x", 0 end - assert_equal 'closed Gem::Package::TarWriter', e.message + assert_equal "closed Gem::Package::TarWriter", e.message end def test_mkdir Time.stub :now, Time.at(1458518157) do - @tar_writer.mkdir 'foo', 0644 + @tar_writer.mkdir "foo", 0644 - assert_headers_equal tar_dir_header('foo', '', 0644, Time.now), + assert_headers_equal tar_dir_header("foo", "", 0644, Time.now), @io.string[0, 512] assert_equal 512, @io.pos @@ -259,42 +259,42 @@ def test_mkdir def test_mkdir_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" Time.stub :now, Time.at(1458518157) do - @tar_writer.mkdir 'foo', 0644 + @tar_writer.mkdir "foo", 0644 - assert_headers_equal tar_dir_header('foo', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), + assert_headers_equal tar_dir_header("foo", "", 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), @io.string[0, 512] end end def test_split_name - assert_equal ['b' * 100, 'a' * 155], + assert_equal ["b" * 100, "a" * 155], @tar_writer.split_name("#{'a' * 155}/#{'b' * 100}") - assert_equal ["#{'qwer/' * 19}bla", 'a' * 151], + assert_equal ["#{'qwer/' * 19}bla", "a" * 151], @tar_writer.split_name("#{'a' * 151}/#{'qwer/' * 19}bla") names = [ - ([''] + ['123456789'] * 9 + ['1234567890']).join('/'), # 101 bytes (several pieces) - (['123456789'] * 9 + ['1234567890'] + ['']).join('/'), # 101 bytes (several pieces) - '/' * 99, - '/' * 100, - '/' * 101, - '/' * 102, + ([""] + ["123456789"] * 9 + ["1234567890"]).join("/"), # 101 bytes (several pieces) + (["123456789"] * 9 + ["1234567890"] + [""]).join("/"), # 101 bytes (several pieces) + "/" * 99, + "/" * 100, + "/" * 101, + "/" * 102, ] names.each do |name| newname, prefix = @tar_writer.split_name(name) assert(!(newname.empty?), "split_name() returned empty name") assert(newname.bytesize <= 100, "split_name() returned name longer than 100 bytes: '#{newname}' for '#{name}'") assert(prefix.bytesize <= 155, "split_name() returned prefix longer than 155 bytes: '#{prefix}' for '#{name}'") - newname = [prefix, newname].join('/') unless prefix.empty? + newname = [prefix, newname].join("/") unless prefix.empty? assert_equal name, newname end end def test_split_name_too_long_name - name = File.join 'a', 'b' * 100 - assert_equal ['b' * 100, 'a'], @tar_writer.split_name(name) + name = File.join "a", "b" * 100 + assert_equal ["b" * 100, "a"], @tar_writer.split_name(name) - name = File.join 'a', 'b' * 101 + name = File.join "a", "b" * 101 exception = assert_raise Gem::Package::TooLongFileName do @tar_writer.split_name name end @@ -302,7 +302,7 @@ def test_split_name_too_long_name # note, GNU tar 1.28 is unable to handle this case too, # tested with "tar --format=ustar -cPf /tmp/foo.tartar -- /aaaaaa....a" - name = '/' + 'a' * 100 + name = "/" + "a" * 100 exception = assert_raise Gem::Package::TooLongFileName do @tar_writer.split_name name end @@ -310,10 +310,10 @@ def test_split_name_too_long_name end def test_split_name_too_long_prefix - name = File.join 'a' * 155, 'b' - assert_equal ['b', 'a' * 155], @tar_writer.split_name(name) + name = File.join "a" * 155, "b" + assert_equal ["b", "a" * 155], @tar_writer.split_name(name) - name = File.join 'a' * 156, 'b' + name = File.join "a" * 156, "b" exception = assert_raise Gem::Package::TooLongFileName do @tar_writer.split_name name end @@ -321,7 +321,7 @@ def test_split_name_too_long_prefix end def test_split_name_too_long_total - name = 'a' * 257 + name = "a" * 257 exception = assert_raise Gem::Package::TooLongFileName do @tar_writer.split_name name end diff --git a/test/rubygems/test_gem_package_task.rb b/test/rubygems/test_gem_package_task.rb index 0cedfe56ebea..65fb818d7a19 100644 --- a/test/rubygems/test_gem_package_task.rb +++ b/test/rubygems/test_gem_package_task.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems' +require_relative "helper" +require "rubygems" begin - require 'rubygems/package_task' + require "rubygems/package_task" rescue LoadError => e - raise unless e.path == 'rake/packagetask' + raise unless e.path == "rake/packagetask" end unless defined?(Rake::PackageTask) - warn 'Skipping Gem::PackageTask tests. rake not found.' + warn "Skipping Gem::PackageTask tests. rake not found." end class TestGemPackageTask < Gem::TestCase @@ -23,7 +23,7 @@ def test_gem_package g.authors = %w[author] g.files = %w[x] - g.summary = 'summary' + g.summary = "summary" end Rake.application = Rake::Application.new @@ -35,12 +35,12 @@ def test_gem_package assert_equal %w[x y], pkg.package_files Dir.chdir @tempdir do - FileUtils.touch 'x' - FileUtils.touch 'y' + FileUtils.touch "x" + FileUtils.touch "y" - Rake.application['package'].invoke + Rake.application["package"].invoke - assert_path_exist 'pkg/pkgr-1.2.3.gem' + assert_path_exist "pkg/pkgr-1.2.3.gem" end ensure RakeFileUtils.verbose_flag = original_rake_fileutils_verbosity @@ -53,7 +53,7 @@ def test_gem_package_prints_to_stdout_by_default g.authors = %w[author] g.files = %w[x] - g.summary = 'summary' + g.summary = "summary" end _, err = capture_output do @@ -66,10 +66,10 @@ def test_gem_package_prints_to_stdout_by_default assert_equal %w[x y], pkg.package_files Dir.chdir @tempdir do - FileUtils.touch 'x' - FileUtils.touch 'y' + FileUtils.touch "x" + FileUtils.touch "y" - Rake.application['package'].invoke + Rake.application["package"].invoke end end @@ -104,14 +104,14 @@ def test_gem_package_with_ruby_platform def test_package_dir_path gem = Gem::Specification.new do |g| - g.name = 'nokogiri' - g.version = '1.5.0' - g.platform = 'java' + g.name = "nokogiri" + g.version = "1.5.0" + g.platform = "java" end pkg = Gem::PackageTask.new gem pkg.define - assert_equal 'pkg/nokogiri-1.5.0-java', pkg.package_dir_path + assert_equal "pkg/nokogiri-1.5.0-java", pkg.package_dir_path end end if defined?(Rake::PackageTask) diff --git a/test/rubygems/test_gem_path_support.rb b/test/rubygems/test_gem_path_support.rb index 394cba2b7f2e..fa0e3990befa 100644 --- a/test/rubygems/test_gem_path_support.rb +++ b/test/rubygems/test_gem_path_support.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems' -require 'fileutils' +require_relative "helper" +require "rubygems" +require "fileutils" class TestGemPathSupport < Gem::TestCase def setup @@ -25,7 +25,7 @@ def test_initialize_home assert_equal File.join(@tempdir, "foo"), ps.home - expected = ENV["GEM_PATH"].split(File::PATH_SEPARATOR) + [File.join(@tempdir, 'foo')] + expected = ENV["GEM_PATH"].split(File::PATH_SEPARATOR) + [File.join(@tempdir, "foo")] assert_equal expected, ps.path end @@ -45,8 +45,8 @@ def test_initialize_path assert_equal ENV["GEM_HOME"], ps.home expected = [ - File.join(@tempdir, 'foo'), - File.join(@tempdir, 'bar'), + File.join(@tempdir, "foo"), + File.join(@tempdir, "bar"), ENV["GEM_HOME"], ] @@ -65,8 +65,8 @@ def test_initialize_regexp_path_separator assert_equal ENV["GEM_HOME"], ps.home expected = [ - File.join(@tempdir, 'foo'), - File.join(@tempdir, 'bar'), + File.join(@tempdir, "foo"), + File.join(@tempdir, "bar"), ] + Gem.default_path << ENV["GEM_HOME"] assert_equal expected, ps.path @@ -83,8 +83,8 @@ def test_initialize_path_with_defaults assert_equal ENV["GEM_HOME"], ps.home expected = [ - File.join(@tempdir, 'foo'), - File.join(@tempdir, 'bar'), + File.join(@tempdir, "foo"), + File.join(@tempdir, "bar"), ] + Gem.default_path << ENV["GEM_HOME"] assert_equal expected, ps.path @@ -97,7 +97,7 @@ def test_initialize_home_path assert_equal File.join(@tempdir, "foo"), ps.home - expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')] + expected = [File.join(@tempdir, "foo"), File.join(@tempdir, "bar")] assert_equal expected, ps.path end end @@ -108,12 +108,12 @@ def test_initialize_spec ps = Gem::PathSupport.new ENV assert_equal Gem.default_spec_cache_dir, ps.spec_cache_dir - ENV["GEM_SPEC_CACHE"] = 'bar' + ENV["GEM_SPEC_CACHE"] = "bar" ps = Gem::PathSupport.new ENV assert_equal ENV["GEM_SPEC_CACHE"], ps.spec_cache_dir - ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache' + ENV["GEM_SPEC_CACHE"] = File.join @tempdir, "spec_cache" ps = Gem::PathSupport.new "GEM_SPEC_CACHE" => "foo" assert_equal "foo", ps.spec_cache_dir @@ -126,7 +126,7 @@ def test_gem_paths_do_not_contain_symlinks begin File.symlink(dir, symlink) rescue NotImplementedError, SystemCallError - pend 'symlinks not supported' + pend "symlinks not supported" end not_existing = "#{@tempdir}/does_not_exist" path = "#{symlink}#{File::PATH_SEPARATOR}#{not_existing}" diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb index b9202ab7be0f..0fb5bf59a521 100644 --- a/test/rubygems/test_gem_platform.rb +++ b/test/rubygems/test_gem_platform.rb @@ -1,47 +1,47 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/platform' -require 'rbconfig' +require_relative "helper" +require "rubygems/platform" +require "rbconfig" class TestGemPlatform < Gem::TestCase def test_self_local - util_set_arch 'i686-darwin8.10.1' + util_set_arch "i686-darwin8.10.1" assert_equal Gem::Platform.new(%w[x86 darwin 8]), Gem::Platform.local end def test_self_match Gem::Deprecate.skip_during do - assert Gem::Platform.match(nil), 'nil == ruby' - assert Gem::Platform.match(Gem::Platform.local), 'exact match' - assert Gem::Platform.match(Gem::Platform.local.to_s), '=~ match' - assert Gem::Platform.match(Gem::Platform::RUBY), 'ruby' + assert Gem::Platform.match(nil), "nil == ruby" + assert Gem::Platform.match(Gem::Platform.local), "exact match" + assert Gem::Platform.match(Gem::Platform.local.to_s), "=~ match" + assert Gem::Platform.match(Gem::Platform::RUBY), "ruby" end end def test_self_match_gem? - assert Gem::Platform.match_gem?(nil, 'json'), 'nil == ruby' - assert Gem::Platform.match_gem?(Gem::Platform.local, 'json'), 'exact match' - assert Gem::Platform.match_gem?(Gem::Platform.local.to_s, 'json'), '=~ match' - assert Gem::Platform.match_gem?(Gem::Platform::RUBY, 'json'), 'ruby' + assert Gem::Platform.match_gem?(nil, "json"), "nil == ruby" + assert Gem::Platform.match_gem?(Gem::Platform.local, "json"), "exact match" + assert Gem::Platform.match_gem?(Gem::Platform.local.to_s, "json"), "=~ match" + assert Gem::Platform.match_gem?(Gem::Platform::RUBY, "json"), "ruby" end def test_self_match_spec? make_spec = -> platform do - util_spec 'mygem-for-platform-match_spec', '1' do |s| + util_spec "mygem-for-platform-match_spec", "1" do |s| s.platform = platform end end - assert Gem::Platform.match_spec?(make_spec.call(nil)), 'nil == ruby' - assert Gem::Platform.match_spec?(make_spec.call(Gem::Platform.local)), 'exact match' - assert Gem::Platform.match_spec?(make_spec.call(Gem::Platform.local.to_s)), '=~ match' - assert Gem::Platform.match_spec?(make_spec.call(Gem::Platform::RUBY)), 'ruby' + assert Gem::Platform.match_spec?(make_spec.call(nil)), "nil == ruby" + assert Gem::Platform.match_spec?(make_spec.call(Gem::Platform.local)), "exact match" + assert Gem::Platform.match_spec?(make_spec.call(Gem::Platform.local.to_s)), "=~ match" + assert Gem::Platform.match_spec?(make_spec.call(Gem::Platform::RUBY)), "ruby" end def test_self_match_spec_with_match_gem_override make_spec = -> name, platform do - util_spec name, '1' do |s| + util_spec name, "1" do |s| s.platform = platform end end @@ -50,7 +50,7 @@ class << Gem::Platform alias_method :original_match_gem?, :match_gem? def match_gem?(platform, gem_name) # e.g., sassc and libv8 are such gems, their native extensions do not use the Ruby C API - if gem_name == 'gem-with-ruby-impl-independent-precompiled-ext' + if gem_name == "gem-with-ruby-impl-independent-precompiled-ext" match_platforms?(platform, [Gem::Platform::RUBY, Gem::Platform.local]) else match_platforms?(platform, Gem.platforms) @@ -61,10 +61,10 @@ def match_gem?(platform, gem_name) platforms = Gem.platforms Gem.platforms = [Gem::Platform::RUBY] begin - assert_equal true, Gem::Platform.match_spec?(make_spec.call('mygem', Gem::Platform::RUBY)) - assert_equal false, Gem::Platform.match_spec?(make_spec.call('mygem', Gem::Platform.local)) + assert_equal true, Gem::Platform.match_spec?(make_spec.call("mygem", Gem::Platform::RUBY)) + assert_equal false, Gem::Platform.match_spec?(make_spec.call("mygem", Gem::Platform.local)) - name = 'gem-with-ruby-impl-independent-precompiled-ext' + name = "gem-with-ruby-impl-independent-precompiled-ext" assert_equal true, Gem::Platform.match_spec?(make_spec.call(name, Gem::Platform.local)) ensure Gem.platforms = platforms @@ -80,65 +80,65 @@ def test_self_new assert_equal Gem::Platform.local, Gem::Platform.new(Gem::Platform::CURRENT) assert_equal Gem::Platform::RUBY, Gem::Platform.new(Gem::Platform::RUBY) assert_equal Gem::Platform::RUBY, Gem::Platform.new(nil) - assert_equal Gem::Platform::RUBY, Gem::Platform.new('') + assert_equal Gem::Platform::RUBY, Gem::Platform.new("") end def test_initialize test_cases = { - 'amd64-freebsd6' => ['amd64', 'freebsd', '6'], - 'hppa2.0w-hpux11.31' => ['hppa2.0w', 'hpux', '11'], - 'java' => [nil, 'java', nil], - 'jruby' => [nil, 'java', nil], - 'universal-dotnet' => ['universal', 'dotnet', nil], - 'universal-dotnet2.0' => ['universal', 'dotnet', '2.0'], - 'universal-dotnet4.0' => ['universal', 'dotnet', '4.0'], - 'powerpc-aix5.3.0.0' => ['powerpc', 'aix', '5'], - 'powerpc-darwin7' => ['powerpc', 'darwin', '7'], - 'powerpc-darwin8' => ['powerpc', 'darwin', '8'], - 'powerpc-linux' => ['powerpc', 'linux', nil], - 'powerpc64-linux' => ['powerpc64', 'linux', nil], - 'sparc-solaris2.10' => ['sparc', 'solaris', '2.10'], - 'sparc-solaris2.8' => ['sparc', 'solaris', '2.8'], - 'sparc-solaris2.9' => ['sparc', 'solaris', '2.9'], - 'universal-darwin8' => ['universal', 'darwin', '8'], - 'universal-darwin9' => ['universal', 'darwin', '9'], - 'universal-macruby' => ['universal', 'macruby', nil], - 'i386-cygwin' => ['x86', 'cygwin', nil], - 'i686-darwin' => ['x86', 'darwin', nil], - 'i686-darwin8.4.1' => ['x86', 'darwin', '8'], - 'i386-freebsd4.11' => ['x86', 'freebsd', '4'], - 'i386-freebsd5' => ['x86', 'freebsd', '5'], - 'i386-freebsd6' => ['x86', 'freebsd', '6'], - 'i386-freebsd7' => ['x86', 'freebsd', '7'], - 'i386-freebsd' => ['x86', 'freebsd', nil], - 'universal-freebsd' => ['universal', 'freebsd', nil], - 'i386-java1.5' => ['x86', 'java', '1.5'], - 'x86-java1.6' => ['x86', 'java', '1.6'], - 'i386-java1.6' => ['x86', 'java', '1.6'], - 'i686-linux' => ['x86', 'linux', nil], - 'i586-linux' => ['x86', 'linux', nil], - 'i486-linux' => ['x86', 'linux', nil], - 'i386-linux' => ['x86', 'linux', nil], - 'i586-linux-gnu' => ['x86', 'linux', nil], - 'i386-linux-gnu' => ['x86', 'linux', nil], - 'i386-mingw32' => ['x86', 'mingw32', nil], - 'x64-mingw-ucrt' => ['x64', 'mingw', 'ucrt'], - 'i386-mswin32' => ['x86', 'mswin32', nil], - 'i386-mswin32_80' => ['x86', 'mswin32', '80'], - 'i386-mswin32-80' => ['x86', 'mswin32', '80'], - 'x86-mswin32' => ['x86', 'mswin32', nil], - 'x86-mswin32_60' => ['x86', 'mswin32', '60'], - 'x86-mswin32-60' => ['x86', 'mswin32', '60'], - 'i386-netbsdelf' => ['x86', 'netbsdelf', nil], - 'i386-openbsd4.0' => ['x86', 'openbsd', '4.0'], - 'i386-solaris2.10' => ['x86', 'solaris', '2.10'], - 'i386-solaris2.8' => ['x86', 'solaris', '2.8'], - 'mswin32' => ['x86', 'mswin32', nil], - 'x86_64-linux' => ['x86_64', 'linux', nil], - 'x86_64-linux-musl' => ['x86_64', 'linux', 'musl'], - 'x86_64-openbsd3.9' => ['x86_64', 'openbsd', '3.9'], - 'x86_64-openbsd4.0' => ['x86_64', 'openbsd', '4.0'], - 'x86_64-openbsd' => ['x86_64', 'openbsd', nil], + "amd64-freebsd6" => ["amd64", "freebsd", "6"], + "hppa2.0w-hpux11.31" => ["hppa2.0w", "hpux", "11"], + "java" => [nil, "java", nil], + "jruby" => [nil, "java", nil], + "universal-dotnet" => ["universal", "dotnet", nil], + "universal-dotnet2.0" => ["universal", "dotnet", "2.0"], + "universal-dotnet4.0" => ["universal", "dotnet", "4.0"], + "powerpc-aix5.3.0.0" => ["powerpc", "aix", "5"], + "powerpc-darwin7" => ["powerpc", "darwin", "7"], + "powerpc-darwin8" => ["powerpc", "darwin", "8"], + "powerpc-linux" => ["powerpc", "linux", nil], + "powerpc64-linux" => ["powerpc64", "linux", nil], + "sparc-solaris2.10" => ["sparc", "solaris", "2.10"], + "sparc-solaris2.8" => ["sparc", "solaris", "2.8"], + "sparc-solaris2.9" => ["sparc", "solaris", "2.9"], + "universal-darwin8" => ["universal", "darwin", "8"], + "universal-darwin9" => ["universal", "darwin", "9"], + "universal-macruby" => ["universal", "macruby", nil], + "i386-cygwin" => ["x86", "cygwin", nil], + "i686-darwin" => ["x86", "darwin", nil], + "i686-darwin8.4.1" => ["x86", "darwin", "8"], + "i386-freebsd4.11" => ["x86", "freebsd", "4"], + "i386-freebsd5" => ["x86", "freebsd", "5"], + "i386-freebsd6" => ["x86", "freebsd", "6"], + "i386-freebsd7" => ["x86", "freebsd", "7"], + "i386-freebsd" => ["x86", "freebsd", nil], + "universal-freebsd" => ["universal", "freebsd", nil], + "i386-java1.5" => ["x86", "java", "1.5"], + "x86-java1.6" => ["x86", "java", "1.6"], + "i386-java1.6" => ["x86", "java", "1.6"], + "i686-linux" => ["x86", "linux", nil], + "i586-linux" => ["x86", "linux", nil], + "i486-linux" => ["x86", "linux", nil], + "i386-linux" => ["x86", "linux", nil], + "i586-linux-gnu" => ["x86", "linux", nil], + "i386-linux-gnu" => ["x86", "linux", nil], + "i386-mingw32" => ["x86", "mingw32", nil], + "x64-mingw-ucrt" => ["x64", "mingw", "ucrt"], + "i386-mswin32" => ["x86", "mswin32", nil], + "i386-mswin32_80" => ["x86", "mswin32", "80"], + "i386-mswin32-80" => ["x86", "mswin32", "80"], + "x86-mswin32" => ["x86", "mswin32", nil], + "x86-mswin32_60" => ["x86", "mswin32", "60"], + "x86-mswin32-60" => ["x86", "mswin32", "60"], + "i386-netbsdelf" => ["x86", "netbsdelf", nil], + "i386-openbsd4.0" => ["x86", "openbsd", "4.0"], + "i386-solaris2.10" => ["x86", "solaris", "2.10"], + "i386-solaris2.8" => ["x86", "solaris", "2.8"], + "mswin32" => ["x86", "mswin32", nil], + "x86_64-linux" => ["x86_64", "linux", nil], + "x86_64-linux-musl" => ["x86_64", "linux", "musl"], + "x86_64-openbsd3.9" => ["x86_64", "openbsd", "3.9"], + "x86_64-openbsd4.0" => ["x86_64", "openbsd", "4.0"], + "x86_64-openbsd" => ["x86_64", "openbsd", nil], } test_cases.each do |arch, expected| @@ -148,67 +148,67 @@ def test_initialize end def test_initialize_command_line - expected = ['x86', 'mswin32', nil] + expected = ["x86", "mswin32", nil] - platform = Gem::Platform.new 'i386-mswin32' + platform = Gem::Platform.new "i386-mswin32" - assert_equal expected, platform.to_a, 'i386-mswin32' + assert_equal expected, platform.to_a, "i386-mswin32" - expected = ['x86', 'mswin32', '80'] + expected = ["x86", "mswin32", "80"] - platform = Gem::Platform.new 'i386-mswin32-80' + platform = Gem::Platform.new "i386-mswin32-80" - assert_equal expected, platform.to_a, 'i386-mswin32-80' + assert_equal expected, platform.to_a, "i386-mswin32-80" - expected = ['x86', 'solaris', '2.10'] + expected = ["x86", "solaris", "2.10"] - platform = Gem::Platform.new 'i386-solaris-2.10' + platform = Gem::Platform.new "i386-solaris-2.10" - assert_equal expected, platform.to_a, 'i386-solaris-2.10' + assert_equal expected, platform.to_a, "i386-solaris-2.10" end def test_initialize_mswin32_vc6 - orig_RUBY_SO_NAME = RbConfig::CONFIG['RUBY_SO_NAME'] - RbConfig::CONFIG['RUBY_SO_NAME'] = 'msvcrt-ruby18' + orig_RUBY_SO_NAME = RbConfig::CONFIG["RUBY_SO_NAME"] + RbConfig::CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18" - expected = ['x86', 'mswin32', nil] + expected = ["x86", "mswin32", nil] - platform = Gem::Platform.new 'i386-mswin32' + platform = Gem::Platform.new "i386-mswin32" - assert_equal expected, platform.to_a, 'i386-mswin32 VC6' + assert_equal expected, platform.to_a, "i386-mswin32 VC6" ensure if orig_RUBY_SO_NAME - RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME + RbConfig::CONFIG["RUBY_SO_NAME"] = orig_RUBY_SO_NAME else - RbConfig::CONFIG.delete 'RUBY_SO_NAME' + RbConfig::CONFIG.delete "RUBY_SO_NAME" end end def test_initialize_platform - platform = Gem::Platform.new 'cpu-my_platform1' + platform = Gem::Platform.new "cpu-my_platform1" - assert_equal 'cpu', platform.cpu - assert_equal 'my_platform', platform.os - assert_equal '1', platform.version + assert_equal "cpu", platform.cpu + assert_equal "my_platform", platform.os + assert_equal "1", platform.version end def test_initialize_test - platform = Gem::Platform.new 'cpu-my_platform1' - assert_equal 'cpu', platform.cpu - assert_equal 'my_platform', platform.os - assert_equal '1', platform.version - - platform = Gem::Platform.new 'cpu-other_platform1' - assert_equal 'cpu', platform.cpu - assert_equal 'other_platform', platform.os - assert_equal '1', platform.version + platform = Gem::Platform.new "cpu-my_platform1" + assert_equal "cpu", platform.cpu + assert_equal "my_platform", platform.os + assert_equal "1", platform.version + + platform = Gem::Platform.new "cpu-other_platform1" + assert_equal "cpu", platform.cpu + assert_equal "other_platform", platform.os + assert_equal "1", platform.version end def test_to_s if win_platform? - assert_equal 'x86-mswin32-60', Gem::Platform.local.to_s + assert_equal "x86-mswin32-60", Gem::Platform.local.to_s else - assert_equal 'x86-darwin-8', Gem::Platform.local.to_s + assert_equal "x86-darwin-8", Gem::Platform.local.to_s end end @@ -231,146 +231,146 @@ def test_equals3 end def test_equals3_cpu - ppc_darwin8 = Gem::Platform.new 'powerpc-darwin8.0' - uni_darwin8 = Gem::Platform.new 'universal-darwin8.0' - x86_darwin8 = Gem::Platform.new 'i686-darwin8.0' - - util_set_arch 'powerpc-darwin8' - assert((ppc_darwin8 === Gem::Platform.local), 'powerpc =~ universal') - assert((uni_darwin8 === Gem::Platform.local), 'powerpc =~ universal') - refute((x86_darwin8 === Gem::Platform.local), 'powerpc =~ universal') - - util_set_arch 'i686-darwin8' - refute((ppc_darwin8 === Gem::Platform.local), 'powerpc =~ universal') - assert((uni_darwin8 === Gem::Platform.local), 'x86 =~ universal') - assert((x86_darwin8 === Gem::Platform.local), 'powerpc =~ universal') - - util_set_arch 'universal-darwin8' - assert((ppc_darwin8 === Gem::Platform.local), 'universal =~ ppc') - assert((uni_darwin8 === Gem::Platform.local), 'universal =~ universal') - assert((x86_darwin8 === Gem::Platform.local), 'universal =~ x86') + ppc_darwin8 = Gem::Platform.new "powerpc-darwin8.0" + uni_darwin8 = Gem::Platform.new "universal-darwin8.0" + x86_darwin8 = Gem::Platform.new "i686-darwin8.0" + + util_set_arch "powerpc-darwin8" + assert((ppc_darwin8 === Gem::Platform.local), "powerpc =~ universal") + assert((uni_darwin8 === Gem::Platform.local), "powerpc =~ universal") + refute((x86_darwin8 === Gem::Platform.local), "powerpc =~ universal") + + util_set_arch "i686-darwin8" + refute((ppc_darwin8 === Gem::Platform.local), "powerpc =~ universal") + assert((uni_darwin8 === Gem::Platform.local), "x86 =~ universal") + assert((x86_darwin8 === Gem::Platform.local), "powerpc =~ universal") + + util_set_arch "universal-darwin8" + assert((ppc_darwin8 === Gem::Platform.local), "universal =~ ppc") + assert((uni_darwin8 === Gem::Platform.local), "universal =~ universal") + assert((x86_darwin8 === Gem::Platform.local), "universal =~ x86") end def test_nil_cpu_arch_is_treated_as_universal - with_nil_arch = Gem::Platform.new [nil, 'mingw32'] - with_uni_arch = Gem::Platform.new ['universal', 'mingw32'] - with_x86_arch = Gem::Platform.new ['x86', 'mingw32'] - - assert((with_nil_arch === with_uni_arch), 'nil =~ universal') - assert((with_uni_arch === with_nil_arch), 'universal =~ nil') - assert((with_nil_arch === with_x86_arch), 'nil =~ x86') - assert((with_x86_arch === with_nil_arch), 'x86 =~ nil') + with_nil_arch = Gem::Platform.new [nil, "mingw32"] + with_uni_arch = Gem::Platform.new ["universal", "mingw32"] + with_x86_arch = Gem::Platform.new ["x86", "mingw32"] + + assert((with_nil_arch === with_uni_arch), "nil =~ universal") + assert((with_uni_arch === with_nil_arch), "universal =~ nil") + assert((with_nil_arch === with_x86_arch), "nil =~ x86") + assert((with_x86_arch === with_nil_arch), "x86 =~ nil") end def test_equals3_cpu_arm - arm = Gem::Platform.new 'arm-linux' - armv5 = Gem::Platform.new 'armv5-linux' - armv7 = Gem::Platform.new 'armv7-linux' - - util_set_arch 'armv5-linux' - assert((arm === Gem::Platform.local), 'arm === armv5') - assert((armv5 === Gem::Platform.local), 'armv5 === armv5') - refute((armv7 === Gem::Platform.local), 'armv7 === armv5') - refute((Gem::Platform.local === arm), 'armv5 === arm') - - util_set_arch 'armv7-linux' - assert((arm === Gem::Platform.local), 'arm === armv7') - refute((armv5 === Gem::Platform.local), 'armv5 === armv7') - assert((armv7 === Gem::Platform.local), 'armv7 === armv7') - refute((Gem::Platform.local === arm), 'armv7 === arm') + arm = Gem::Platform.new "arm-linux" + armv5 = Gem::Platform.new "armv5-linux" + armv7 = Gem::Platform.new "armv7-linux" + + util_set_arch "armv5-linux" + assert((arm === Gem::Platform.local), "arm === armv5") + assert((armv5 === Gem::Platform.local), "armv5 === armv5") + refute((armv7 === Gem::Platform.local), "armv7 === armv5") + refute((Gem::Platform.local === arm), "armv5 === arm") + + util_set_arch "armv7-linux" + assert((arm === Gem::Platform.local), "arm === armv7") + refute((armv5 === Gem::Platform.local), "armv5 === armv7") + assert((armv7 === Gem::Platform.local), "armv7 === armv7") + refute((Gem::Platform.local === arm), "armv7 === arm") end def test_equals3_universal_mingw - uni_mingw = Gem::Platform.new 'universal-mingw' - mingw32 = Gem::Platform.new 'x64-mingw32' - mingw_ucrt = Gem::Platform.new 'x64-mingw-ucrt' - - util_set_arch 'x64-mingw32' - assert((uni_mingw === Gem::Platform.local), 'uni_mingw === mingw32') - assert((mingw32 === Gem::Platform.local), 'mingw32 === mingw32') - refute((mingw_ucrt === Gem::Platform.local), 'mingw32 === mingw_ucrt') - - util_set_arch 'x64-mingw-ucrt' - assert((uni_mingw === Gem::Platform.local), 'uni_mingw === mingw32') - assert((mingw_ucrt === Gem::Platform.local), 'mingw_ucrt === mingw_ucrt') - refute((mingw32 === Gem::Platform.local), 'mingw32 === mingw_ucrt') + uni_mingw = Gem::Platform.new "universal-mingw" + mingw32 = Gem::Platform.new "x64-mingw32" + mingw_ucrt = Gem::Platform.new "x64-mingw-ucrt" + + util_set_arch "x64-mingw32" + assert((uni_mingw === Gem::Platform.local), "uni_mingw === mingw32") + assert((mingw32 === Gem::Platform.local), "mingw32 === mingw32") + refute((mingw_ucrt === Gem::Platform.local), "mingw32 === mingw_ucrt") + + util_set_arch "x64-mingw-ucrt" + assert((uni_mingw === Gem::Platform.local), "uni_mingw === mingw32") + assert((mingw_ucrt === Gem::Platform.local), "mingw_ucrt === mingw_ucrt") + refute((mingw32 === Gem::Platform.local), "mingw32 === mingw_ucrt") end def test_equals3_version - util_set_arch 'i686-darwin8' + util_set_arch "i686-darwin8" - x86_darwin = Gem::Platform.new ['x86', 'darwin', nil] - x86_darwin7 = Gem::Platform.new ['x86', 'darwin', '7'] - x86_darwin8 = Gem::Platform.new ['x86', 'darwin', '8'] - x86_darwin9 = Gem::Platform.new ['x86', 'darwin', '9'] + x86_darwin = Gem::Platform.new ["x86", "darwin", nil] + x86_darwin7 = Gem::Platform.new ["x86", "darwin", "7"] + x86_darwin8 = Gem::Platform.new ["x86", "darwin", "8"] + x86_darwin9 = Gem::Platform.new ["x86", "darwin", "9"] - assert((x86_darwin === Gem::Platform.local), 'x86_darwin === x86_darwin8') - assert((x86_darwin8 === Gem::Platform.local), 'x86_darwin8 === x86_darwin8') + assert((x86_darwin === Gem::Platform.local), "x86_darwin === x86_darwin8") + assert((x86_darwin8 === Gem::Platform.local), "x86_darwin8 === x86_darwin8") - refute((x86_darwin7 === Gem::Platform.local), 'x86_darwin7 === x86_darwin8') - refute((x86_darwin9 === Gem::Platform.local), 'x86_darwin9 === x86_darwin8') + refute((x86_darwin7 === Gem::Platform.local), "x86_darwin7 === x86_darwin8") + refute((x86_darwin9 === Gem::Platform.local), "x86_darwin9 === x86_darwin8") end def test_equals_tilde - util_set_arch 'i386-mswin32' + util_set_arch "i386-mswin32" - assert_local_match 'mswin32' - assert_local_match 'i386-mswin32' + assert_local_match "mswin32" + assert_local_match "i386-mswin32" # oddballs - assert_local_match 'i386-mswin32-mq5.3' - assert_local_match 'i386-mswin32-mq6' - refute_local_match 'win32-1.8.2-VC7' - refute_local_match 'win32-1.8.4-VC6' - refute_local_match 'win32-source' - refute_local_match 'windows' - - util_set_arch 'i686-linux' - assert_local_match 'i486-linux' - assert_local_match 'i586-linux' - assert_local_match 'i686-linux' - - util_set_arch 'i686-darwin8' - assert_local_match 'i686-darwin8.4.1' - assert_local_match 'i686-darwin8.8.2' - - util_set_arch 'java' - assert_local_match 'java' - assert_local_match 'jruby' - - util_set_arch 'universal-dotnet2.0' - assert_local_match 'universal-dotnet' - assert_local_match 'universal-dotnet-2.0' - refute_local_match 'universal-dotnet-4.0' - assert_local_match 'dotnet' - assert_local_match 'dotnet-2.0' - refute_local_match 'dotnet-4.0' - - util_set_arch 'universal-dotnet4.0' - assert_local_match 'universal-dotnet' - refute_local_match 'universal-dotnet-2.0' - assert_local_match 'universal-dotnet-4.0' - assert_local_match 'dotnet' - refute_local_match 'dotnet-2.0' - assert_local_match 'dotnet-4.0' - - util_set_arch 'universal-macruby-1.0' - assert_local_match 'universal-macruby' - assert_local_match 'macruby' - refute_local_match 'universal-macruby-0.10' - assert_local_match 'universal-macruby-1.0' - - util_set_arch 'powerpc-darwin' - assert_local_match 'powerpc-darwin' - - util_set_arch 'powerpc-darwin7' - assert_local_match 'powerpc-darwin7.9.0' - - util_set_arch 'powerpc-darwin8' - assert_local_match 'powerpc-darwin8.10.0' - - util_set_arch 'sparc-solaris2.8' - assert_local_match 'sparc-solaris2.8-mq5.3' + assert_local_match "i386-mswin32-mq5.3" + assert_local_match "i386-mswin32-mq6" + refute_local_match "win32-1.8.2-VC7" + refute_local_match "win32-1.8.4-VC6" + refute_local_match "win32-source" + refute_local_match "windows" + + util_set_arch "i686-linux" + assert_local_match "i486-linux" + assert_local_match "i586-linux" + assert_local_match "i686-linux" + + util_set_arch "i686-darwin8" + assert_local_match "i686-darwin8.4.1" + assert_local_match "i686-darwin8.8.2" + + util_set_arch "java" + assert_local_match "java" + assert_local_match "jruby" + + util_set_arch "universal-dotnet2.0" + assert_local_match "universal-dotnet" + assert_local_match "universal-dotnet-2.0" + refute_local_match "universal-dotnet-4.0" + assert_local_match "dotnet" + assert_local_match "dotnet-2.0" + refute_local_match "dotnet-4.0" + + util_set_arch "universal-dotnet4.0" + assert_local_match "universal-dotnet" + refute_local_match "universal-dotnet-2.0" + assert_local_match "universal-dotnet-4.0" + assert_local_match "dotnet" + refute_local_match "dotnet-2.0" + assert_local_match "dotnet-4.0" + + util_set_arch "universal-macruby-1.0" + assert_local_match "universal-macruby" + assert_local_match "macruby" + refute_local_match "universal-macruby-0.10" + assert_local_match "universal-macruby-1.0" + + util_set_arch "powerpc-darwin" + assert_local_match "powerpc-darwin" + + util_set_arch "powerpc-darwin7" + assert_local_match "powerpc-darwin7.9.0" + + util_set_arch "powerpc-darwin8" + assert_local_match "powerpc-darwin8.10.0" + + util_set_arch "sparc-solaris2.8" + assert_local_match "sparc-solaris2.8-mq5.3" end def test_inspect diff --git a/test/rubygems/test_gem_rdoc.rb b/test/rubygems/test_gem_rdoc.rb index 7b8ad07b276e..7a3454236009 100644 --- a/test/rubygems/test_gem_rdoc.rb +++ b/test/rubygems/test_gem_rdoc.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'rubygems' -require_relative 'helper' -require 'rubygems/rdoc' +require "rubygems" +require_relative "helper" +require "rubygems/rdoc" class TestGemRDoc < Gem::TestCase Gem::RDoc.load_rdoc @@ -9,13 +9,13 @@ class TestGemRDoc < Gem::TestCase def setup super - @a = util_spec 'a' do |s| + @a = util_spec "a" do |s| s.rdoc_options = %w[--main MyTitle] s.extra_rdoc_files = %w[README] end - write_file File.join(@tempdir, 'lib', 'a.rb') - write_file File.join(@tempdir, 'README') + write_file File.join(@tempdir, "lib", "a.rb") + write_file File.join(@tempdir, "README") install_gem @a @@ -70,14 +70,14 @@ def test_new_rdoc def test_rdoc_installed? refute @hook.rdoc_installed? - FileUtils.mkdir_p @a.doc_dir 'rdoc' + FileUtils.mkdir_p @a.doc_dir "rdoc" assert @hook.rdoc_installed? end def test_remove - FileUtils.mkdir_p @a.doc_dir 'rdoc' - FileUtils.mkdir_p @a.doc_dir 'ri' + FileUtils.mkdir_p @a.doc_dir "rdoc" + FileUtils.mkdir_p @a.doc_dir "ri" @hook.remove @@ -88,8 +88,8 @@ def test_remove end def test_remove_unwritable - pend 'chmod not supported' if Gem.win_platform? - pend 'skipped in root privilege' if Process.uid.zero? + pend "chmod not supported" if Gem.win_platform? + pend "skipped in root privilege" if Process.uid.zero? FileUtils.mkdir_p @a.base_dir FileUtils.chmod 0, @a.base_dir @@ -105,7 +105,7 @@ def test_remove_unwritable def test_ri_installed? refute @hook.ri_installed? - FileUtils.mkdir_p @a.doc_dir 'ri' + FileUtils.mkdir_p @a.doc_dir "ri" assert @hook.ri_installed? end @@ -117,8 +117,8 @@ def test_setup end def test_setup_unwritable - pend 'chmod not supported' if Gem.win_platform? - pend 'skipped in root privilege' if Process.uid.zero? + pend "chmod not supported" if Gem.win_platform? + pend "skipped in root privilege" if Process.uid.zero? FileUtils.mkdir_p @a.doc_dir FileUtils.chmod 0, @a.doc_dir diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index fa82a117a18b..d8b55a5f7aa3 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" -require 'webrick' -require 'webrick/https' if Gem::HAVE_OPENSSL +require "webrick" +require "webrick/https" if Gem::HAVE_OPENSSL unless Gem::HAVE_OPENSSL - warn 'Skipping Gem::RemoteFetcher tests. openssl not found.' + warn "Skipping Gem::RemoteFetcher tests. openssl not found." end -require 'rubygems/remote_fetcher' -require 'rubygems/package' +require "rubygems/remote_fetcher" +require "rubygems/package" # = Testing Proxy Settings # @@ -69,7 +69,7 @@ class TestGemRemoteFetcher < Gem::TestCase dependencies: [] EOY - PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, '0.4.2') + PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, "0.4.2") # Generated via: # x = OpenSSL::PKey::DH.new(2048) # wait a while... @@ -104,11 +104,11 @@ def setup @cache_dir = File.join @gemhome, "cache" # TODO: why does the remote fetcher need it written to disk? - @a1, @a1_gem = util_gem 'a', '1' do |s| - s.executables << 'a_bin' + @a1, @a1_gem = util_gem "a", "1" do |s| + s.executables << "a_bin" end - @a1.loaded_from = File.join(@gemhome, 'specifications', @a1.full_name) + @a1.loaded_from = File.join(@gemhome, "specifications", @a1.full_name) Gem::RemoteFetcher.fetcher = nil @stub_ui = Gem::MockGemUi.new @@ -130,7 +130,7 @@ def test_self_fetcher end def test_self_fetcher_with_proxy - proxy_uri = 'http://proxy.example.com' + proxy_uri = "http://proxy.example.com" Gem.configuration[:http_proxy] = proxy_uri Gem::RemoteFetcher.fetcher = nil @@ -149,34 +149,34 @@ def test_fetch_path_bad_uri @fetcher.fetch_path("gems.example.com/yaml", nil, true) end - assert_equal 'uri scheme is invalid: nil', e.message + assert_equal "uri scheme is invalid: nil", e.message end def test_no_proxy use_ui @stub_ui do assert_data_from_server @fetcher.fetch_path(@server_uri) response = @fetcher.fetch_path(@server_uri, nil, true) - assert_equal SERVER_DATA.size, response['content-length'].to_i + assert_equal SERVER_DATA.size, response["content-length"].to_i end end def test_cache_update_path - uri = URI 'http://example/file' - path = File.join @tempdir, 'file' + uri = URI "http://example/file" + path = File.join @tempdir, "file" - fetcher = util_fuck_with_fetcher 'hello' + fetcher = util_fuck_with_fetcher "hello" data = fetcher.cache_update_path uri, path - assert_equal 'hello', data + assert_equal "hello", data - assert_equal 'hello', File.read(path) + assert_equal "hello", File.read(path) end def test_cache_update_path_with_utf8_internal_encoding - with_internal_encoding('UTF-8') do - uri = URI 'http://example/file' - path = File.join @tempdir, 'file' + with_internal_encoding("UTF-8") do + uri = URI "http://example/file" + path = File.join @tempdir, "file" data = String.new("\xC8").force_encoding(Encoding::BINARY) fetcher = util_fuck_with_fetcher data @@ -189,14 +189,14 @@ def test_cache_update_path_with_utf8_internal_encoding end def test_cache_update_path_no_update - uri = URI 'http://example/file' - path = File.join @tempdir, 'file' + uri = URI "http://example/file" + path = File.join @tempdir, "file" - fetcher = util_fuck_with_fetcher 'hello' + fetcher = util_fuck_with_fetcher "hello" data = fetcher.cache_update_path uri, path, false - assert_equal 'hello', data + assert_equal "hello", data assert_path_not_exist path end @@ -219,7 +219,7 @@ def self.fetch_path(arg, *rest) @test_data end - raise Gem::RemoteFetcher::FetchError.new("haha!", '') + raise Gem::RemoteFetcher::FetchError.new("haha!", "") end end @@ -228,14 +228,14 @@ def self.fetch_path(arg, *rest) def test_download a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end fetcher = util_fuck_with_fetcher a1_data a1_cache_gem = @a1.cache_file - assert_equal a1_cache_gem, fetcher.download(@a1, 'http://gems.example.com') + assert_equal a1_cache_gem, fetcher.download(@a1, "http://gems.example.com") assert_equal("http://gems.example.com/gems/a-1.gem", fetcher.instance_variable_get(:@test_arg).to_s) assert File.exist?(a1_cache_gem) @@ -243,14 +243,14 @@ def test_download def test_download_with_auth a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end fetcher = util_fuck_with_fetcher a1_data a1_cache_gem = @a1.cache_file - assert_equal a1_cache_gem, fetcher.download(@a1, 'http://user:password@gems.example.com') + assert_equal a1_cache_gem, fetcher.download(@a1, "http://user:password@gems.example.com") assert_equal("http://user:password@gems.example.com/gems/a-1.gem", fetcher.instance_variable_get(:@test_arg).to_s) assert File.exist?(a1_cache_gem) @@ -258,14 +258,14 @@ def test_download_with_auth def test_download_with_token a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end fetcher = util_fuck_with_fetcher a1_data a1_cache_gem = @a1.cache_file - assert_equal a1_cache_gem, fetcher.download(@a1, 'http://token@gems.example.com') + assert_equal a1_cache_gem, fetcher.download(@a1, "http://token@gems.example.com") assert_equal("http://token@gems.example.com/gems/a-1.gem", fetcher.instance_variable_get(:@test_arg).to_s) assert File.exist?(a1_cache_gem) @@ -273,14 +273,14 @@ def test_download_with_token def test_download_with_x_oauth_basic a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end fetcher = util_fuck_with_fetcher a1_data a1_cache_gem = @a1.cache_file - assert_equal a1_cache_gem, fetcher.download(@a1, 'http://token:x-oauth-basic@gems.example.com') + assert_equal a1_cache_gem, fetcher.download(@a1, "http://token:x-oauth-basic@gems.example.com") assert_equal("http://token:x-oauth-basic@gems.example.com/gems/a-1.gem", fetcher.instance_variable_get(:@test_arg).to_s) assert File.exist?(a1_cache_gem) @@ -288,14 +288,14 @@ def test_download_with_x_oauth_basic def test_download_with_encoded_auth a1_data = nil - File.open @a1_gem, 'rb' do |fp| + File.open @a1_gem, "rb" do |fp| a1_data = fp.read end fetcher = util_fuck_with_fetcher a1_data a1_cache_gem = @a1.cache_file - assert_equal a1_cache_gem, fetcher.download(@a1, 'http://user:%25pas%25sword@gems.example.com') + assert_equal a1_cache_gem, fetcher.download(@a1, "http://user:%25pas%25sword@gems.example.com") assert_equal("http://user:%25pas%25sword@gems.example.com/gems/a-1.gem", fetcher.instance_variable_get(:@test_arg).to_s) assert File.exist?(a1_cache_gem) @@ -306,7 +306,7 @@ def test_download_cached inst = Gem::RemoteFetcher.fetcher - assert_equal @a1.cache_file, inst.download(@a1, 'http://gems.example.com') + assert_equal @a1.cache_file, inst.download(@a1, "http://gems.example.com") end def test_download_local @@ -322,7 +322,7 @@ def test_download_local end def test_download_local_space - space_path = File.join @tempdir, 'space path' + space_path = File.join @tempdir, "space path" FileUtils.mkdir space_path FileUtils.mv @a1_gem, space_path local_path = File.join space_path, @a1.file_name @@ -336,17 +336,17 @@ def test_download_local_space end def test_download_install_dir - a1_data = File.open @a1_gem, 'rb' do |fp| + a1_data = File.open @a1_gem, "rb" do |fp| fp.read end fetcher = util_fuck_with_fetcher a1_data - install_dir = File.join @tempdir, 'more_gems' + install_dir = File.join @tempdir, "more_gems" a1_cache_gem = File.join install_dir, "cache", @a1.file_name FileUtils.mkdir_p(File.dirname(a1_cache_gem)) - actual = fetcher.download(@a1, 'http://gems.example.com', install_dir) + actual = fetcher.download(@a1, "http://gems.example.com", install_dir) assert_equal a1_cache_gem, actual assert_equal("http://gems.example.com/gems/a-1.gem", @@ -380,7 +380,7 @@ def test_download_read_only FileUtils.chmod 0555, @gemhome fetcher = util_fuck_with_fetcher File.read(@a1_gem) - fetcher.download(@a1, 'http://gems.example.com') + fetcher.download(@a1, "http://gems.example.com") a1_cache_gem = File.join Gem.user_dir, "cache", @a1.file_name assert File.exist? a1_cache_gem ensure @@ -390,16 +390,16 @@ def test_download_read_only end def test_download_platform_legacy - original_platform = 'old-platform' + original_platform = "old-platform" - e1, e1_gem = util_gem 'e', '1' do |s| + e1, e1_gem = util_gem "e", "1" do |s| s.platform = Gem::Platform::CURRENT s.instance_variable_set :@original_platform, original_platform end - e1.loaded_from = File.join(@gemhome, 'specifications', e1.full_name) + e1.loaded_from = File.join(@gemhome, "specifications", e1.full_name) e1_data = nil - File.open e1_gem, 'rb' do |fp| + File.open e1_gem, "rb" do |fp| e1_data = fp.read end @@ -407,7 +407,7 @@ def test_download_platform_legacy e1_cache_gem = e1.cache_file - assert_equal e1_cache_gem, fetcher.download(e1, 'http://gems.example.com') + assert_equal e1_cache_gem, fetcher.download(e1, "http://gems.example.com") assert_equal("http://gems.example.com/gems/#{e1.original_name}.gem", fetcher.instance_variable_get(:@test_arg).to_s) @@ -435,14 +435,14 @@ def test_download_unsupported inst = Gem::RemoteFetcher.fetcher e = assert_raise ArgumentError do - inst.download @a1, 'ftp://gems.rubyforge.org' + inst.download @a1, "ftp://gems.rubyforge.org" end - assert_equal 'unsupported URI scheme ftp', e.message + assert_equal "unsupported URI scheme ftp", e.message end def test_download_to_cache - @a2, @a2_gem = util_gem 'a', '2' + @a2, @a2_gem = util_gem "a", "2" util_setup_spec_fetcher @a1, @a2 @fetcher.instance_variable_set :@a1, @a1 @@ -458,7 +458,7 @@ def @fetcher.fetch_path(uri, mtime = nil, head = false) end end - gem = Gem::RemoteFetcher.fetcher.download_to_cache dep 'a' + gem = Gem::RemoteFetcher.fetcher.download_to_cache dep "a" assert_equal @a2.file_name, File.basename(gem) end @@ -468,10 +468,10 @@ def test_fetch_path_gzip @fetcher = fetcher def fetcher.fetch_http(uri, mtime, head = nil) - Gem::Util.gzip 'foo' + Gem::Util.gzip "foo" end - assert_equal 'foo', fetcher.fetch_path(@uri + 'foo.gz') + assert_equal "foo", fetcher.fetch_path(@uri + "foo.gz") end def test_fetch_path_gzip_unmodified @@ -482,7 +482,7 @@ def fetcher.fetch_http(uri, mtime, head = nil) nil end - assert_nil fetcher.fetch_path(@uri + 'foo.gz', Time.at(0)) + assert_nil fetcher.fetch_path(@uri + "foo.gz", Time.at(0)) end def test_fetch_path_io_error @@ -493,7 +493,7 @@ def fetcher.fetch_http(*) raise EOFError end - url = 'http://example.com/uri' + url = "http://example.com/uri" e = assert_raise Gem::RemoteFetcher::FetchError do fetcher.fetch_path url @@ -511,7 +511,7 @@ def fetcher.fetch_http(uri, mtime, head = nil) raise SocketError end - url = 'http://example.com/uri' + url = "http://example.com/uri" e = assert_raise Gem::RemoteFetcher::FetchError do fetcher.fetch_path url @@ -526,10 +526,10 @@ def test_fetch_path_system_call_error @fetcher = fetcher def fetcher.fetch_http(uri, mtime = nil, head = nil) - raise Errno::ECONNREFUSED, 'connect(2)' + raise Errno::ECONNREFUSED, "connect(2)" end - url = 'http://example.com/uri' + url = "http://example.com/uri" e = assert_raise Gem::RemoteFetcher::FetchError do fetcher.fetch_path url @@ -545,10 +545,10 @@ def test_fetch_path_timeout_error @fetcher = fetcher def fetcher.fetch_http(uri, mtime = nil, head = nil) - raise Timeout::Error, 'timed out' + raise Timeout::Error, "timed out" end - url = 'http://example.com/uri' + url = "http://example.com/uri" e = assert_raise Gem::RemoteFetcher::FetchError do fetcher.fetch_path url @@ -564,10 +564,10 @@ def test_fetch_path_getaddrinfo_error @fetcher = fetcher def fetcher.fetch_http(uri, mtime = nil, head = nil) - raise SocketError, 'getaddrinfo: nodename nor servname provided' + raise SocketError, "getaddrinfo: nodename nor servname provided" end - url = 'http://example.com/uri' + url = "http://example.com/uri" e = assert_raise Gem::RemoteFetcher::FetchError do fetcher.fetch_path url @@ -586,7 +586,7 @@ def fetcher.fetch_http(uri, mtime = nil, head = nil) raise OpenSSL::SSL::SSLError end - url = 'http://example.com/uri' + url = "http://example.com/uri" e = assert_raise Gem::RemoteFetcher::FetchError do fetcher.fetch_path url @@ -609,7 +609,7 @@ def fetcher.fetch_http(uri, mtime, head = nil) def test_implicit_no_proxy use_ui @stub_ui do - ENV['http_proxy'] = 'http://fakeurl:12345' + ENV["http_proxy"] = "http://fakeurl:12345" fetcher = Gem::RemoteFetcher.new :no_proxy @fetcher = fetcher assert_data_from_server fetcher.fetch_path(@server_uri) @@ -618,7 +618,7 @@ def test_implicit_no_proxy def test_implicit_proxy use_ui @stub_ui do - ENV['http_proxy'] = @proxy_uri + ENV["http_proxy"] = @proxy_uri fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher assert_data_from_proxy fetcher.fetch_path(@server_uri) @@ -627,7 +627,7 @@ def test_implicit_proxy def test_implicit_upper_case_proxy use_ui @stub_ui do - ENV['HTTP_PROXY'] = @proxy_uri + ENV["HTTP_PROXY"] = @proxy_uri fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher assert_data_from_proxy fetcher.fetch_path(@server_uri) @@ -645,36 +645,36 @@ def test_implicit_proxy_no_env def test_fetch_http fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher - url = 'http://gems.example.com/redirect' + url = "http://gems.example.com/redirect" def fetcher.request(uri, request_class, last_modified = nil) - url = 'http://gems.example.com/redirect' + url = "http://gems.example.com/redirect" unless defined? @requested @requested = true res = Net::HTTPMovedPermanently.new nil, 301, nil - res.add_field 'Location', url + res.add_field "Location", url res else res = Net::HTTPOK.new nil, 200, nil - def res.body() 'real_path' end + def res.body() "real_path" end res end end data = fetcher.fetch_http URI.parse(url) - assert_equal 'real_path', data + assert_equal "real_path", data end def test_fetch_http_redirects fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher - url = 'http://gems.example.com/redirect' + url = "http://gems.example.com/redirect" def fetcher.request(uri, request_class, last_modified = nil) - url = 'http://gems.example.com/redirect' + url = "http://gems.example.com/redirect" res = Net::HTTPMovedPermanently.new nil, 301, nil - res.add_field 'Location', url + res.add_field "Location", url res end @@ -688,7 +688,7 @@ def fetcher.request(uri, request_class, last_modified = nil) def test_fetch_http_redirects_without_location fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher - url = 'http://gems.example.com/redirect' + url = "http://gems.example.com/redirect" def fetcher.request(uri, request_class, last_modified = nil) res = Net::HTTPMovedPermanently.new nil, 301, nil @@ -710,7 +710,7 @@ def test_fetch_http_with_additional_headers assert_equal "murphy", fetcher.fetch_path(@server_uri) end - def assert_fetch_s3(url, signature, token=nil, region='us-east-1', instance_profile_json=nil) + def assert_fetch_s3(url, signature, token=nil, region="us-east-1", instance_profile_json=nil) fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher $fetched_uri = nil @@ -719,12 +719,12 @@ def assert_fetch_s3(url, signature, token=nil, region='us-east-1', instance_prof def fetcher.request(uri, request_class, last_modified = nil) $fetched_uri = uri res = Net::HTTPOK.new nil, 200, nil - def res.body() 'success' end + def res.body() "success" end res end def fetcher.s3_uri_signer(uri) - require 'json' + require "json" s3_uri_signer = Gem::S3URISigner.new(uri) def s3_uri_signer.ec2_metadata_credentials_json JSON.parse($instance_profile) @@ -738,18 +738,18 @@ def s3_uri_signer.ec2_metadata_credentials_json data = fetcher.fetch_s3 URI.parse(url) assert_equal "https://my-bucket.s3.#{region}.amazonaws.com/gems/specs.4.8.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=testuser%2F20190624%2F#{region}%2Fs3%2Faws4_request&X-Amz-Date=20190624T050641Z&X-Amz-Expires=86400#{token ? "&X-Amz-Security-Token=" + token : ""}&X-Amz-SignedHeaders=host&X-Amz-Signature=#{signature}", $fetched_uri.to_s - assert_equal 'success', data + assert_equal "success", data ensure $fetched_uri = nil end def test_fetch_s3_config_creds Gem.configuration[:s3_source] = { - 'my-bucket' => { :id => 'testuser', :secret => 'testpass' }, + "my-bucket" => { :id => "testuser", :secret => "testpass" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b' + assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b" end ensure Gem.configuration[:s3_source] = nil @@ -757,11 +757,11 @@ def test_fetch_s3_config_creds def test_fetch_s3_config_creds_with_region Gem.configuration[:s3_source] = { - 'my-bucket' => { :id => 'testuser', :secret => 'testpass', :region => 'us-west-2' }, + "my-bucket" => { :id => "testuser", :secret => "testpass", :region => "us-west-2" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2' + assert_fetch_s3 url, "4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9", nil, "us-west-2" end ensure Gem.configuration[:s3_source] = nil @@ -769,79 +769,79 @@ def test_fetch_s3_config_creds_with_region def test_fetch_s3_config_creds_with_token Gem.configuration[:s3_source] = { - 'my-bucket' => { :id => 'testuser', :secret => 'testpass', :security_token => 'testtoken' }, + "my-bucket" => { :id => "testuser", :secret => "testpass", :security_token => "testtoken" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken' + assert_fetch_s3 url, "935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c", "testtoken" end ensure Gem.configuration[:s3_source] = nil end def test_fetch_s3_env_creds - ENV['AWS_ACCESS_KEY_ID'] = 'testuser' - ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass' - ENV['AWS_SESSION_TOKEN'] = nil + ENV["AWS_ACCESS_KEY_ID"] = "testuser" + ENV["AWS_SECRET_ACCESS_KEY"] = "testpass" + ENV["AWS_SESSION_TOKEN"] = nil Gem.configuration[:s3_source] = { - 'my-bucket' => { :provider => 'env' }, + "my-bucket" => { :provider => "env" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b' + assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b" end ensure - ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS') } + ENV.each_key {|key| ENV.delete(key) if key.start_with?("AWS") } Gem.configuration[:s3_source] = nil end def test_fetch_s3_env_creds_with_region - ENV['AWS_ACCESS_KEY_ID'] = 'testuser' - ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass' - ENV['AWS_SESSION_TOKEN'] = nil + ENV["AWS_ACCESS_KEY_ID"] = "testuser" + ENV["AWS_SECRET_ACCESS_KEY"] = "testpass" + ENV["AWS_SESSION_TOKEN"] = nil Gem.configuration[:s3_source] = { - 'my-bucket' => { :provider => 'env', :region => 'us-west-2' }, + "my-bucket" => { :provider => "env", :region => "us-west-2" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2' + assert_fetch_s3 url, "4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9", nil, "us-west-2" end ensure - ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS') } + ENV.each_key {|key| ENV.delete(key) if key.start_with?("AWS") } Gem.configuration[:s3_source] = nil end def test_fetch_s3_env_creds_with_token - ENV['AWS_ACCESS_KEY_ID'] = 'testuser' - ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass' - ENV['AWS_SESSION_TOKEN'] = 'testtoken' + ENV["AWS_ACCESS_KEY_ID"] = "testuser" + ENV["AWS_SECRET_ACCESS_KEY"] = "testpass" + ENV["AWS_SESSION_TOKEN"] = "testtoken" Gem.configuration[:s3_source] = { - 'my-bucket' => { :provider => 'env' }, + "my-bucket" => { :provider => "env" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken' + assert_fetch_s3 url, "935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c", "testtoken" end ensure - ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS') } + ENV.each_key {|key| ENV.delete(key) if key.start_with?("AWS") } Gem.configuration[:s3_source] = nil end def test_fetch_s3_url_creds - url = 's3://testuser:testpass@my-bucket/gems/specs.4.8.gz' + url = "s3://testuser:testpass@my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b' + assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b" end end def test_fetch_s3_instance_profile_creds Gem.configuration[:s3_source] = { - 'my-bucket' => { :provider => 'instance_profile' }, + "my-bucket" => { :provider => "instance_profile" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b', nil, 'us-east-1', + assert_fetch_s3 url, "20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b", nil, "us-east-1", '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}' end ensure @@ -850,12 +850,12 @@ def test_fetch_s3_instance_profile_creds def test_fetch_s3_instance_profile_creds_with_region Gem.configuration[:s3_source] = { - 'my-bucket' => { :provider => 'instance_profile', :region => 'us-west-2' }, + "my-bucket" => { :provider => "instance_profile", :region => "us-west-2" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2', + assert_fetch_s3 url, "4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9", nil, "us-west-2", '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}' end ensure @@ -864,12 +864,12 @@ def test_fetch_s3_instance_profile_creds_with_region def test_fetch_s3_instance_profile_creds_with_token Gem.configuration[:s3_source] = { - 'my-bucket' => { :provider => 'instance_profile' }, + "my-bucket" => { :provider => "instance_profile" }, } - url = 's3://my-bucket/gems/specs.4.8.gz' + url = "s3://my-bucket/gems/specs.4.8.gz" Time.stub :now, Time.at(1561353581) do - assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken', 'us-east-1', + assert_fetch_s3 url, "935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c", "testtoken", "us-east-1", '{"AccessKeyId": "testuser", "SecretAccessKey": "testpass", "Token": "testtoken"}' end ensure @@ -888,35 +888,35 @@ def refute_fetch_s3(url, expected_message) end def test_fetch_s3_no_source_key - url = 's3://my-bucket/gems/specs.4.8.gz' - refute_fetch_s3 url, 'no s3_source key exists in .gemrc' + url = "s3://my-bucket/gems/specs.4.8.gz" + refute_fetch_s3 url, "no s3_source key exists in .gemrc" end def test_fetch_s3_no_host Gem.configuration[:s3_source] = { - 'my-bucket' => { :id => 'testuser', :secret => 'testpass' }, + "my-bucket" => { :id => "testuser", :secret => "testpass" }, } - url = 's3://other-bucket/gems/specs.4.8.gz' - refute_fetch_s3 url, 'no key for host other-bucket in s3_source in .gemrc' + url = "s3://other-bucket/gems/specs.4.8.gz" + refute_fetch_s3 url, "no key for host other-bucket in s3_source in .gemrc" ensure Gem.configuration[:s3_source] = nil end def test_fetch_s3_no_id - Gem.configuration[:s3_source] = { 'my-bucket' => { :secret => 'testpass' } } + Gem.configuration[:s3_source] = { "my-bucket" => { :secret => "testpass" } } - url = 's3://my-bucket/gems/specs.4.8.gz' - refute_fetch_s3 url, 's3_source for my-bucket missing id or secret' + url = "s3://my-bucket/gems/specs.4.8.gz" + refute_fetch_s3 url, "s3_source for my-bucket missing id or secret" ensure Gem.configuration[:s3_source] = nil end def test_fetch_s3_no_secret - Gem.configuration[:s3_source] = { 'my-bucket' => { :id => 'testuser' } } + Gem.configuration[:s3_source] = { "my-bucket" => { :id => "testuser" } } - url = 's3://my-bucket/gems/specs.4.8.gz' - refute_fetch_s3 url, 's3_source for my-bucket missing id or secret' + url = "s3://my-bucket/gems/specs.4.8.gz" + refute_fetch_s3 url, "s3_source for my-bucket missing id or secret" ensure Gem.configuration[:s3_source] = nil end @@ -946,7 +946,7 @@ def test_request_block @fetcher = fetcher assert_throws :block_called do - fetcher.request URI('http://example'), Net::HTTP::Get do |req| + fetcher.request URI("http://example"), Net::HTTP::Get do |req| assert_kind_of Net::HTTPGenericRequest, req throw :block_called end @@ -964,7 +964,7 @@ def test_yaml_error_on_size def test_ssl_connection ssl_server = start_ssl_server - temp_ca_cert = File.join(__dir__, 'ca_cert.pem') + temp_ca_cert = File.join(__dir__, "ca_cert.pem") with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher| fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml") end @@ -975,8 +975,8 @@ def test_ssl_client_cert_auth_connection :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT }) - temp_ca_cert = File.join(__dir__, 'ca_cert.pem') - temp_client_cert = File.join(__dir__, 'client.pem') + temp_ca_cert = File.join(__dir__, "ca_cert.pem") + temp_client_cert = File.join(__dir__, "client.pem") with_configured_fetcher( ":ssl_ca_cert: #{temp_ca_cert}\n" + @@ -990,8 +990,8 @@ def test_do_not_allow_invalid_client_cert_auth_connection :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT }) - temp_ca_cert = File.join(__dir__, 'ca_cert.pem') - temp_client_cert = File.join(__dir__, 'invalid_client.pem') + temp_ca_cert = File.join(__dir__, "ca_cert.pem") + temp_client_cert = File.join(__dir__, "invalid_client.pem") with_configured_fetcher( ":ssl_ca_cert: #{temp_ca_cert}\n" + @@ -1020,7 +1020,7 @@ def test_ssl_connection_allow_verify_none def test_do_not_follow_insecure_redirect ssl_server = start_ssl_server - temp_ca_cert = File.join(__dir__, 'ca_cert.pem') + temp_ca_cert = File.join(__dir__, "ca_cert.pem") expected_error_message = "redirecting to non-https resource: #{@server_uri} (https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri})" @@ -1046,8 +1046,8 @@ def test_nil_ca_cert def with_configured_fetcher(config_str = nil, &block) if config_str - temp_conf = File.join @tempdir, '.gemrc' - File.open temp_conf, 'w' do |fp| + temp_conf = File.join @tempdir, ".gemrc" + File.open temp_conf, "w" do |fp| fp.puts config_str end Gem.configuration = Gem::ConfigFile.new %W[--config-file #{temp_conf}] @@ -1136,9 +1136,9 @@ def start_ssl_server(config = {}) :Logger => null_logger, :AccessLog => [], :SSLEnable => true, - :SSLCACertificateFile => File.join(__dir__, 'ca_cert.pem'), - :SSLCertificate => cert('ssl_cert.pem'), - :SSLPrivateKey => key('ssl_key.pem'), + :SSLCACertificateFile => File.join(__dir__, "ca_cert.pem"), + :SSLCertificate => cert("ssl_cert.pem"), + :SSLPrivateKey => key("ssl_key.pem"), :SSLVerifyClient => nil, :SSLCertName => nil, }.merge(config)) @@ -1146,7 +1146,7 @@ def start_ssl_server(config = {}) res.body = "--- true\n" end server.mount_proc("/insecure_redirect") do |req, res| - res.set_redirect(WEBrick::HTTPStatus::MovedPermanently, req.query['to']) + res.set_redirect(WEBrick::HTTPStatus::MovedPermanently, req.query["to"]) end server.ssl_context.tmp_dh_callback = proc { TEST_KEY_DH2048 } t = Thread.new do @@ -1185,22 +1185,22 @@ def start_server(data) res.body = req["X-Captain"] elsif @enable_yaml res.body = data - res['Content-Type'] = 'text/plain' - res['content-length'] = data.size + res["Content-Type"] = "text/plain" + res["content-length"] = data.size else res.status = "404" res.body = "

NOT FOUND

" - res['Content-Type'] = 'text/html' + res["Content-Type"] = "text/html" end end s.mount_proc("/yaml.Z") do |req, res| if @enable_zip res.body = Zlib::Deflate.deflate(data) - res['Content-Type'] = 'text/plain' + res["Content-Type"] = "text/plain" else res.status = "404" res.body = "

NOT FOUND

" - res['Content-Type'] = 'text/html' + res["Content-Type"] = "text/html" end end th = Thread.new do diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb index 47654f6fa417..aba9dc54479b 100644 --- a/test/rubygems/test_gem_request.rb +++ b/test/rubygems/test_gem_request.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request' -require 'ostruct' -require 'base64' +require_relative "helper" +require "rubygems/request" +require "ostruct" +require "base64" unless Gem::HAVE_OPENSSL - warn 'Skipping Gem::Request tests. openssl not found.' + warn "Skipping Gem::Request tests. openssl not found." end class TestGemRequest < Gem::TestCase - CA_CERT_FILE = cert_path 'ca' - CHILD_CERT = load_cert 'child' - EXPIRED_CERT = load_cert 'expired' - PUBLIC_CERT = load_cert 'public' - PUBLIC_CERT_FILE = cert_path 'public' - SSL_CERT = load_cert 'ssl' + CA_CERT_FILE = cert_path "ca" + CHILD_CERT = load_cert "child" + EXPIRED_CERT = load_cert "expired" + PUBLIC_CERT = load_cert "public" + PUBLIC_CERT_FILE = cert_path "public" + SSL_CERT = load_cert "ssl" def make_request(uri, request_class, last_modified, proxy) Gem::Request.create_with_proxy uri, request_class, last_modified, proxy @@ -28,7 +28,7 @@ def setup super @proxy_uri = "http://localhost:1234" - @uri = URI('http://example') + @uri = URI("http://example") @request = make_request @uri, nil, nil, nil end @@ -40,7 +40,7 @@ def teardown end def test_initialize_proxy - proxy_uri = 'http://proxy.example.com' + proxy_uri = "http://proxy.example.com" request = make_request @uri, nil, nil, proxy_uri @@ -48,7 +48,7 @@ def test_initialize_proxy end def test_initialize_proxy_URI - proxy_uri = 'http://proxy.example.com' + proxy_uri = "http://proxy.example.com" request = make_request @uri, nil, nil, URI(proxy_uri) @@ -56,22 +56,22 @@ def test_initialize_proxy_URI end def test_initialize_proxy_ENV - ENV['http_proxy'] = @proxy_uri - ENV['http_proxy_user'] = 'foo' - ENV['http_proxy_pass'] = 'bar' + ENV["http_proxy"] = @proxy_uri + ENV["http_proxy_user"] = "foo" + ENV["http_proxy_pass"] = "bar" request = make_request @uri, nil, nil, nil proxy = request.proxy_uri - assert_equal 'foo', proxy.user - assert_equal 'bar', proxy.password + assert_equal "foo", proxy.user + assert_equal "bar", proxy.password end def test_initialize_proxy_ENV_https - ENV['https_proxy'] = @proxy_uri + ENV["https_proxy"] = @proxy_uri - request = make_request URI('https://example'), nil, nil, nil + request = make_request URI("https://example"), nil, nil, nil proxy = request.proxy_uri @@ -79,10 +79,10 @@ def test_initialize_proxy_ENV_https end def test_proxy_ENV - ENV['http_proxy'] = "http://proxy" - ENV['https_proxy'] = "" + ENV["http_proxy"] = "http://proxy" + ENV["https_proxy"] = "" - request = make_request URI('https://example'), nil, nil, nil + request = make_request URI("https://example"), nil, nil, nil proxy = request.proxy_uri @@ -90,13 +90,13 @@ def test_proxy_ENV end def test_configure_connection_for_https - connection = Net::HTTP.new 'localhost', 443 + connection = Net::HTTP.new "localhost", 443 request = Class.new(Gem::Request) do def self.get_cert_files [TestGemRequest::PUBLIC_CERT_FILE] end - end.create_with_proxy URI('https://example'), nil, nil, nil + end.create_with_proxy URI("https://example"), nil, nil, nil Gem::Request.configure_connection_for_https connection, request.cert_files @@ -109,13 +109,13 @@ def test_configure_connection_for_https_ssl_ca_cert ssl_ca_cert, Gem.configuration.ssl_ca_cert = Gem.configuration.ssl_ca_cert, CA_CERT_FILE - connection = Net::HTTP.new 'localhost', 443 + connection = Net::HTTP.new "localhost", 443 request = Class.new(Gem::Request) do def self.get_cert_files [TestGemRequest::PUBLIC_CERT_FILE] end - end.create_with_proxy URI('https://example'), nil, nil, nil + end.create_with_proxy URI("https://example"), nil, nil, nil Gem::Request.configure_connection_for_https connection, request.cert_files @@ -128,7 +128,7 @@ def self.get_cert_files end def test_get_proxy_from_env_fallback - ENV['http_proxy'] = @proxy_uri + ENV["http_proxy"] = @proxy_uri request = make_request @uri, nil, nil, nil proxy = request.proxy_uri @@ -136,8 +136,8 @@ def test_get_proxy_from_env_fallback end def test_get_proxy_from_env_https - ENV['https_proxy'] = @proxy_uri - uri = URI('https://example') + ENV["https_proxy"] = @proxy_uri + uri = URI("https://example") request = make_request uri, nil, nil, nil proxy = request.proxy_uri @@ -146,39 +146,39 @@ def test_get_proxy_from_env_https end def test_get_proxy_from_env_domain - ENV['http_proxy'] = @proxy_uri - ENV['http_proxy_user'] = 'foo\user' - ENV['http_proxy_pass'] = 'my bar' + ENV["http_proxy"] = @proxy_uri + ENV["http_proxy_user"] = 'foo\user' + ENV["http_proxy_pass"] = "my bar" request = make_request @uri, nil, nil, nil proxy = request.proxy_uri assert_equal 'foo\user', Gem::UriFormatter.new(proxy.user).unescape - assert_equal 'my bar', Gem::UriFormatter.new(proxy.password).unescape + assert_equal "my bar", Gem::UriFormatter.new(proxy.password).unescape end def test_get_proxy_from_env_escape - ENV['http_proxy'] = @proxy_uri - ENV['http_proxy_user'] = 'foo@user' - ENV['http_proxy_pass'] = 'my@bar' + ENV["http_proxy"] = @proxy_uri + ENV["http_proxy_user"] = "foo@user" + ENV["http_proxy_pass"] = "my@bar" request = make_request @uri, nil, nil, nil proxy = request.proxy_uri - assert_equal 'foo%40user', proxy.user - assert_equal 'my%40bar', proxy.password + assert_equal "foo%40user", proxy.user + assert_equal "my%40bar", proxy.password end def test_get_proxy_from_env_normalize - ENV['HTTP_PROXY'] = 'fakeurl:12345' + ENV["HTTP_PROXY"] = "fakeurl:12345" request = make_request @uri, nil, nil, nil - assert_equal 'http://fakeurl:12345', request.proxy_uri.to_s + assert_equal "http://fakeurl:12345", request.proxy_uri.to_s end def test_get_proxy_from_env_empty - ENV['HTTP_PROXY'] = '' - ENV.delete 'http_proxy' + ENV["HTTP_PROXY"] = "" + ENV.delete "http_proxy" request = make_request @uri, nil, nil, nil assert_nil request.proxy_uri @@ -207,7 +207,7 @@ def test_fetch_basic_auth c end - auth_header = conn.payload['Authorization'] + auth_header = conn.payload["Authorization"] assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header assert_includes @ui.output, "GET https://user:REDACTED@example.rubygems/specs.#{Gem.marshal_version}" end @@ -224,7 +224,7 @@ def test_fetch_basic_auth_encoded c end - auth_header = conn.payload['Authorization'] + auth_header = conn.payload["Authorization"] assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header assert_includes @ui.output, "GET https://user:REDACTED@example.rubygems/specs.#{Gem.marshal_version}" end @@ -241,36 +241,36 @@ def test_fetch_basic_oauth_encoded c end - auth_header = conn.payload['Authorization'] + auth_header = conn.payload["Authorization"] assert_equal "Basic #{Base64.encode64('{DEScede}pass:x-oauth-basic')}".strip, auth_header assert_includes @ui.output, "GET https://REDACTED:x-oauth-basic@example.rubygems/specs.#{Gem.marshal_version}" end def test_fetch_head uri = Gem::Uri.new(URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}") - response = util_stub_net_http(:body => '', :code => 200) do |conn| + response = util_stub_net_http(:body => "", :code => 200) do |conn| @request = make_request(uri, Net::HTTP::Get, nil, nil) @request.fetch end assert_equal 200, response.code - assert_equal '', response.body + assert_equal "", response.body end def test_fetch_unmodified uri = Gem::Uri.new(URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}") t = Time.utc(2013, 1, 2, 3, 4, 5) - conn, response = util_stub_net_http(:body => '', :code => 304) do |c| + conn, response = util_stub_net_http(:body => "", :code => 304) do |c| @request = make_request(uri, Net::HTTP::Get, t, nil) [c, @request.fetch] end assert_equal 304, response.code - assert_equal '', response.body + assert_equal "", response.body - modified_header = conn.payload['if-modified-since'] + modified_header = conn.payload["if-modified-since"] - assert_equal 'Wed, 02 Jan 2013 03:04:05 GMT', modified_header + assert_equal "Wed, 02 Jan 2013 03:04:05 GMT", modified_header end def test_user_agent @@ -287,7 +287,7 @@ def test_user_agent_engine util_save_version Object.send :remove_const, :RUBY_ENGINE - Object.send :const_set, :RUBY_ENGINE, 'vroom' + Object.send :const_set, :RUBY_ENGINE, "vroom" ua = make_request(@uri, nil, nil, nil).user_agent @@ -300,7 +300,7 @@ def test_user_agent_engine_ruby util_save_version Object.send :remove_const, :RUBY_ENGINE - Object.send :const_set, :RUBY_ENGINE, 'ruby' + Object.send :const_set, :RUBY_ENGINE, "ruby" ua = make_request(@uri, nil, nil, nil).user_agent diff --git a/test/rubygems/test_gem_request_connection_pools.rb b/test/rubygems/test_gem_request_connection_pools.rb index c5e7cf2ed4f0..964d5c961fa4 100644 --- a/test/rubygems/test_gem_request_connection_pools.rb +++ b/test/rubygems/test_gem_request_connection_pools.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request' -require 'timeout' +require_relative "helper" +require "rubygems/request" +require "timeout" class TestGemRequestConnectionPool < Gem::TestCase class FakeHttp @@ -17,7 +17,7 @@ def setup @old_client = Gem::Request::ConnectionPools.client Gem::Request::ConnectionPools.client = FakeHttp - @proxy = URI 'http://proxy.example' + @proxy = URI "http://proxy.example" end def teardown @@ -32,9 +32,9 @@ def test_to_proxy_substring ems.example ] - no_proxy = pools.send :no_proxy?, 'rubygems.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "rubygems.example", env_no_proxy - refute no_proxy, 'mismatch' + refute no_proxy, "mismatch" end def test_to_proxy_empty_string @@ -42,13 +42,13 @@ def test_to_proxy_empty_string env_no_proxy = [""] - no_proxy = pools.send :no_proxy?, 'ems.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "ems.example", env_no_proxy - refute no_proxy, 'mismatch' + refute no_proxy, "mismatch" end def test_checkout_same_connection - uri = URI.parse('http://example/some_endpoint') + uri = URI.parse("http://example/some_endpoint") pools = Gem::Request::ConnectionPools.new nil, [] pool = pools.pool_for uri @@ -66,13 +66,13 @@ def test_to_proxy_eh 2.no-proxy.example ] - no_proxy = pools.send :no_proxy?, '2.no-proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "2.no-proxy.example", env_no_proxy - assert no_proxy, 'match' + assert no_proxy, "match" - no_proxy = pools.send :no_proxy?, 'proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "proxy.example", env_no_proxy - refute no_proxy, 'mismatch' + refute no_proxy, "mismatch" end def test_to_proxy_eh_wildcard @@ -82,31 +82,31 @@ def test_to_proxy_eh_wildcard .no-proxy.example ] - no_proxy = pools.send :no_proxy?, '2.no-proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "2.no-proxy.example", env_no_proxy - assert no_proxy, 'wildcard matching subdomain' + assert no_proxy, "wildcard matching subdomain" - no_proxy = pools.send :no_proxy?, 'no-proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "no-proxy.example", env_no_proxy - assert no_proxy, 'wildcard matching dotless domain' + assert no_proxy, "wildcard matching dotless domain" - no_proxy = pools.send :no_proxy?, 'proxy.example', env_no_proxy + no_proxy = pools.send :no_proxy?, "proxy.example", env_no_proxy - refute no_proxy, 'wildcard mismatch' + refute no_proxy, "wildcard mismatch" end def test_net_http_args pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://example'), nil + net_http_args = pools.send :net_http_args, URI("http://example"), nil - assert_equal ['example', 80], net_http_args + assert_equal ["example", 80], net_http_args end def test_net_http_args_ipv6 pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://[::1]'), nil + net_http_args = pools.send :net_http_args, URI("http://[::1]"), nil assert_equal ["::1", 80], net_http_args end @@ -114,26 +114,26 @@ def test_net_http_args_ipv6 def test_net_http_args_proxy pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://example'), @proxy + net_http_args = pools.send :net_http_args, URI("http://example"), @proxy - assert_equal ['example', 80, 'proxy.example', 80, nil, nil], net_http_args + assert_equal ["example", 80, "proxy.example", 80, nil, nil], net_http_args end def test_net_http_args_no_proxy - orig_no_proxy, ENV['no_proxy'] = ENV['no_proxy'], 'example' + orig_no_proxy, ENV["no_proxy"] = ENV["no_proxy"], "example" pools = Gem::Request::ConnectionPools.new nil, [] - net_http_args = pools.send :net_http_args, URI('http://example'), @proxy + net_http_args = pools.send :net_http_args, URI("http://example"), @proxy - assert_equal ['example', 80, nil, nil], net_http_args + assert_equal ["example", 80, nil, nil], net_http_args ensure - ENV['no_proxy'] = orig_no_proxy + ENV["no_proxy"] = orig_no_proxy end def test_thread_waits_for_connection - uri = URI.parse('http://example/some_endpoint') + uri = URI.parse("http://example/some_endpoint") pools = Gem::Request::ConnectionPools.new nil, [] pool = pools.pool_for uri diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb index e2fe98b9bffa..6d14321126e3 100644 --- a/test/rubygems/test_gem_request_set.rb +++ b/test/rubygems/test_gem_request_set.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request_set' +require_relative "helper" +require "rubygems/request_set" class TestGemRequestSet < Gem::TestCase def setup @@ -23,24 +23,24 @@ def test_gem def test_gem_duplicate rs = Gem::RequestSet.new - rs.gem 'a', '1' - rs.gem 'a', '2' + rs.gem "a", "1" + rs.gem "a", "2" - assert_equal [dep('a', '= 1', '= 2')], rs.dependencies + assert_equal [dep("a", "= 1", "= 2")], rs.dependencies end def test_import rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" - rs.import [dep('b')] + rs.import [dep("b")] - assert_equal [dep('a'), dep('b')], rs.dependencies + assert_equal [dep("a"), dep("b")], rs.dependencies end def test_install_from_gemdeps spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end done_installing_ran = false @@ -52,7 +52,7 @@ def test_install_from_gemdeps rs = Gem::RequestSet.new installed = [] - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.puts 'gem "a"' io.flush @@ -63,9 +63,9 @@ def test_install_from_gemdeps assert_kind_of Array, result # what is supposed to be in here? end - assert_includes installed, 'a-2' - assert_path_exist File.join @gemhome, 'gems', 'a-2' - assert_path_exist 'gem.deps.rb.lock' + assert_includes installed, "a-2" + assert_path_exist File.join @gemhome, "gems", "a-2" + assert_path_exist "gem.deps.rb.lock" assert rs.remote refute done_installing_ran @@ -73,12 +73,12 @@ def test_install_from_gemdeps def test_install_from_gemdeps_explain spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end rs = Gem::RequestSet.new - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.puts 'gem "a"' io.flush @@ -96,21 +96,21 @@ def test_install_from_gemdeps_explain def test_install_from_gemdeps_install_dir spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end util_clear_gems - assert_path_not_exist File.join Gem.dir, 'gems', 'a-2' + assert_path_not_exist File.join Gem.dir, "gems", "a-2" rs = Gem::RequestSet.new installed = [] - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.puts 'gem "a"' end options = { - :gemdeps => 'gem.deps.rb', + :gemdeps => "gem.deps.rb", :install_dir => "#{@gemhome}2", } @@ -118,18 +118,18 @@ def test_install_from_gemdeps_install_dir installed << req.full_name end - assert_includes installed, 'a-2' - assert_path_not_exist File.join Gem.dir, 'gems', 'a-2' + assert_includes installed, "a-2" + assert_path_not_exist File.join Gem.dir, "gems", "a-2" end def test_install_from_gemdeps_local spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end rs = Gem::RequestSet.new - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.puts 'gem "a"' io.flush @@ -143,15 +143,15 @@ def test_install_from_gemdeps_local def test_install_from_gemdeps_lockfile spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 - fetcher.download 'b', 1, 'a' => '>= 0' + fetcher.download "a", 1 + fetcher.download "a", 2 + fetcher.download "b", 1, "a" => ">= 0" end rs = Gem::RequestSet.new installed = [] - File.open 'gem.deps.rb.lock', 'w' do |io| + File.open "gem.deps.rb.lock", "w" do |io| io.puts <<-LOCKFILE GEM remote: #{@gem_repo} @@ -168,19 +168,19 @@ def test_install_from_gemdeps_lockfile LOCKFILE end - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.puts 'gem "b"' end - rs.install_from_gemdeps :gemdeps => 'gem.deps.rb' do |req, installer| + rs.install_from_gemdeps :gemdeps => "gem.deps.rb" do |req, installer| installed << req.full_name end - assert_includes installed, 'b-1' - assert_includes installed, 'a-1' + assert_includes installed, "b-1" + assert_includes installed, "a-1" - assert_path_exist File.join @gemhome, 'specifications', 'a-1.gemspec' - assert_path_exist File.join @gemhome, 'specifications', 'b-1.gemspec' + assert_path_exist File.join @gemhome, "specifications", "a-1.gemspec" + assert_path_exist File.join @gemhome, "specifications", "b-1.gemspec" end def test_install_from_gemdeps_complex_dependencies @@ -197,7 +197,7 @@ def test_install_from_gemdeps_complex_dependencies rs = Gem::RequestSet.new installed = [] - File.open 'Gemfile.lock', 'w' do |io| + File.open "Gemfile.lock", "w" do |io| io.puts <<-LOCKFILE GEM remote: #{@gem_repo} @@ -212,7 +212,7 @@ def test_install_from_gemdeps_complex_dependencies LOCKFILE end - File.open 'testo.gemspec', 'w' do |io| + File.open "testo.gemspec", "w" do |io| io.puts <<-LOCKFILE Gem::Specification.new do |spec| spec.name = 'testo' @@ -222,28 +222,28 @@ def test_install_from_gemdeps_complex_dependencies LOCKFILE end - File.open 'Gemfile', 'w' do |io| + File.open "Gemfile", "w" do |io| io.puts("gemspec") end - rs.install_from_gemdeps :gemdeps => 'Gemfile' do |req, installer| + rs.install_from_gemdeps :gemdeps => "Gemfile" do |req, installer| installed << req.full_name end - assert_includes installed, 'z-1.0.3' + assert_includes installed, "z-1.0.3" - assert_path_exist File.join @gemhome, 'specifications', 'z-1.0.3.gemspec' + assert_path_exist File.join @gemhome, "specifications", "z-1.0.3.gemspec" end def test_install_from_gemdeps_version_mismatch spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end rs = Gem::RequestSet.new installed = [] - File.open 'gem.deps.rb', 'w' do |io| + File.open "gem.deps.rb", "w" do |io| io.puts <<-GEM_DEPS gem "a" ruby "0" @@ -256,13 +256,13 @@ def test_install_from_gemdeps_version_mismatch end end - assert_includes installed, 'a-2' + assert_includes installed, "a-2" end def test_load_gemdeps rs = Gem::RequestSet.new - tf = Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open "gem.deps.rb" do |io| io.puts 'gem "a"' io.flush @@ -273,7 +273,7 @@ def test_load_gemdeps end tf.close! - assert_equal [dep('a')], rs.dependencies + assert_equal [dep("a")], rs.dependencies assert rs.git_set assert rs.vendor_set @@ -282,7 +282,7 @@ def test_load_gemdeps def test_load_gemdeps_installing rs = Gem::RequestSet.new - tf = Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open "gem.deps.rb" do |io| io.puts 'ruby "0"' io.puts 'gem "a"' io.flush @@ -294,13 +294,13 @@ def test_load_gemdeps_installing end tf.close! - assert_equal [dep('a')], rs.dependencies + assert_equal [dep("a")], rs.dependencies end def test_load_gemdeps_without_groups rs = Gem::RequestSet.new - tf = Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open "gem.deps.rb" do |io| io.puts 'gem "a", :group => :test' io.flush @@ -332,12 +332,12 @@ def test_resolve end def test_bug_bug_990 - a = util_spec 'a', '1.b', 'b' => '~> 1.a' - b = util_spec 'b', '1.b', 'c' => '>= 1' - c = util_spec 'c', '1.1.b' + a = util_spec "a", "1.b", "b" => "~> 1.a" + b = util_spec "b", "1.b", "c" => ">= 1" + c = util_spec "c", "1.1.b" rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.prerelease = true res = rs.resolve StaticSet.new([a, b, c]) @@ -349,11 +349,11 @@ def test_bug_bug_990 end def test_resolve_development - a = util_spec 'a', 1 + a = util_spec "a", 1 spec = Gem::Resolver::SpecSpecification.new nil, a rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.development = true res = rs.resolve StaticSet.new [spec] @@ -364,22 +364,22 @@ def test_resolve_development end def test_resolve_development_shallow - a = util_spec 'a', 1 do |s| - s.add_development_dependency 'b' + a = util_spec "a", 1 do |s| + s.add_development_dependency "b" end - b = util_spec 'b', 1 do |s| - s.add_development_dependency 'c' + b = util_spec "b", 1 do |s| + s.add_development_dependency "c" end - c = util_spec 'c', 1 + c = util_spec "c", 1 a_spec = Gem::Resolver::SpecSpecification.new nil, a b_spec = Gem::Resolver::SpecSpecification.new nil, b c_spec = Gem::Resolver::SpecSpecification.new nil, c rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.development = true rs.development_shallow = true @@ -395,7 +395,7 @@ def test_resolve_git rs = Gem::RequestSet.new - tf = Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open "gem.deps.rb" do |io| io.puts <<-GEMS_DEPS_RB gem "#{name}", :git => "#{repository}" GEMS_DEPS_RB @@ -435,12 +435,12 @@ def test_resolve_ignore_dependencies end def test_resolve_incompatible - a1 = util_spec 'a', 1 - a2 = util_spec 'a', 2 + a1 = util_spec "a", 1 + a2 = util_spec "a", 2 rs = Gem::RequestSet.new - rs.gem 'a', '= 1' - rs.gem 'a', '= 2' + rs.gem "a", "= 1" + rs.gem "a", "= 2" set = StaticSet.new [a1, a2] @@ -450,15 +450,15 @@ def test_resolve_incompatible end def test_resolve_vendor - a_name, _, a_directory = vendor_gem 'a', 1 do |s| - s.add_dependency 'b', '~> 2.0' + a_name, _, a_directory = vendor_gem "a", 1 do |s| + s.add_dependency "b", "~> 2.0" end - b_name, _, b_directory = vendor_gem 'b', 2 + b_name, _, b_directory = vendor_gem "b", 2 rs = Gem::RequestSet.new - tf = Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open "gem.deps.rb" do |io| io.puts <<-GEMS_DEPS_RB gem "#{a_name}", :path => "#{a_directory}" gem "#{b_name}", :path => "#{b_directory}" @@ -509,7 +509,7 @@ def test_install end rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.resolve @@ -525,8 +525,8 @@ def test_install assert_equal %w[b-1 a-1], installers.map {|installer| installer.spec.full_name } - assert_path_exist File.join @gemhome, 'specifications', 'a-1.gemspec' - assert_path_exist File.join @gemhome, 'specifications', 'b-1.gemspec' + assert_path_exist File.join @gemhome, "specifications", "a-1.gemspec" + assert_path_exist File.join @gemhome, "specifications", "b-1.gemspec" assert_equal %w[b-1 a-1], installed.map {|s| s.full_name } @@ -545,32 +545,32 @@ def test_install_into rs.resolve installed = rs.install_into @tempdir do - assert_equal @tempdir, ENV['GEM_HOME'] + assert_equal @tempdir, ENV["GEM_HOME"] end - assert_path_exist File.join @tempdir, 'specifications', 'a-1.gemspec' - assert_path_exist File.join @tempdir, 'specifications', 'b-1.gemspec' + assert_path_exist File.join @tempdir, "specifications", "a-1.gemspec" + assert_path_exist File.join @tempdir, "specifications", "b-1.gemspec" assert_equal %w[b-1 a-1], installed.map {|s| s.full_name } end def test_install_into_development_shallow spec_fetcher do |fetcher| - fetcher.gem 'a', '1' do |s| - s.add_development_dependency 'b', '= 1' + fetcher.gem "a", "1" do |s| + s.add_development_dependency "b", "= 1" end - fetcher.gem 'b', '1' do |s| - s.add_development_dependency 'c', '= 1' + fetcher.gem "b", "1" do |s| + s.add_development_dependency "c", "= 1" end - fetcher.spec 'c', '1' + fetcher.spec "c", "1" end rs = Gem::RequestSet.new rs.development = true rs.development_shallow = true - rs.gem 'a' + rs.gem "a" rs.resolve @@ -580,25 +580,25 @@ def test_install_into_development_shallow } installed = rs.install_into @tempdir, true, options do - assert_equal @tempdir, ENV['GEM_HOME'] + assert_equal @tempdir, ENV["GEM_HOME"] end assert_equal %w[a-1 b-1], installed.map {|s| s.full_name }.sort end def test_sorted_requests_development_shallow - a = util_spec 'a', 1 do |s| - s.add_development_dependency 'b' + a = util_spec "a", 1 do |s| + s.add_development_dependency "b" end - b = util_spec 'b', 1 do |s| - s.add_development_dependency 'c' + b = util_spec "b", 1 do |s| + s.add_development_dependency "c" end - c = util_spec 'c', 1 + c = util_spec "c", 1 rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.development = true rs.development_shallow = true @@ -612,18 +612,18 @@ def test_sorted_requests_development_shallow end def test_tsort_each_child_development - a = util_spec 'a', 1 do |s| - s.add_development_dependency 'b' + a = util_spec "a", 1 do |s| + s.add_development_dependency "b" end - b = util_spec 'b', 1 do |s| - s.add_development_dependency 'c' + b = util_spec "b", 1 do |s| + s.add_development_dependency "c" end - c = util_spec 'c', 1 + c = util_spec "c", 1 rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.development = true rs.development_shallow = true @@ -641,18 +641,18 @@ def test_tsort_each_child_development end def test_tsort_each_child_development_shallow - a = util_spec 'a', 1 do |s| - s.add_development_dependency 'b' + a = util_spec "a", 1 do |s| + s.add_development_dependency "b" end - b = util_spec 'b', 1 do |s| - s.add_development_dependency 'c' + b = util_spec "b", 1 do |s| + s.add_development_dependency "c" end - c = util_spec 'c', 1 + c = util_spec "c", 1 rs = Gem::RequestSet.new - rs.gem 'a' + rs.gem "a" rs.development = true rs.development_shallow = true diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb index 14f51575e4e1..d1411ddc5643 100644 --- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb +++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request_set' +require_relative "helper" +require "rubygems/request_set" class TestGemRequestSetGemDependencyAPI < Gem::TestCase def setup @@ -13,7 +13,7 @@ def setup @git_set = Gem::Resolver::GitSet.new @vendor_set = Gem::Resolver::VendorSet.new - @gda = @GDA.new @set, 'gem.deps.rb' + @gda = @GDA.new @set, "gem.deps.rb" @gda.instance_variable_set :@git_set, @git_set @gda.instance_variable_set :@vendor_set, @vendor_set end @@ -44,45 +44,45 @@ def with_engine_version(name, version) end def test_gempspec_with_multiple_runtime_deps - save_gemspec 'foo', '1.0' do |s| - s.add_runtime_dependency 'bar', '>= 1.6.0', '< 1.6.4' + save_gemspec "foo", "1.0" do |s| + s.add_runtime_dependency "bar", ">= 1.6.0", "< 1.6.4" end @gda.gemspec assert_equal %w[ foo bar ].sort, @set.dependencies.map(&:name).sort - bar = @set.dependencies.find {|d| d.name == 'bar' } - assert_equal [["<", Gem::Version.create('1.6.4')], - [">=", Gem::Version.create('1.6.0')]], bar.requirement.requirements.sort + bar = @set.dependencies.find {|d| d.name == "bar" } + assert_equal [["<", Gem::Version.create("1.6.4")], + [">=", Gem::Version.create("1.6.0")]], bar.requirement.requirements.sort end def test_gemspec_without_group - @gda.send :add_dependencies, [:development], [dep('a', '= 1')] + @gda.send :add_dependencies, [:development], [dep("a", "= 1")] - assert_equal [dep('a', '= 1')], @set.dependencies + assert_equal [dep("a", "= 1")], @set.dependencies @gda.without_groups << :development - @gda.send :add_dependencies, [:development], [dep('b', '= 2')] + @gda.send :add_dependencies, [:development], [dep("b", "= 2")] - assert_equal [dep('a', '= 1')], @set.dependencies + assert_equal [dep("a", "= 1")], @set.dependencies end def test_gem - @gda.gem 'a' + @gda.gem "a" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies - assert_equal %w[a], @gda.requires['a'] + assert_equal %w[a], @gda.requires["a"] - expected = { 'a' => Gem::Requirement.default } + expected = { "a" => Gem::Requirement.default } assert_equal expected, @gda.dependencies end def test_gem_duplicate - @gda.gem 'a' + @gda.gem "a" _, err = capture_output do - @gda.gem 'a' + @gda.gem "a" end expected = "Gem dependencies file gem.deps.rb requires a more than once." @@ -91,141 +91,141 @@ def test_gem_duplicate end def test_gem_git - @gda.gem 'a', :git => 'git/a' + @gda.gem "a", :git => "git/a" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies - assert_equal %w[git/a master], @git_set.repositories['a'] + assert_equal %w[git/a master], @git_set.repositories["a"] - expected = { 'a' => Gem::Requirement.create('!') } + expected = { "a" => Gem::Requirement.create("!") } assert_equal expected, @gda.dependencies end def test_gem_bitbucket - @gda.gem 'a', :bitbucket => 'example/repository' + @gda.gem "a", :bitbucket => "example/repository" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal %w[https://example@bitbucket.org/example/repository.git master], - @git_set.repositories['a'] + @git_set.repositories["a"] - expected = { 'a' => Gem::Requirement.create('!') } + expected = { "a" => Gem::Requirement.create("!") } assert_equal expected, @gda.dependencies end def test_gem_bitbucket_expand_path - @gda.gem 'a', :bitbucket => 'example' + @gda.gem "a", :bitbucket => "example" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal %w[https://example@bitbucket.org/example/example.git master], - @git_set.repositories['a'] + @git_set.repositories["a"] - expected = { 'a' => Gem::Requirement.create('!') } + expected = { "a" => Gem::Requirement.create("!") } assert_equal expected, @gda.dependencies end def test_gem_git_branch _, err = capture_output do - @gda.gem 'a', :git => 'git/a', :branch => 'other', :tag => 'v1' + @gda.gem "a", :git => "git/a", :branch => "other", :tag => "v1" end expected = "Gem dependencies file gem.deps.rb includes git reference for both ref/branch and tag but only ref/branch is used." assert_match expected, err - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies - assert_equal %w[git/a other], @git_set.repositories['a'] + assert_equal %w[git/a other], @git_set.repositories["a"] end def test_gem_git_gist - @gda.gem 'a', :gist => 'a' + @gda.gem "a", :gist => "a" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal %w[https://gist.github.com/a.git master], - @git_set.repositories['a'] + @git_set.repositories["a"] end def test_gem_git_ref _, err = capture_output do - @gda.gem 'a', :git => 'git/a', :ref => 'abcd123', :branch => 'other' + @gda.gem "a", :git => "git/a", :ref => "abcd123", :branch => "other" end expected = "Gem dependencies file gem.deps.rb includes git reference for both ref and branch but only ref is used." assert_match expected, err - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies - assert_equal %w[git/a abcd123], @git_set.repositories['a'] + assert_equal %w[git/a abcd123], @git_set.repositories["a"] end def test_gem_git_submodules - @gda.gem 'a', :git => 'git/a', :submodules => true + @gda.gem "a", :git => "git/a", :submodules => true - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies - assert_equal %w[git/a master], @git_set.repositories['a'] + assert_equal %w[git/a master], @git_set.repositories["a"] assert_equal %w[git/a], @git_set.need_submodules.keys end def test_gem_git_tag - @gda.gem 'a', :git => 'git/a', :tag => 'v1' + @gda.gem "a", :git => "git/a", :tag => "v1" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies - assert_equal %w[git/a v1], @git_set.repositories['a'] + assert_equal %w[git/a v1], @git_set.repositories["a"] end def test_gem_github - @gda.gem 'a', :github => 'example/repository' + @gda.gem "a", :github => "example/repository" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal %w[git://github.com/example/repository.git master], - @git_set.repositories['a'] + @git_set.repositories["a"] - expected = { 'a' => Gem::Requirement.create('!') } + expected = { "a" => Gem::Requirement.create("!") } assert_equal expected, @gda.dependencies end def test_gem_github_expand_path - @gda.gem 'a', :github => 'example' + @gda.gem "a", :github => "example" - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal %w[git://github.com/example/example.git master], - @git_set.repositories['a'] + @git_set.repositories["a"] - expected = { 'a' => Gem::Requirement.create('!') } + expected = { "a" => Gem::Requirement.create("!") } assert_equal expected, @gda.dependencies end def test_gem_group - @gda.gem 'a', :group => :test + @gda.gem "a", :group => :test - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies end def test_gem_group_without @gda.without_groups << :test - @gda.gem 'a', :group => :test + @gda.gem "a", :group => :test assert_empty @set.dependencies - expected = { 'a' => Gem::Requirement.default } + expected = { "a" => Gem::Requirement.default } assert_equal expected, @gda.dependencies end def test_gem_groups - @gda.gem 'a', :groups => [:test, :development] + @gda.gem "a", :groups => [:test, :development] - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies end def test_gem_path @@ -239,7 +239,7 @@ def test_gem_path assert_equal "#{name}-#{version}", loaded.full_name - expected = { name => Gem::Requirement.create('!') } + expected = { name => Gem::Requirement.create("!") } assert_equal expected, @gda.dependencies end @@ -247,8 +247,8 @@ def test_gem_path def test_gem_platforms win_platform, Gem.win_platform = Gem.win_platform?, false - with_engine_version 'ruby', '2.0.0' do - @gda.gem 'a', :platforms => :ruby + with_engine_version "ruby", "2.0.0" do + @gda.gem "a", :platforms => :ruby refute_empty @set.dependencies end @@ -259,44 +259,44 @@ def test_gem_platforms def test_gem_platforms_bundler_ruby win_platform, Gem.win_platform = Gem.win_platform?, false - with_engine_version 'ruby', '2.0.0' do + with_engine_version "ruby", "2.0.0" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :ruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :ruby refute_empty set.dependencies end - with_engine_version 'rbx', '2.0.0' do + with_engine_version "rbx", "2.0.0" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :ruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :ruby refute_empty set.dependencies end - with_engine_version 'truffleruby', '2.0.0' do + with_engine_version "truffleruby", "2.0.0" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :ruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :ruby refute_empty set.dependencies end - with_engine_version 'jruby', '1.7.6' do + with_engine_version "jruby", "1.7.6" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :ruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :ruby assert_empty set.dependencies end Gem.win_platform = true - with_engine_version 'ruby', '2.0.0' do + with_engine_version "ruby", "2.0.0" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :ruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :ruby assert_empty set.dependencies end @@ -305,14 +305,14 @@ def test_gem_platforms_bundler_ruby end def test_gem_platforms_engine - with_engine_version 'jruby', '1.7.6' do - @gda.gem 'a', :platforms => :mri + with_engine_version "jruby", "1.7.6" do + @gda.gem "a", :platforms => :mri assert_empty @set.dependencies end - with_engine_version 'truffleruby', '1.2.3' do - @gda.gem 'a', :platforms => :mri + with_engine_version "truffleruby", "1.2.3" do + @gda.gem "a", :platforms => :mri assert_empty @set.dependencies end @@ -321,16 +321,16 @@ def test_gem_platforms_engine def test_gem_platforms_maglev win_platform, Gem.win_platform = Gem.win_platform?, false - with_engine_version 'maglev', '1.0.0' do + with_engine_version "maglev", "1.0.0" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :ruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :ruby refute_empty set.dependencies set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :maglev + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :maglev refute_empty set.dependencies end @@ -339,16 +339,16 @@ def test_gem_platforms_maglev end def test_gem_platforms_truffleruby - with_engine_version 'truffleruby', '1.0.0' do + with_engine_version "truffleruby", "1.0.0" do set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :truffleruby + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :truffleruby refute_empty set.dependencies set = Gem::RequestSet.new - gda = @GDA.new set, 'gem.deps.rb' - gda.gem 'a', :platforms => :maglev + gda = @GDA.new set, "gem.deps.rb" + gda.gem "a", :platforms => :maglev assert_empty set.dependencies end @@ -357,8 +357,8 @@ def test_gem_platforms_truffleruby def test_gem_platforms_multiple win_platform, Gem.win_platform = Gem.win_platform?, false - with_engine_version 'ruby', '2.0.0' do - @gda.gem 'a', :platforms => [:mswin, :jruby] + with_engine_version "ruby", "2.0.0" do + @gda.gem "a", :platforms => [:mswin, :jruby] assert_empty @set.dependencies end @@ -370,8 +370,8 @@ def test_gem_platforms_multiple def test_gem_platforms_platform win_platform, Gem.win_platform = Gem.win_platform?, false - with_engine_version 'ruby', '2.0.0' do - @gda.gem 'a', :platforms => :jruby, :platform => :ruby + with_engine_version "ruby", "2.0.0" do + @gda.gem "a", :platforms => :jruby, :platform => :ruby refute_empty @set.dependencies end @@ -380,8 +380,8 @@ def test_gem_platforms_platform end def test_gem_platforms_version - with_engine_version 'ruby', '2.0.0' do - @gda.gem 'a', :platforms => :ruby_18 + with_engine_version "ruby", "2.0.0" do + @gda.gem "a", :platforms => :ruby_18 assert_empty @set.dependencies end @@ -389,26 +389,26 @@ def test_gem_platforms_version def test_gem_platforms_unknown e = assert_raise ArgumentError do - @gda.gem 'a', :platforms => :unknown + @gda.gem "a", :platforms => :unknown end - assert_equal 'unknown platform :unknown', e.message + assert_equal "unknown platform :unknown", e.message end def test_gem_requires - @gda.gem 'a', :require => %w[b c] - @gda.gem 'd', :require => 'e' + @gda.gem "a", :require => %w[b c] + @gda.gem "d", :require => "e" - assert_equal [dep('a'), dep('d')], @set.dependencies + assert_equal [dep("a"), dep("d")], @set.dependencies - assert_equal %w[b c], @gda.requires['a'] - assert_equal %w[e], @gda.requires['d'] + assert_equal %w[b c], @gda.requires["a"] + assert_equal %w[e], @gda.requires["d"] end def test_gem_requires_false - @gda.gem 'a', :require => false + @gda.gem "a", :require => false - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_empty @gda.requires end @@ -416,37 +416,37 @@ def test_gem_requires_false def test_gem_requires_without_group @gda.without_groups << :test - @gda.gem 'a', :group => :test + @gda.gem "a", :group => :test assert_empty @set.dependencies - assert_empty @gda.requires['a'] + assert_empty @gda.requires["a"] end def test_gem_requirement - @gda.gem 'a', '~> 1.0' + @gda.gem "a", "~> 1.0" - assert_equal [dep('a', '~> 1.0')], @set.dependencies + assert_equal [dep("a", "~> 1.0")], @set.dependencies - expected = { 'a' => Gem::Requirement.create(['~> 1.0']) } + expected = { "a" => Gem::Requirement.create(["~> 1.0"]) } assert_equal expected, @gda.dependencies end def test_gem_requirements - @gda.gem 'b', '~> 1.0', '>= 1.0.2' + @gda.gem "b", "~> 1.0", ">= 1.0.2" - assert_equal [dep('b', '~> 1.0', '>= 1.0.2')], @set.dependencies + assert_equal [dep("b", "~> 1.0", ">= 1.0.2")], @set.dependencies - expected = { 'b' => Gem::Requirement.create(['~> 1.0', '>= 1.0.2']) } + expected = { "b" => Gem::Requirement.create(["~> 1.0", ">= 1.0.2"]) } assert_equal expected, @gda.dependencies end def test_gem_requirements_options - @gda.gem 'c', :git => 'https://example/c.git' + @gda.gem "c", :git => "https://example/c.git" - assert_equal [dep('c')], @set.dependencies + assert_equal [dep("c")], @set.dependencies end def test_gem_source_mismatch @@ -475,47 +475,47 @@ def test_gem_source_mismatch end def test_gem_deps_file - assert_equal 'gem.deps.rb', @gda.gem_deps_file + assert_equal "gem.deps.rb", @gda.gem_deps_file - gda = @GDA.new @set, 'foo/Gemfile' + gda = @GDA.new @set, "foo/Gemfile" - assert_equal 'Gemfile', gda.gem_deps_file + assert_equal "Gemfile", gda.gem_deps_file end def test_gem_group_method groups = [] @gda.group :a do - groups = @gda.send :gem_group, 'a', :group => :b, :groups => [:c, :d] + groups = @gda.send :gem_group, "a", :group => :b, :groups => [:c, :d] end assert_equal [:a, :b, :c, :d], groups.sort_by {|group| group.to_s } end def test_gemspec - save_gemspec 'a', 1 do |s| - s.add_dependency 'b', 2 - s.add_development_dependency 'c', 3 + save_gemspec "a", 1 do |s| + s.add_dependency "b", 2 + s.add_development_dependency "c", 3 end @gda.gemspec - assert_equal [dep('a', '= 1'), dep('b', '= 2'), dep('c', '=3')], + assert_equal [dep("a", "= 1"), dep("b", "= 2"), dep("c", "=3")], @set.dependencies - assert_equal %w[a], @gda.requires['a'] + assert_equal %w[a], @gda.requires["a"] expected = { - 'a' => Gem::Requirement.create('!'), - 'b' => req('= 2'), - 'c' => req('= 3'), + "a" => Gem::Requirement.create("!"), + "b" => req("= 2"), + "c" => req("= 3"), } assert_equal expected, @gda.dependencies end def test_gemspec_bad - FileUtils.touch 'a.gemspec' + FileUtils.touch "a.gemspec" e = assert_raise ArgumentError do capture_output do @@ -523,31 +523,31 @@ def test_gemspec_bad end end - assert_equal 'invalid gemspec ./a.gemspec', e.message + assert_equal "invalid gemspec ./a.gemspec", e.message end def test_gemspec_development_group - save_gemspec 'a', 1 do |s| - s.add_dependency 'b', 2 - s.add_development_dependency 'c', 3 + save_gemspec "a", 1 do |s| + s.add_dependency "b", 2 + s.add_development_dependency "c", 3 end @gda.without_groups << :other @gda.gemspec :development_group => :other - assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies + assert_equal [dep("a", "= 1"), dep("b", "= 2")], @set.dependencies - assert_equal %w[a], @gda.requires['a'] + assert_equal %w[a], @gda.requires["a"] end def test_gemspec_multiple - save_gemspec 'a', 1 do |s| - s.add_dependency 'b', 2 + save_gemspec "a", 1 do |s| + s.add_dependency "b", 2 end - save_gemspec 'b', 2 do |s| - s.add_dependency 'c', 3 + save_gemspec "b", 2 do |s| + s.add_dependency "c", 3 end e = assert_raise ArgumentError do @@ -558,27 +558,27 @@ def test_gemspec_multiple end def test_gemspec_name - save_gemspec 'a', 1 do |s| - s.add_dependency 'b', 2 + save_gemspec "a", 1 do |s| + s.add_dependency "b", 2 end - save_gemspec 'b', 2 do |s| - s.add_dependency 'c', 3 + save_gemspec "b", 2 do |s| + s.add_dependency "c", 3 end - @gda.gemspec :name => 'b' + @gda.gemspec :name => "b" - assert_equal [dep('b', '= 2'), dep('c', '= 3')], @set.dependencies + assert_equal [dep("b", "= 2"), dep("c", "= 3")], @set.dependencies end def test_gemspec_named - save_gemspec 'a', 1 do |s| - s.add_dependency 'b', 2 + save_gemspec "a", 1 do |s| + s.add_dependency "b", 2 end @gda.gemspec - assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies + assert_equal [dep("a", "= 1"), dep("b", "= 2")], @set.dependencies end def test_gemspec_none @@ -590,27 +590,27 @@ def test_gemspec_none end def test_gemspec_path - FileUtils.mkdir 'other' + FileUtils.mkdir "other" - save_gemspec 'a', 1, 'other' do |s| - s.add_dependency 'b', 2 + save_gemspec "a", 1, "other" do |s| + s.add_dependency "b", 2 end - @gda.gemspec :path => 'other' + @gda.gemspec :path => "other" - assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies + assert_equal [dep("a", "= 1"), dep("b", "= 2")], @set.dependencies end def test_git - @gda.git 'git://example/repo.git' do - @gda.gem 'a' - @gda.gem 'b' + @gda.git "git://example/repo.git" do + @gda.gem "a" + @gda.gem "b" end - assert_equal [dep('a'), dep('b')], @set.dependencies + assert_equal [dep("a"), dep("b")], @set.dependencies - assert_equal %w[git://example/repo.git master], @git_set.repositories['a'] - assert_equal %w[git://example/repo.git master], @git_set.repositories['b'] + assert_equal %w[git://example/repo.git master], @git_set.repositories["a"] + assert_equal %w[git://example/repo.git master], @git_set.repositories["b"] end def test_git_source @@ -618,21 +618,21 @@ def test_git_source "git://example/#{repo_name}.git" end - @gda.gem 'a', :example => 'repo' + @gda.gem "a", :example => "repo" - assert_equal %w[git://example/repo.git master], @git_set.repositories['a'] + assert_equal %w[git://example/repo.git master], @git_set.repositories["a"] end def test_group @gda.group :test do - @gda.gem 'a' + @gda.gem "a" end - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies end def test_load - tf = Tempfile.open 'gem.deps.rb' do |io| + tf = Tempfile.open "gem.deps.rb" do |io| io.write <<-GEM_DEPS gem 'a' @@ -646,7 +646,7 @@ def test_load assert_equal gda, gda.load - assert_equal [dep('a'), dep('b')], @set.dependencies + assert_equal [dep("a"), dep("b")], @set.dependencies io end tf.close! @@ -655,18 +655,18 @@ def test_load def test_pin_gem_source gda = @GDA.new @set, nil - gda.send :pin_gem_source, 'a' - gda.send :pin_gem_source, 'a' + gda.send :pin_gem_source, "a" + gda.send :pin_gem_source, "a" e = assert_raise ArgumentError do - gda.send :pin_gem_source, 'a', :path, 'vendor/a' + gda.send :pin_gem_source, "a", :path, "vendor/a" end assert_equal "duplicate source path: vendor/a for gem a", e.message e = assert_raise ArgumentError do - gda.send :pin_gem_source, 'a', :git, 'git://example/repo.git' + gda.send :pin_gem_source, "a", :git, "git://example/repo.git" end assert_equal "duplicate source git: git://example/repo.git for gem a", @@ -675,18 +675,18 @@ def test_pin_gem_source def test_platform_mswin if win_platform? - util_set_arch 'x86-mswin32-60' do + util_set_arch "x86-mswin32-60" do @gda.platform :mswin do - @gda.gem 'a' + @gda.gem "a" end - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies refute_empty @set.dependencies end else - util_set_arch 'i686-darwin8.10.1' do + util_set_arch "i686-darwin8.10.1" do @gda.platform :mswin do - @gda.gem 'a' + @gda.gem "a" end assert_empty @set.dependencies @@ -699,9 +699,9 @@ def test_platform_multiple gda = @GDA.new @set, nil - with_engine_version 'ruby', '1.8.7' do + with_engine_version "ruby", "1.8.7" do gda.platform :mri_19, :mri_20 do - gda.gem 'a' + gda.gem "a" end end @@ -709,9 +709,9 @@ def test_platform_multiple gda = @GDA.new @set, nil - with_engine_version 'ruby', '2.0.0' do + with_engine_version "ruby", "2.0.0" do gda.platform :mri_19, :mri_20 do - gda.gem 'a' + gda.gem "a" end end @@ -724,28 +724,28 @@ def test_platform_ruby win_platform, Gem.win_platform = Gem.win_platform?, false @gda.platform :ruby do - @gda.gem 'a' + @gda.gem "a" end - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies ensure Gem.win_platform = win_platform end def test_platforms unless win_platform? - util_set_arch 'i686-darwin8.10.1' do + util_set_arch "i686-darwin8.10.1" do @gda.platforms :ruby do - @gda.gem 'a' + @gda.gem "a" end - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies @gda.platforms :mswin do - @gda.gem 'b' + @gda.gem "b" end - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies end end end @@ -755,51 +755,51 @@ def test_ruby end def test_ruby_engine - with_engine_version 'jruby', '1.7.6' do + with_engine_version "jruby", "1.7.6" do assert @gda.ruby RUBY_VERSION, - :engine => 'jruby', :engine_version => '1.7.6' + :engine => "jruby", :engine_version => "1.7.6" end - with_engine_version 'truffleruby', '1.0.0-rc11' do + with_engine_version "truffleruby", "1.0.0-rc11" do assert @gda.ruby RUBY_VERSION, - :engine => 'truffleruby', :engine_version => '1.0.0-rc11' + :engine => "truffleruby", :engine_version => "1.0.0-rc11" end end def test_ruby_engine_mismatch_engine - with_engine_version 'ruby', '2.0.0' do + with_engine_version "ruby", "2.0.0" do e = assert_raise Gem::RubyVersionMismatch do - @gda.ruby RUBY_VERSION, :engine => 'jruby', :engine_version => '1.7.4' + @gda.ruby RUBY_VERSION, :engine => "jruby", :engine_version => "1.7.4" end - assert_equal 'Your Ruby engine is ruby, but your gem.deps.rb requires jruby', + assert_equal "Your Ruby engine is ruby, but your gem.deps.rb requires jruby", e.message end end def test_ruby_engine_mismatch_version - with_engine_version 'jruby', '1.7.6' do + with_engine_version "jruby", "1.7.6" do e = assert_raise Gem::RubyVersionMismatch do - @gda.ruby RUBY_VERSION, :engine => 'jruby', :engine_version => '1.7.4' + @gda.ruby RUBY_VERSION, :engine => "jruby", :engine_version => "1.7.4" end - assert_equal 'Your Ruby engine version is jruby 1.7.6, but your gem.deps.rb requires jruby 1.7.4', + assert_equal "Your Ruby engine version is jruby 1.7.6, but your gem.deps.rb requires jruby 1.7.4", e.message end end def test_ruby_engine_no_engine_version e = assert_raise ArgumentError do - @gda.ruby RUBY_VERSION, :engine => 'jruby' + @gda.ruby RUBY_VERSION, :engine => "jruby" end - assert_equal 'You must specify engine_version along with the Ruby engine', + assert_equal "You must specify engine_version along with the Ruby engine", e.message end def test_ruby_mismatch e = assert_raise Gem::RubyVersionMismatch do - @gda.ruby '1.8.0' + @gda.ruby "1.8.0" end assert_equal "Your Ruby version is #{RUBY_VERSION}, but your gem.deps.rb requires 1.8.0", e.message @@ -808,19 +808,19 @@ def test_ruby_mismatch def test_ruby_mismatch_installing @gda.installing = true - assert @gda.ruby '1.8.0' + assert @gda.ruby "1.8.0" end def test_source sources = Gem.sources - @gda.source 'http://first.example' + @gda.source "http://first.example" assert_equal %w[http://first.example], Gem.sources assert_same sources, Gem.sources - @gda.source 'http://second.example' + @gda.source "http://second.example" assert_equal %w[http://first.example http://second.example], Gem.sources end @@ -830,9 +830,9 @@ def test_with_engine_version engine = Gem.ruby_engine engine_version = RUBY_ENGINE_VERSION - with_engine_version 'other', '1.2.3' do - assert_equal 'other', Gem.ruby_engine - assert_equal '1.2.3', RUBY_ENGINE_VERSION + with_engine_version "other", "1.2.3" do + assert_equal "other", Gem.ruby_engine + assert_equal "1.2.3", RUBY_ENGINE_VERSION assert_equal version, RUBY_VERSION end diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb index 690b632d9b07..30dcbbbfdc92 100644 --- a/test/rubygems/test_gem_request_set_lockfile.rb +++ b/test/rubygems/test_gem_request_set_lockfile.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request_set' -require 'rubygems/request_set/lockfile' +require_relative "helper" +require "rubygems/request_set" +require "rubygems/request_set/lockfile" class TestGemRequestSetLockfile < Gem::TestCase def setup @@ -9,7 +9,7 @@ def setup Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new - util_set_arch 'i686-darwin8.10.1' + util_set_arch "i686-darwin8.10.1" @set = Gem::RequestSet.new @@ -19,7 +19,7 @@ def setup @set.instance_variable_set :@git_set, @git_set @set.instance_variable_set :@vendor_set, @vendor_set - @gem_deps_file = 'gem.deps.rb' + @gem_deps_file = "gem.deps.rb" end def lockfile @@ -29,19 +29,19 @@ def lockfile def write_lockfile(lockfile) @lock_file = File.expand_path "#{@gem_deps_file}.lock" - File.open @lock_file, 'w' do |io| + File.open @lock_file, "w" do |io| io.write lockfile end end def test_add_DEPENDENCIES spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.add_development_dependency 'b' + fetcher.spec "a", 2 do |s| + s.add_development_dependency "b" end end - @set.gem 'a' + @set.gem "a" @set.resolve out = [] @@ -49,8 +49,8 @@ def test_add_DEPENDENCIES lockfile.add_DEPENDENCIES out expected = [ - 'DEPENDENCIES', - ' a', + "DEPENDENCIES", + " a", nil, ] @@ -59,14 +59,14 @@ def test_add_DEPENDENCIES def test_add_DEPENDENCIES_from_gem_deps spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.add_development_dependency 'b' + fetcher.spec "a", 2 do |s| + s.add_development_dependency "b" end end - dependencies = { 'a' => Gem::Requirement.new('~> 2.0') } + dependencies = { "a" => Gem::Requirement.new("~> 2.0") } - @set.gem 'a' + @set.gem "a" @set.resolve @lockfile = Gem::RequestSet::Lockfile.new @set, @gem_deps_file, dependencies @@ -76,8 +76,8 @@ def test_add_DEPENDENCIES_from_gem_deps @lockfile.add_DEPENDENCIES out expected = [ - 'DEPENDENCIES', - ' a (~> 2.0)', + "DEPENDENCIES", + " a (~> 2.0)", nil, ] @@ -86,18 +86,18 @@ def test_add_DEPENDENCIES_from_gem_deps def test_add_GEM spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.add_dependency 'b' - s.add_development_dependency 'c' + fetcher.spec "a", 2 do |s| + s.add_dependency "b" + s.add_development_dependency "c" end - fetcher.spec 'b', 2 + fetcher.spec "b", 2 - fetcher.spec 'bundler', 1 + fetcher.spec "bundler", 1 end - @set.gem 'a' - @set.gem 'bundler' + @set.gem "a" + @set.gem "bundler" @set.resolve out = [] @@ -105,12 +105,12 @@ def test_add_GEM lockfile.add_GEM out, lockfile.spec_groups expected = [ - 'GEM', - ' remote: http://gems.example.com/', - ' specs:', - ' a (2)', - ' b', - ' b (2)', + "GEM", + " remote: http://gems.example.com/", + " specs:", + " a (2)", + " b", + " b (2)", nil, ] @@ -119,16 +119,16 @@ def test_add_GEM def test_add_PLATFORMS spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.add_dependency 'b' + fetcher.spec "a", 2 do |s| + s.add_dependency "b" end - fetcher.spec 'b', 2 do |s| + fetcher.spec "b", 2 do |s| s.platform = Gem::Platform::CURRENT end end - @set.gem 'a' + @set.gem "a" @set.resolve out = [] @@ -136,9 +136,9 @@ def test_add_PLATFORMS lockfile.add_PLATFORMS out expected = [ - 'PLATFORMS', - ' ruby', - ' x86-darwin-8', + "PLATFORMS", + " ruby", + " x86-darwin-8", nil, ] @@ -146,21 +146,21 @@ def test_add_PLATFORMS end def test_relative_path_from - path = lockfile.relative_path_from '/foo', '/foo/bar' + path = lockfile.relative_path_from "/foo", "/foo/bar" - assert_equal File.expand_path('/foo'), path + assert_equal File.expand_path("/foo"), path - path = lockfile.relative_path_from '/foo', '/foo' + path = lockfile.relative_path_from "/foo", "/foo" - assert_equal '.', path + assert_equal ".", path end def test_to_s_gem spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 end - @set.gem 'a' + @set.gem "a" expected = <<-LOCKFILE GEM @@ -180,12 +180,12 @@ def test_to_s_gem def test_to_s_gem_dependency spec_fetcher do |fetcher| - fetcher.spec 'a', 2, 'c' => '>= 0', 'b' => '>= 0' - fetcher.spec 'b', 2 - fetcher.spec 'c', 2 + fetcher.spec "a", 2, "c" => ">= 0", "b" => ">= 0" + fetcher.spec "b", 2 + fetcher.spec "c", 2 end - @set.gem 'a' + @set.gem "a" expected = <<-LOCKFILE GEM @@ -211,12 +211,12 @@ def test_to_s_gem_dependency def test_to_s_gem_dependency_non_default spec_fetcher do |fetcher| - fetcher.spec 'a', 2, 'b' => '>= 1' - fetcher.spec 'b', 2 + fetcher.spec "a", 2, "b" => ">= 1" + fetcher.spec "b", 2 end - @set.gem 'b' - @set.gem 'a' + @set.gem "b" + @set.gem "a" expected = <<-LOCKFILE GEM @@ -239,11 +239,11 @@ def test_to_s_gem_dependency_non_default def test_to_s_gem_dependency_requirement spec_fetcher do |fetcher| - fetcher.spec 'a', 2, 'b' => '>= 0' - fetcher.spec 'b', 2 + fetcher.spec "a", 2, "b" => ">= 0" + fetcher.spec "b", 2 end - @set.gem 'a', '>= 1' + @set.gem "a", ">= 1" expected = <<-LOCKFILE GEM @@ -269,7 +269,7 @@ def test_to_s_gem_path @vendor_set.add_vendor_gem name, directory - @set.gem 'a' + @set.gem "a" expected = <<-LOCKFILE PATH @@ -292,7 +292,7 @@ def test_to_s_gem_path_absolute @vendor_set.add_vendor_gem name, File.expand_path(directory) - @set.gem 'a' + @set.gem "a" expected = <<-LOCKFILE PATH @@ -312,12 +312,12 @@ def test_to_s_gem_path_absolute def test_to_s_gem_platform spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |spec| + fetcher.spec "a", 2 do |spec| spec.platform = Gem::Platform.local end end - @set.gem 'a' + @set.gem "a" expected = <<-LOCKFILE GEM @@ -337,17 +337,17 @@ def test_to_s_gem_platform def test_to_s_gem_source spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 end - spec_fetcher 'http://other.example/' do |fetcher| - fetcher.download 'b', 2 + spec_fetcher "http://other.example/" do |fetcher| + fetcher.download "b", 2 end - Gem.sources << 'http://other.example/' + Gem.sources << "http://other.example/" - @set.gem 'a' - @set.gem 'b' + @set.gem "a" + @set.gem "b" expected = <<-LOCKFILE GEM @@ -377,43 +377,43 @@ def test_to_s_git head = nil Dir.chdir repository do - FileUtils.mkdir 'b' + FileUtils.mkdir "b" - Dir.chdir 'b' do - b = Gem::Specification.new 'b', 1 do |s| - s.add_dependency 'a', '~> 1.0' - s.add_dependency 'c', '~> 1.0' + Dir.chdir "b" do + b = Gem::Specification.new "b", 1 do |s| + s.add_dependency "a", "~> 1.0" + s.add_dependency "c", "~> 1.0" end - File.open 'b.gemspec', 'w' do |io| + File.open "b.gemspec", "w" do |io| io.write b.to_ruby end - system @git, 'add', 'b.gemspec' - system @git, 'commit', '--quiet', '-m', 'add b/b.gemspec' + system @git, "add", "b.gemspec" + system @git, "commit", "--quiet", "-m", "add b/b.gemspec" end - FileUtils.mkdir 'c' + FileUtils.mkdir "c" - Dir.chdir 'c' do - c = Gem::Specification.new 'c', 1 + Dir.chdir "c" do + c = Gem::Specification.new "c", 1 - File.open 'c.gemspec', 'w' do |io| + File.open "c.gemspec", "w" do |io| io.write c.to_ruby end - system @git, 'add', 'c.gemspec' - system @git, 'commit', '--quiet', '-m', 'add c/c.gemspec' + system @git, "add", "c.gemspec" + system @git, "commit", "--quiet", "-m", "add c/c.gemspec" end head = `#{@git} rev-parse HEAD`.strip end - @git_set.add_git_gem 'a', repository, 'HEAD', true - @git_set.add_git_gem 'b', repository, 'HEAD', true - @git_set.add_git_gem 'c', repository, 'HEAD', true + @git_set.add_git_gem "a", repository, "HEAD", true + @git_set.add_git_gem "b", repository, "HEAD", true + @git_set.add_git_gem "c", repository, "HEAD", true - @set.gem 'b' + @set.gem "b" expected = <<-LOCKFILE GIT @@ -449,12 +449,12 @@ def test_write end def test_write_error - @set.gem 'nonexistent' + @set.gem "nonexistent" gem_deps_lock_file = "#{@gem_deps_file}.lock" - File.open gem_deps_lock_file, 'w' do |io| - io.write 'hello' + File.open gem_deps_lock_file, "w" do |io| + io.write "hello" end assert_raise Gem::UnsatisfiableDependencyError do @@ -463,6 +463,6 @@ def test_write_error assert_path_exist gem_deps_lock_file - assert_equal 'hello', File.read(gem_deps_lock_file) + assert_equal "hello", File.read(gem_deps_lock_file) end end diff --git a/test/rubygems/test_gem_request_set_lockfile_parser.rb b/test/rubygems/test_gem_request_set_lockfile_parser.rb index 775085964e1b..757c764dc187 100644 --- a/test/rubygems/test_gem_request_set_lockfile_parser.rb +++ b/test/rubygems/test_gem_request_set_lockfile_parser.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request_set' -require 'rubygems/request_set/lockfile' -require 'rubygems/request_set/lockfile/tokenizer' -require 'rubygems/request_set/lockfile/parser' +require_relative "helper" +require "rubygems/request_set" +require "rubygems/request_set/lockfile" +require "rubygems/request_set/lockfile/tokenizer" +require "rubygems/request_set/lockfile/parser" class TestGemRequestSetLockfileParser < Gem::TestCase def setup super - @gem_deps_file = 'gem.deps.rb' + @gem_deps_file = "gem.deps.rb" @lock_file = File.expand_path "#{@gem_deps_file}.lock" @set = Gem::RequestSet.new end @@ -53,7 +53,7 @@ def test_get_type_value_mismatch parser = tokenizer.make_parser nil, nil e = assert_raise Gem::RequestSet::Lockfile::ParseError do - parser.get :text, 'y' + parser.get :text, "y" end expected = @@ -83,7 +83,7 @@ def test_parse platforms = [] parse_lockfile @set, platforms - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal [Gem::Platform::RUBY], platforms @@ -91,7 +91,7 @@ def test_parse Gem::Resolver::LockSet === set end - assert lockfile_set, 'could not find a LockSet' + assert lockfile_set, "could not find a LockSet" assert_equal %w[a-2], lockfile_set.specs.map {|tuple| tuple.full_name } end @@ -113,7 +113,7 @@ def test_parse_dependencies platforms = [] parse_lockfile @set, platforms - assert_equal [dep('a', '>= 1', '<= 2')], @set.dependencies + assert_equal [dep("a", ">= 1", "<= 2")], @set.dependencies assert_equal [Gem::Platform::RUBY], platforms @@ -121,7 +121,7 @@ def test_parse_dependencies Gem::Resolver::LockSet === set end - assert lockfile_set, 'could not find a LockSet' + assert lockfile_set, "could not find a LockSet" assert_equal %w[a-2], lockfile_set.specs.map {|tuple| tuple.full_name } end @@ -159,8 +159,8 @@ def test_parse_DEPENDENCIES_git parse_lockfile @set, [] expected = [ - dep('i18n-active_record', '= 0.0.2'), - dep('rails-footnotes', '= 3.7.9'), + dep("i18n-active_record", "= 0.0.2"), + dep("rails-footnotes", "= 3.7.9"), ] assert_equal expected, @set.dependencies @@ -188,7 +188,7 @@ def test_parse_DEPENDENCIES_git_version parse_lockfile @set, [] expected = [ - dep('jwt', '= 1.1'), + dep("jwt", "= 1.1"), ] assert_equal expected, @set.dependencies @@ -209,13 +209,13 @@ def test_parse_GEM parse_lockfile @set, [] - assert_equal [dep('a', '>= 0')], @set.dependencies + assert_equal [dep("a", ">= 0")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - assert lockfile_set, 'found a LockSet' + assert lockfile_set, "found a LockSet" assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name } end @@ -237,13 +237,13 @@ def test_parse_GEM_remote_multiple parse_lockfile @set, [] - assert_equal [dep('a', '>= 0')], @set.dependencies + assert_equal [dep("a", ">= 0")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - assert lockfile_set, 'found a LockSet' + assert lockfile_set, "found a LockSet" assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name } @@ -252,7 +252,7 @@ def test_parse_GEM_remote_multiple end def test_parse_GIT - @set.instance_variable_set :@install_dir, 'install_dir' + @set.instance_variable_set :@install_dir, "install_dir" write_lockfile <<-LOCKFILE GIT @@ -269,31 +269,31 @@ def test_parse_GIT parse_lockfile @set, [] - assert_equal [dep('a', '= 2')], @set.dependencies + assert_equal [dep("a", "= 2")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - refute lockfile_set, 'fount a LockSet' + refute lockfile_set, "fount a LockSet" git_set = @set.sets.find do |set| Gem::Resolver::GitSet === set end - assert git_set, 'could not find a GitSet' + assert git_set, "could not find a GitSet" assert_equal %w[a-2], git_set.specs.values.map {|s| s.full_name } - assert_equal [dep('b', '>= 3'), dep('c')], + assert_equal [dep("b", ">= 3"), dep("c")], git_set.specs.values.first.dependencies expected = { - 'a' => %w[git://example/a.git master], + "a" => %w[git://example/a.git master], } assert_equal expected, git_set.repositories - assert_equal 'install_dir', git_set.root_dir + assert_equal "install_dir", git_set.root_dir end def test_parse_GIT_branch @@ -312,22 +312,22 @@ def test_parse_GIT_branch parse_lockfile @set, [] - assert_equal [dep('a', '= 2')], @set.dependencies + assert_equal [dep("a", "= 2")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - refute lockfile_set, 'fount a LockSet' + refute lockfile_set, "fount a LockSet" git_set = @set.sets.find do |set| Gem::Resolver::GitSet === set end - assert git_set, 'could not find a GitSet' + assert git_set, "could not find a GitSet" expected = { - 'a' => %w[git://example/a.git 1234abc], + "a" => %w[git://example/a.git 1234abc], } assert_equal expected, git_set.repositories @@ -349,22 +349,22 @@ def test_parse_GIT_ref parse_lockfile @set, [] - assert_equal [dep('a', '= 2')], @set.dependencies + assert_equal [dep("a", "= 2")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - refute lockfile_set, 'fount a LockSet' + refute lockfile_set, "fount a LockSet" git_set = @set.sets.find do |set| Gem::Resolver::GitSet === set end - assert git_set, 'could not find a GitSet' + assert git_set, "could not find a GitSet" expected = { - 'a' => %w[git://example/a.git 1234abc], + "a" => %w[git://example/a.git 1234abc], } assert_equal expected, git_set.repositories @@ -386,22 +386,22 @@ def test_parse_GIT_tag parse_lockfile @set, [] - assert_equal [dep('a', '= 2')], @set.dependencies + assert_equal [dep("a", "= 2")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - refute lockfile_set, 'fount a LockSet' + refute lockfile_set, "fount a LockSet" git_set = @set.sets.find do |set| Gem::Resolver::GitSet === set end - assert git_set, 'could not find a GitSet' + assert git_set, "could not find a GitSet" expected = { - 'a' => %w[git://example/a.git 1234abc], + "a" => %w[git://example/a.git 1234abc], } assert_equal expected, git_set.repositories @@ -423,45 +423,45 @@ def test_parse_PATH parse_lockfile @set, [] - assert_equal [dep('a', '= 1')], @set.dependencies + assert_equal [dep("a", "= 1")], @set.dependencies lockfile_set = @set.sets.find do |set| Gem::Resolver::LockSet === set end - refute lockfile_set, 'found a LockSet' + refute lockfile_set, "found a LockSet" vendor_set = @set.sets.find do |set| Gem::Resolver::VendorSet === set end - assert vendor_set, 'could not find a VendorSet' + assert vendor_set, "could not find a VendorSet" assert_equal %w[a-1], vendor_set.specs.values.map {|s| s.full_name } - spec = vendor_set.load_spec 'a', nil, nil, nil + spec = vendor_set.load_spec "a", nil, nil, nil - assert_equal [dep('b', '= 2')], spec.dependencies + assert_equal [dep("b", "= 2")], spec.dependencies end def test_parse_dependency - write_lockfile ' 1)' + write_lockfile " 1)" tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file @lock_file parser = tokenizer.make_parser nil, nil - parsed = parser.parse_dependency 'a', '=' + parsed = parser.parse_dependency "a", "=" - assert_equal dep('a', '= 1'), parsed + assert_equal dep("a", "= 1"), parsed - write_lockfile ')' + write_lockfile ")" tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file @lock_file parser = tokenizer.make_parser nil, nil - parsed = parser.parse_dependency 'a', '2' + parsed = parser.parse_dependency "a", "2" - assert_equal dep('a', '= 2'), parsed + assert_equal dep("a", "= 2"), parsed end def test_parse_gem_specs_dependency @@ -486,7 +486,7 @@ def test_parse_gem_specs_dependency platforms = [] parse_lockfile @set, platforms - assert_equal [dep('a')], @set.dependencies + assert_equal [dep("a")], @set.dependencies assert_equal [Gem::Platform::RUBY], platforms @@ -494,13 +494,13 @@ def test_parse_gem_specs_dependency Gem::Resolver::LockSet === set end - assert lockfile_set, 'could not find a LockSet' + assert lockfile_set, "could not find a LockSet" assert_equal %w[a-2 b-3], lockfile_set.specs.map {|tuple| tuple.full_name } expected = [ Gem::Platform::RUBY, - Gem::Platform.new('x86_64-linux'), + Gem::Platform.new("x86_64-linux"), ] assert_equal expected, lockfile_set.specs.map {|tuple| tuple.platform } @@ -508,10 +508,10 @@ def test_parse_gem_specs_dependency spec = lockfile_set.specs.first expected = [ - dep('b', '= 3'), - dep('c', '~> 4'), - dep('d'), - dep('e', '~> 5.0', '>= 5.0.1'), + dep("b", "= 3"), + dep("c", "~> 4"), + dep("d"), + dep("e", "~> 5.0", ">= 5.0.1"), ] assert_equal expected, spec.dependencies @@ -530,7 +530,7 @@ def test_parse_missing end def write_lockfile(lockfile) - File.open @lock_file, 'w' do |io| + File.open @lock_file, "w" do |io| io.write lockfile end end diff --git a/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb b/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb index f779c33012a2..8db180eb2765 100644 --- a/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +++ b/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/request_set' -require 'rubygems/request_set/lockfile' -require 'rubygems/request_set/lockfile/tokenizer' -require 'rubygems/request_set/lockfile/parser' +require_relative "helper" +require "rubygems/request_set" +require "rubygems/request_set/lockfile" +require "rubygems/request_set/lockfile/tokenizer" +require "rubygems/request_set/lockfile/parser" class TestGemRequestSetLockfileTokenizer < Gem::TestCase def setup super - @gem_deps_file = 'gem.deps.rb' + @gem_deps_file = "gem.deps.rb" @lock_file = File.expand_path "#{@gem_deps_file}.lock" end @@ -34,10 +34,10 @@ def test_skip end def test_token_pos - tokenizer = Gem::RequestSet::Lockfile::Tokenizer.new '' + tokenizer = Gem::RequestSet::Lockfile::Tokenizer.new "" assert_equal [5, 0], tokenizer.token_pos(5) - tokenizer = Gem::RequestSet::Lockfile::Tokenizer.new '', nil, 1, 2 + tokenizer = Gem::RequestSet::Lockfile::Tokenizer.new "", nil, 1, 2 assert_equal [3, 1], tokenizer.token_pos(5) end @@ -63,74 +63,74 @@ def test_tokenize LOCKFILE expected = [ - [:section, 'GEM', 0, 0], + [:section, "GEM", 0, 0], [:newline, nil, 3, 0], - [:entry, 'remote', 2, 1], + [:entry, "remote", 2, 1], [:text, @gem_repo, 10, 1], [:newline, nil, 34, 1], - [:entry, 'specs', 2, 2], + [:entry, "specs", 2, 2], [:newline, nil, 8, 2], - [:text, 'a', 4, 3], + [:text, "a", 4, 3], [:l_paren, nil, 6, 3], - [:text, '2', 7, 3], + [:text, "2", 7, 3], [:r_paren, nil, 8, 3], [:newline, nil, 9, 3], - [:text, 'b', 6, 4], + [:text, "b", 6, 4], [:l_paren, nil, 8, 4], - [:requirement, '=', 9, 4], - [:text, '2', 11, 4], + [:requirement, "=", 9, 4], + [:text, "2", 11, 4], [:r_paren, nil, 12, 4], [:newline, nil, 13, 4], - [:text, 'c', 6, 5], + [:text, "c", 6, 5], [:l_paren, nil, 8, 5], - [:requirement, '!=', 9, 5], - [:text, '3', 12, 5], + [:requirement, "!=", 9, 5], + [:text, "3", 12, 5], [:r_paren, nil, 13, 5], [:newline, nil, 14, 5], - [:text, 'd', 6, 6], + [:text, "d", 6, 6], [:l_paren, nil, 8, 6], - [:requirement, '>', 9, 6], - [:text, '4', 11, 6], + [:requirement, ">", 9, 6], + [:text, "4", 11, 6], [:r_paren, nil, 12, 6], [:newline, nil, 13, 6], - [:text, 'e', 6, 7], + [:text, "e", 6, 7], [:l_paren, nil, 8, 7], - [:requirement, '<', 9, 7], - [:text, '5', 11, 7], + [:requirement, "<", 9, 7], + [:text, "5", 11, 7], [:r_paren, nil, 12, 7], [:newline, nil, 13, 7], - [:text, 'f', 6, 8], + [:text, "f", 6, 8], [:l_paren, nil, 8, 8], - [:requirement, '>=', 9, 8], - [:text, '6', 12, 8], + [:requirement, ">=", 9, 8], + [:text, "6", 12, 8], [:r_paren, nil, 13, 8], [:newline, nil, 14, 8], - [:text, 'g', 6, 9], + [:text, "g", 6, 9], [:l_paren, nil, 8, 9], - [:requirement, '<=', 9, 9], - [:text, '7', 12, 9], + [:requirement, "<=", 9, 9], + [:text, "7", 12, 9], [:r_paren, nil, 13, 9], [:newline, nil, 14, 9], - [:text, 'h', 6, 10], + [:text, "h", 6, 10], [:l_paren, nil, 8, 10], - [:requirement, '~>', 9, 10], - [:text, '8', 12, 10], + [:requirement, "~>", 9, 10], + [:text, "8", 12, 10], [:r_paren, nil, 13, 10], [:newline, nil, 14, 10], [:newline, nil, 0, 11], - [:section, 'PLATFORMS', 0, 12], + [:section, "PLATFORMS", 0, 12], [:newline, nil, 9, 12], [:text, Gem::Platform::RUBY, 2, 13], @@ -138,10 +138,10 @@ def test_tokenize [:newline, nil, 0, 14], - [:section, 'DEPENDENCIES', 0, 15], + [:section, "DEPENDENCIES", 0, 15], [:newline, nil, 12, 15], - [:text, 'a', 2, 16], + [:text, "a", 2, 16], [:newline, nil, 3, 16], ] @@ -163,27 +163,27 @@ def test_tokenize_capitals LOCKFILE expected = [ - [:section, 'GEM', 0, 0], + [:section, "GEM", 0, 0], [:newline, nil, 3, 0], - [:entry, 'remote', 2, 1], + [:entry, "remote", 2, 1], [:text, @gem_repo, 10, 1], [:newline, nil, 34, 1], - [:entry, 'specs', 2, 2], + [:entry, "specs", 2, 2], [:newline, nil, 8, 2], - [:text, 'Ab', 4, 3], + [:text, "Ab", 4, 3], [:l_paren, nil, 7, 3], - [:text, '2', 8, 3], + [:text, "2", 8, 3], [:r_paren, nil, 9, 3], [:newline, nil, 10, 3], [:newline, nil, 0, 4], - [:section, 'PLATFORMS', 0, 5], + [:section, "PLATFORMS", 0, 5], [:newline, nil, 9, 5], [:text, Gem::Platform::RUBY, 2, 6], [:newline, nil, 6, 6], [:newline, nil, 0, 7], - [:section, 'DEPENDENCIES', 0, 8], + [:section, "DEPENDENCIES", 0, 8], [:newline, nil, 12, 8], - [:text, 'Ab', 2, 9], + [:text, "Ab", 2, 9], [:newline, nil, 4, 9], ] @@ -191,7 +191,7 @@ def test_tokenize_capitals end def test_tokenize_conflict_markers - write_lockfile '<<<<<<<' + write_lockfile "<<<<<<<" e = assert_raise Gem::RequestSet::Lockfile::ParseError do tokenize_lockfile @@ -200,7 +200,7 @@ def test_tokenize_conflict_markers assert_equal "your #{@lock_file} contains merge conflict markers (at line 0 column 0)", e.message - write_lockfile '|||||||' + write_lockfile "|||||||" e = assert_raise Gem::RequestSet::Lockfile::ParseError do tokenize_lockfile @@ -209,7 +209,7 @@ def test_tokenize_conflict_markers assert_equal "your #{@lock_file} contains merge conflict markers (at line 0 column 0)", e.message - write_lockfile '=======' + write_lockfile "=======" e = assert_raise Gem::RequestSet::Lockfile::ParseError do tokenize_lockfile @@ -218,7 +218,7 @@ def test_tokenize_conflict_markers assert_equal "your #{@lock_file} contains merge conflict markers (at line 0 column 0)", e.message - write_lockfile '>>>>>>>' + write_lockfile ">>>>>>>" e = assert_raise Gem::RequestSet::Lockfile::ParseError do tokenize_lockfile @@ -235,10 +235,10 @@ def test_tokenize_git LOCKFILE expected = [ - [:section, 'DEPENDENCIES', 0, 0], + [:section, "DEPENDENCIES", 0, 0], [:newline, nil, 12, 0], - [:text, 'a', 2, 1], + [:text, "a", 2, 1], [:bang, nil, 3, 1], [:newline, nil, 4, 1], ] @@ -256,29 +256,29 @@ def test_tokenize_multiple LOCKFILE expected = [ - [:section, 'GEM', 0, 0], + [:section, "GEM", 0, 0], [:newline, nil, 3, 0], - [:entry, 'remote', 2, 1], + [:entry, "remote", 2, 1], [:text, @gem_repo, 10, 1], [:newline, nil, 34, 1], - [:entry, 'specs', 2, 2], + [:entry, "specs", 2, 2], [:newline, nil, 8, 2], - [:text, 'a', 4, 3], + [:text, "a", 4, 3], [:l_paren, nil, 6, 3], - [:text, '2', 7, 3], + [:text, "2", 7, 3], [:r_paren, nil, 8, 3], [:newline, nil, 9, 3], - [:text, 'b', 6, 4], + [:text, "b", 6, 4], [:l_paren, nil, 8, 4], - [:requirement, '~>', 9, 4], - [:text, '3.0', 12, 4], + [:requirement, "~>", 9, 4], + [:text, "3.0", 12, 4], [:comma, nil, 15, 4], - [:requirement, '>=', 17, 4], - [:text, '3.0.1', 20, 4], + [:requirement, ">=", 17, 4], + [:text, "3.0.1", 20, 4], [:r_paren, nil, 25, 4], [:newline, nil, 26, 4], ] @@ -295,7 +295,7 @@ def test_unget end def write_lockfile(lockfile) - File.open @lock_file, 'w' do |io| + File.open @lock_file, "w" do |io| io.write lockfile end end diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb index b4367681d0b3..37137dbdad80 100644 --- a/test/rubygems/test_gem_requirement.rb +++ b/test/rubygems/test_gem_requirement.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" require "rubygems/requirement" class TestGemRequirement < Gem::TestCase def test_concat - r = req '>= 1' + r = req ">= 1" - r.concat ['< 2'] + r.concat ["< 2"] - assert_equal [['>=', v(1)], ['<', v(2)]], r.requirements + assert_equal [[">=", v(1)], ["<", v(2)]], r.requirements end def test_equals2 @@ -60,42 +60,42 @@ def test_basic_non_none end def test_for_lockfile - assert_equal ' (~> 1.0)', req('~> 1.0').for_lockfile + assert_equal " (~> 1.0)", req("~> 1.0").for_lockfile - assert_equal ' (~> 1.0, >= 1.0.1)', req('>= 1.0.1', '~> 1.0').for_lockfile + assert_equal " (~> 1.0, >= 1.0.1)", req(">= 1.0.1", "~> 1.0").for_lockfile - duped = req '= 1.0' - duped.requirements << ['=', v('1.0')] + duped = req "= 1.0" + duped.requirements << ["=", v("1.0")] - assert_equal ' (= 1.0)', duped.for_lockfile + assert_equal " (= 1.0)", duped.for_lockfile assert_nil Gem::Requirement.default.for_lockfile end def test_parse - assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse(' 1') - assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse('= 1') - assert_equal ['>', Gem::Version.new(1)], Gem::Requirement.parse('> 1') - assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse("=\n1") - assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse('1.0') + assert_equal ["=", Gem::Version.new(1)], Gem::Requirement.parse(" 1") + assert_equal ["=", Gem::Version.new(1)], Gem::Requirement.parse("= 1") + assert_equal [">", Gem::Version.new(1)], Gem::Requirement.parse("> 1") + assert_equal ["=", Gem::Version.new(1)], Gem::Requirement.parse("=\n1") + assert_equal ["=", Gem::Version.new(1)], Gem::Requirement.parse("1.0") - assert_equal ['=', Gem::Version.new(2)], - Gem::Requirement.parse(Gem::Version.new('2')) + assert_equal ["=", Gem::Version.new(2)], + Gem::Requirement.parse(Gem::Version.new("2")) end - if RUBY_VERSION >= '2.5' && !(Gem.java_platform? && ENV["JRUBY_OPTS"] =~ /--debug/) + if RUBY_VERSION >= "2.5" && !(Gem.java_platform? && ENV["JRUBY_OPTS"] =~ /--debug/) def test_parse_deduplication - assert_same '~>', Gem::Requirement.parse('~> 1').first + assert_same "~>", Gem::Requirement.parse("~> 1").first end end def test_parse_bad [ nil, - '', - '! 1', - '= junk', - '1..2', + "", + "! 1", + "= junk", + "1..2", ].each do |bad| e = assert_raise Gem::Requirement::BadRequirementError do Gem::Requirement.parse bad @@ -108,21 +108,21 @@ def test_parse_bad end def test_prerelease_eh - r = req '= 1' + r = req "= 1" refute r.prerelease? - r = req '= 1.a' + r = req "= 1.a" assert r.prerelease? - r = req '> 1.a', '< 2' + r = req "> 1.a", "< 2" assert r.prerelease? end def test_satisfied_by_eh_bang_equal - r = req '!= 1.2' + r = req "!= 1.2" assert_satisfied_by "1.1", r refute_satisfied_by "1.2", r @@ -362,16 +362,16 @@ def test_satisfied_by_explicitly_bounded end def test_specific - refute req('> 1') .specific? - refute req('>= 1').specific? + refute req("> 1") .specific? + refute req(">= 1").specific? - assert req('!= 1').specific? - assert req('< 1') .specific? - assert req('<= 1').specific? - assert req('= 1') .specific? - assert req('~> 1').specific? + assert req("!= 1").specific? + assert req("< 1") .specific? + assert req("<= 1").specific? + assert req("= 1") .specific? + assert req("~> 1").specific? - assert req('> 1', '> 2').specific? # GIGO + assert req("> 1", "> 2").specific? # GIGO end def test_bad @@ -392,12 +392,12 @@ def test_bad end def test_hash_with_multiple_versions - r1 = req('1.0', '2.0') - r2 = req('2.0', '1.0') + r1 = req("1.0", "2.0") + r2 = req("2.0", "1.0") assert_equal r1.hash, r2.hash - r1 = req('1.0', '2.0').tap {|r| r.concat(['3.0']) } - r2 = req('3.0', '1.0').tap {|r| r.concat(['2.0']) } + r1 = req("1.0", "2.0").tap {|r| r.concat(["3.0"]) } + r2 = req("3.0", "1.0").tap {|r| r.concat(["2.0"]) } assert_equal r1.hash, r2.hash end diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb index ab0cdaddb9a1..22712447292f 100644 --- a/test/rubygems/test_gem_resolver.rb +++ b/test/rubygems/test_gem_resolver.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolver < Gem::TestCase def setup @@ -80,7 +80,7 @@ def test_self_compose_sets_nil @DR.compose_sets nil end - assert_equal 'one set in the composition must be non-nil', e.message + assert_equal "one set in the composition must be non-nil", e.message end def test_self_compose_sets_single @@ -92,9 +92,9 @@ def test_self_compose_sets_single end def test_requests - a1 = util_spec 'a', 1, 'b' => 2 + a1 = util_spec "a", 1, "b" => 2 - r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil + r1 = Gem::Resolver::DependencyRequest.new dep("a", "= 1"), nil act = Gem::Resolver::ActivationRequest.new a1, r1 @@ -104,18 +104,18 @@ def test_requests res.requests a1, act, reqs - assert_equal ['b (= 2)'], reqs.map {|req| req.to_s } + assert_equal ["b (= 2)"], reqs.map {|req| req.to_s } end def test_requests_development - a1 = util_spec 'a', 1, 'b' => 2 + a1 = util_spec "a", 1, "b" => 2 spec = Gem::Resolver::SpecSpecification.new nil, a1 def spec.fetch_development_dependencies @called = true end - r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil + r1 = Gem::Resolver::DependencyRequest.new dep("a", "= 1"), nil act = Gem::Resolver::ActivationRequest.new spec, r1 @@ -126,15 +126,15 @@ def spec.fetch_development_dependencies res.requests spec, act, reqs - assert_equal ['b (= 2)'], reqs.map {|req| req.to_s } + assert_equal ["b (= 2)"], reqs.map {|req| req.to_s } assert spec.instance_variable_defined? :@called end def test_requests_ignore_dependencies - a1 = util_spec 'a', 1, 'b' => 2 + a1 = util_spec "a", 1, "b" => 2 - r1 = Gem::Resolver::DependencyRequest.new dep('a', '= 1'), nil + r1 = Gem::Resolver::DependencyRequest.new dep("a", "= 1"), nil act = Gem::Resolver::ActivationRequest.new a1, r1 @@ -149,37 +149,37 @@ def test_requests_ignore_dependencies end def test_resolve_conservative - a1_spec = util_spec 'a', 1 + a1_spec = util_spec "a", 1 - a2_spec = util_spec 'a', 2 do |s| - s.add_dependency 'b', 2 - s.add_dependency 'c' + a2_spec = util_spec "a", 2 do |s| + s.add_dependency "b", 2 + s.add_dependency "c" end - b1_spec = util_spec 'b', 1 - b2_spec = util_spec 'b', 2 + b1_spec = util_spec "b", 1 + b2_spec = util_spec "b", 2 - c1_spec = util_spec 'c', 1 do |s| - s.add_dependency 'd', 2 + c1_spec = util_spec "c", 1 do |s| + s.add_dependency "d", 2 end - c2_spec = util_spec 'c', 2 do |s| - s.add_dependency 'd', 2 + c2_spec = util_spec "c", 2 do |s| + s.add_dependency "d", 2 end - d1_spec = util_spec 'd', 1 do |s| - s.add_dependency 'e' + d1_spec = util_spec "d", 1 do |s| + s.add_dependency "e" end - d2_spec = util_spec 'd', 2 do |s| - s.add_dependency 'e' + d2_spec = util_spec "d", 2 do |s| + s.add_dependency "e" end - e1_spec = util_spec 'e', 1 - e2_spec = util_spec 'e', 2 + e1_spec = util_spec "e", 1 + e2_spec = util_spec "e", 2 - a_dep = make_dep 'a', '= 2' - e_dep = make_dep 'e' + a_dep = make_dep "a", "= 2" + e_dep = make_dep "e" # When requesting to install: # a-2, e @@ -191,7 +191,7 @@ def test_resolve_conservative # With the following gems already installed: # a-1, b-1, c-1, e-1 - res.skip_gems = { 'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec] } + res.skip_gems = { "a" => [a1_spec], "b" => [b1_spec], "c" => [c1_spec], "e" => [e1_spec] } # Make sure the following gems end up getting used/installed/upgraded: # a-2 (upgraded) @@ -203,17 +203,17 @@ def test_resolve_conservative end def test_resolve_development - a_spec = util_spec 'a', 1 do |s| - s.add_development_dependency 'b' + a_spec = util_spec "a", 1 do |s| + s.add_development_dependency "b" end - b_spec = util_spec 'b', 1 do - |s| s.add_development_dependency 'c' + b_spec = util_spec "b", 1 do + |s| s.add_development_dependency "c" end - c_spec = util_spec 'c', 1 + c_spec = util_spec "c", 1 - a_dep = make_dep 'a', '= 1' + a_dep = make_dep "a", "= 1" deps = [a_dep] @@ -227,24 +227,24 @@ def test_resolve_development end def test_resolve_development_shallow - a_spec = util_spec 'a', 1 do |s| - s.add_development_dependency 'b' - s.add_runtime_dependency 'd' + a_spec = util_spec "a", 1 do |s| + s.add_development_dependency "b" + s.add_runtime_dependency "d" end - b_spec = util_spec 'b', 1 do |s| - s.add_development_dependency 'c' + b_spec = util_spec "b", 1 do |s| + s.add_development_dependency "c" end - c_spec = util_spec 'c', 1 + c_spec = util_spec "c", 1 - d_spec = util_spec 'd', 1 do |s| - s.add_development_dependency 'e' + d_spec = util_spec "d", 1 do |s| + s.add_development_dependency "e" end - e_spec = util_spec 'e', 1 + e_spec = util_spec "e", 1 - a_dep = make_dep 'a', '= 1' + a_dep = make_dep "a", "= 1" deps = [a_dep] @@ -262,7 +262,7 @@ def test_resolve_remote_missing_dependency @fetcher = Gem::FakeFetcher.new Gem::RemoteFetcher.fetcher = @fetcher - a_dep = make_dep 'a', '= 1' + a_dep = make_dep "a", "= 1" res = Gem::Resolver.new [a_dep], Gem::Resolver::IndexSet.new @@ -274,7 +274,7 @@ def test_resolve_remote_missing_dependency end def test_no_overlap_specifically - a = util_spec "a", '1' + a = util_spec "a", "1" b = util_spec "b", "1" ad = make_dep "a", "= 1" @@ -290,7 +290,7 @@ def test_no_overlap_specifically end def test_pulls_in_dependencies - a = util_spec "a", '1' + a = util_spec "a", "1" b = util_spec "b", "1", "c" => "= 1" c = util_spec "c", "1" @@ -307,8 +307,8 @@ def test_pulls_in_dependencies end def test_picks_highest_version - a1 = util_spec "a", '1' - a2 = util_spec "a", '2' + a1 = util_spec "a", "1" + a2 = util_spec "a", "2" s = set(a1, a2) @@ -321,17 +321,17 @@ def test_picks_highest_version def test_picks_best_platform is = Gem::Resolver::IndexSpecification - unknown = Gem::Platform.new 'unknown' + unknown = Gem::Platform.new "unknown" a2_p1 = a3_p2 = nil spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 - a2_p1 = fetcher.spec 'a', 2 do |s| + a2_p1 = fetcher.spec "a", 2 do |s| s.platform = Gem::Platform.local end - a3_p2 = fetcher.spec 'a', 3 do |s| + a3_p2 = fetcher.spec "a", 3 do |s| s.platform = unknown end end @@ -342,9 +342,9 @@ def test_picks_best_platform s = set - a2 = is.new s, 'a', v2, source, Gem::Platform::RUBY - a2_p1 = is.new s, 'a', v2, source, Gem::Platform.local.to_s - a3_p2 = is.new s, 'a', v3, source, unknown + a2 = is.new s, "a", v2, source, Gem::Platform::RUBY + a2_p1 = is.new s, "a", v2, source, Gem::Platform.local.to_s + a3_p2 = is.new s, "a", v3, source, unknown s.add a3_p2 s.add a2_p1 @@ -509,7 +509,7 @@ def test_raises_and_reports_a_toplevel_request_properly def test_raises_and_reports_an_implicit_request_properly a1 = util_spec "a", "1" do |s| - s.add_runtime_dependency 'b', '= 2' + s.add_runtime_dependency "b", "= 2" end ad = make_dep "a", "= 1" @@ -546,14 +546,14 @@ def test_raises_when_possibles_are_exhausted dependency = e.conflict.dependency assert_includes %w[a b], dependency.name - assert_equal req('>= 0'), dependency.requirement + assert_equal req(">= 0"), dependency.requirement activated = e.conflict.activated - assert_equal 'c-1', activated.full_name + assert_equal "c-1", activated.full_name - assert_equal dep('c', '= 1'), activated.request.dependency + assert_equal dep("c", "= 1"), activated.request.dependency - assert_equal [dep('c', '>= 2'), dep('c', '= 1')], + assert_equal [dep("c", ">= 2"), dep("c", "= 1")], e.conflict.conflicting_dependencies end @@ -617,15 +617,15 @@ def test_backtracks_to_the_first_conflict end def test_resolve_conflict - a1 = util_spec 'a', 1 - a2 = util_spec 'a', 2 + a1 = util_spec "a", 1 + a2 = util_spec "a", 2 - b2 = util_spec 'b', 2, 'a' => '~> 2.0' + b2 = util_spec "b", 2, "a" => "~> 2.0" s = set a1, a2, b2 - a_dep = dep 'a', '~> 1.0' - b_dep = dep 'b' + a_dep = dep "a", "~> 1.0" + b_dep = dep "b" r = Gem::Resolver.new [a_dep, b_dep], s @@ -635,18 +635,18 @@ def test_resolve_conflict end def test_resolve_bug_699 - a1 = util_spec 'a', '1', 'b' => '= 2', - 'c' => '~> 1.0.3' + a1 = util_spec "a", "1", "b" => "= 2", + "c" => "~> 1.0.3" - b1 = util_spec 'b', '2', 'c' => '~> 1.0' + b1 = util_spec "b", "2", "c" => "~> 1.0" - c1 = util_spec 'c', '1.0.9' - c2 = util_spec 'c', '1.1.0' - c3 = util_spec 'c', '1.2.0' + c1 = util_spec "c", "1.0.9" + c2 = util_spec "c", "1.1.0" + c3 = util_spec "c", "1.2.0" s = set a1, b1, c1, c2, c3 - a_dep = dep 'a', '= 1' + a_dep = dep "a", "= 1" r = Gem::Resolver.new [a_dep], s @@ -654,16 +654,16 @@ def test_resolve_bug_699 end def test_resolve_rollback - a1 = util_spec 'a', 1 - a2 = util_spec 'a', 2 + a1 = util_spec "a", 1 + a2 = util_spec "a", 2 - b1 = util_spec 'b', 1, 'a' => '~> 1.0' - b2 = util_spec 'b', 2, 'a' => '~> 2.0' + b1 = util_spec "b", 1, "a" => "~> 1.0" + b2 = util_spec "b", 2, "a" => "~> 2.0" s = set a1, a2, b1, b2 - a_dep = dep 'a', '~> 1.0' - b_dep = dep 'b' + a_dep = dep "a", "~> 1.0" + b_dep = dep "b" r = Gem::Resolver.new [a_dep, b_dep], s @@ -711,15 +711,15 @@ def test_second_level_backout end def test_sorts_by_source_then_version - sourceA = Gem::Source.new 'http://example.com/a' - sourceB = Gem::Source.new 'http://example.com/b' - sourceC = Gem::Source.new 'http://example.com/c' + sourceA = Gem::Source.new "http://example.com/a" + sourceB = Gem::Source.new "http://example.com/b" + sourceC = Gem::Source.new "http://example.com/c" - spec_A_1 = util_spec 'some-dep', '0.0.1' - spec_A_2 = util_spec 'some-dep', '1.0.0' - spec_B_1 = util_spec 'some-dep', '0.0.1' - spec_B_2 = util_spec 'some-dep', '0.0.2' - spec_C_1 = util_spec 'some-dep', '0.1.0' + spec_A_1 = util_spec "some-dep", "0.0.1" + spec_A_2 = util_spec "some-dep", "1.0.0" + spec_B_1 = util_spec "some-dep", "0.0.1" + spec_B_2 = util_spec "some-dep", "0.0.2" + spec_C_1 = util_spec "some-dep", "0.1.0" set = StaticSet.new [ Gem::Resolver::SpecSpecification.new(nil, spec_B_1, sourceB), @@ -729,7 +729,7 @@ def test_sorts_by_source_then_version Gem::Resolver::SpecSpecification.new(nil, spec_A_1, sourceA), ] - dependency = make_dep 'some-dep', '> 0' + dependency = make_dep "some-dep", "> 0" resolver = Gem::Resolver.new [dependency], set @@ -739,14 +739,14 @@ def test_sorts_by_source_then_version def test_select_local_platforms r = Gem::Resolver.new nil, nil - a1 = util_spec 'a', 1 + a1 = util_spec "a", 1 - a1_p1 = util_spec 'a', 1 do |s| + a1_p1 = util_spec "a", 1 do |s| s.platform = Gem::Platform.local end - a1_p2 = util_spec 'a', 1 do |s| - s.platform = 'unknown' + a1_p2 = util_spec "a", 1 do |s| + s.platform = "unknown" end selected = r.select_local_platforms [a1, a1_p1, a1_p2] @@ -755,18 +755,18 @@ def test_select_local_platforms end def test_search_for_local_platform_partial_string_match - a1 = util_spec 'a', 1 + a1 = util_spec "a", 1 - a1_p1 = util_spec 'a', 1 do |s| + a1_p1 = util_spec "a", 1 do |s| s.platform = Gem::Platform.local.os end - a1_p2 = util_spec 'a', 1 do |s| - s.platform = 'unknown' + a1_p2 = util_spec "a", 1 do |s| + s.platform = "unknown" end s = set(a1_p1, a1_p2, a1) - d = [make_dep('a')] + d = [make_dep("a")] r = Gem::Resolver.new(d, s) assert_resolves_to [a1_p1], r diff --git a/test/rubygems/test_gem_resolver_activation_request.rb b/test/rubygems/test_gem_resolver_activation_request.rb index c7b726a230e7..397eb1e10dc7 100644 --- a/test/rubygems/test_gem_resolver_activation_request.rb +++ b/test/rubygems/test_gem_resolver_activation_request.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverActivationRequest < Gem::TestCase def setup @@ -7,12 +7,12 @@ def setup @DR = Gem::Resolver - @dep = @DR::DependencyRequest.new dep('a', '>= 0'), nil + @dep = @DR::DependencyRequest.new dep("a", ">= 0"), nil source = Gem::Source::Local.new platform = Gem::Platform::RUBY - @a3 = @DR::IndexSpecification.new nil, 'a', v(3), source, platform + @a3 = @DR::IndexSpecification.new nil, "a", v(3), source, platform @req = @DR::ActivationRequest.new @a3, @dep end @@ -20,7 +20,7 @@ def setup def test_development_eh refute @req.development? - dep_req = @DR::DependencyRequest.new dep('a', '>= 0', :development), nil + dep_req = @DR::DependencyRequest.new dep("a", ">= 0", :development), nil act_req = @DR::ActivationRequest.new @a3, dep_req @@ -28,8 +28,8 @@ def test_development_eh end def test_inspect - assert_match 'a-3', @req.inspect - assert_match 'from a (>= 0)', @req.inspect + assert_match "a-3", @req.inspect + assert_match "from a (>= 0)", @req.inspect end def test_installed_eh diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb index c3db25d7aa5e..5c13311b1b38 100644 --- a/test/rubygems/test_gem_resolver_api_set.rb +++ b/test/rubygems/test_gem_resolver_api_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverAPISet < Gem::TestCase def setup @@ -12,17 +12,17 @@ def setup def test_initialize set = @DR::APISet.new - assert_equal URI('https://index.rubygems.org/info/'), set.dep_uri - assert_equal URI('https://index.rubygems.org/'), set.uri - assert_equal Gem::Source.new(URI('https://index.rubygems.org')), set.source + assert_equal URI("https://index.rubygems.org/info/"), set.dep_uri + assert_equal URI("https://index.rubygems.org/"), set.uri + assert_equal Gem::Source.new(URI("https://index.rubygems.org")), set.source end def test_initialize_deeper_uri - set = @DR::APISet.new 'https://rubygemsserver.com/mygems/info' + set = @DR::APISet.new "https://rubygemsserver.com/mygems/info" - assert_equal URI('https://rubygemsserver.com/mygems/info'), set.dep_uri - assert_equal URI('https://rubygemsserver.com/'), set.uri - assert_equal Gem::Source.new(URI('https://rubygemsserver.com/')), set.source + assert_equal URI("https://rubygemsserver.com/mygems/info"), set.dep_uri + assert_equal URI("https://rubygemsserver.com/"), set.uri + assert_equal Gem::Source.new(URI("https://rubygemsserver.com/")), set.source end def test_initialize_uri @@ -36,9 +36,9 @@ def test_find_all spec_fetcher data = [ - { :name => 'a', - :number => '1', - :platform => 'ruby', + { :name => "a", + :number => "1", + :platform => "ruby", :dependencies => [] }, ] @@ -46,7 +46,7 @@ def test_find_all set = @DR::APISet.new @dep_uri - a_dep = @DR::DependencyRequest.new dep('a'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil expected = [ @DR::APISpecification.new(set, data.first), @@ -59,13 +59,13 @@ def test_find_all_prereleases spec_fetcher data = [ - { :name => 'a', - :number => '1', - :platform => 'ruby', + { :name => "a", + :number => "1", + :platform => "ruby", :dependencies => [] }, - { :name => 'a', - :number => '2.a', - :platform => 'ruby', + { :name => "a", + :number => "2.a", + :platform => "ruby", :dependencies => [] }, ] @@ -74,7 +74,7 @@ def test_find_all_prereleases set = @DR::APISet.new @dep_uri set.prerelease = true - a_dep = @DR::DependencyRequest.new dep('a'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil expected = [ @DR::APISpecification.new(set, data.first), @@ -88,9 +88,9 @@ def test_find_all_cache spec_fetcher data = [ - { :name => 'a', - :number => '1', - :platform => 'ruby', + { :name => "a", + :number => "1", + :platform => "ruby", :dependencies => [] }, ] @@ -98,7 +98,7 @@ def test_find_all_cache set = @DR::APISet.new @dep_uri - a_dep = @DR::DependencyRequest.new dep('a'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil set.prefetch [a_dep] @@ -115,7 +115,7 @@ def test_find_all_local set = @DR::APISet.new @dep_uri set.remote = false - a_dep = @DR::DependencyRequest.new dep('a'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil assert_empty set.find_all(a_dep) end @@ -127,7 +127,7 @@ def test_find_all_missing set = @DR::APISet.new @dep_uri - a_dep = @DR::DependencyRequest.new dep('a'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil assert_empty set.find_all(a_dep) @@ -144,8 +144,8 @@ def test_prefetch set = @DR::APISet.new @dep_uri - a_dep = @DR::DependencyRequest.new dep('a'), nil - b_dep = @DR::DependencyRequest.new dep('b'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil + b_dep = @DR::DependencyRequest.new dep("b"), nil set.prefetch [a_dep, b_dep] @@ -160,8 +160,8 @@ def test_prefetch_cache set = @DR::APISet.new @dep_uri - a_dep = @DR::DependencyRequest.new dep('a'), nil - b_dep = @DR::DependencyRequest.new dep('b'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil + b_dep = @DR::DependencyRequest.new dep("b"), nil set.prefetch [a_dep] @@ -179,8 +179,8 @@ def test_prefetch_cache_missing set = @DR::APISet.new @dep_uri - a_dep = @DR::DependencyRequest.new dep('a'), nil - b_dep = @DR::DependencyRequest.new dep('b'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil + b_dep = @DR::DependencyRequest.new dep("b"), nil set.prefetch [a_dep, b_dep] @@ -199,8 +199,8 @@ def test_prefetch_local set = @DR::APISet.new @dep_uri set.remote = false - a_dep = @DR::DependencyRequest.new dep('a'), nil - b_dep = @DR::DependencyRequest.new dep('b'), nil + a_dep = @DR::DependencyRequest.new dep("a"), nil + b_dep = @DR::DependencyRequest.new dep("b"), nil set.prefetch [a_dep, b_dep] diff --git a/test/rubygems/test_gem_resolver_api_specification.rb b/test/rubygems/test_gem_resolver_api_specification.rb index 3f9b81868f16..98981e53e945 100644 --- a/test/rubygems/test_gem_resolver_api_specification.rb +++ b/test/rubygems/test_gem_resolver_api_specification.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverAPISpecification < Gem::TestCase def test_initialize set = Gem::Resolver::APISet.new data = { - :name => 'rails', - :number => '3.0.3', + :name => "rails", + :number => "3.0.3", :platform => Gem::Platform.local.to_s, :dependencies => [ - ['bundler', '~> 1.0'], - ['railties', '= 3.0.3'], + ["bundler", "~> 1.0"], + ["railties", "= 3.0.3"], ], } spec = Gem::Resolver::APISpecification.new set, data - assert_equal 'rails', spec.name - assert_equal Gem::Version.new('3.0.3'), spec.version + assert_equal "rails", spec.name + assert_equal Gem::Version.new("3.0.3"), spec.version assert_equal Gem::Platform.local, spec.platform expected = [ - Gem::Dependency.new('bundler', '~> 1.0'), - Gem::Dependency.new('railties', '= 3.0.3'), + Gem::Dependency.new("bundler", "~> 1.0"), + Gem::Dependency.new("railties", "= 3.0.3"), ] assert_equal expected, spec.dependencies @@ -30,26 +30,26 @@ def test_initialize def test_fetch_development_dependencies specs = spec_fetcher do |fetcher| - fetcher.spec 'rails', '3.0.3' do |s| - s.add_runtime_dependency 'bundler', '~> 1.0' - s.add_runtime_dependency 'railties', '= 3.0.3' - s.add_development_dependency 'a', '= 1' + fetcher.spec "rails", "3.0.3" do |s| + s.add_runtime_dependency "bundler", "~> 1.0" + s.add_runtime_dependency "railties", "= 3.0.3" + s.add_development_dependency "a", "= 1" end end - rails = specs['rails-3.0.3'] + rails = specs["rails-3.0.3"] - repo = @gem_repo + 'info' + repo = @gem_repo + "info" set = Gem::Resolver::APISet.new repo data = { - :name => 'rails', - :number => '3.0.3', - :platform => 'ruby', + :name => "rails", + :number => "3.0.3", + :platform => "ruby", :dependencies => [ - ['bundler', '~> 1.0'], - ['railties', '= 3.0.3'], + ["bundler", "~> 1.0"], + ["railties", "= 3.0.3"], ], } @@ -60,9 +60,9 @@ def test_fetch_development_dependencies spec.fetch_development_dependencies expected = [ - Gem::Dependency.new('bundler', '~> 1.0'), - Gem::Dependency.new('railties', '= 3.0.3'), - Gem::Dependency.new('a', '= 1', :development), + Gem::Dependency.new("bundler", "~> 1.0"), + Gem::Dependency.new("railties", "= 3.0.3"), + Gem::Dependency.new("a", "= 1", :development), ] assert_equal expected, spec.dependencies @@ -71,9 +71,9 @@ def test_fetch_development_dependencies def test_installable_platform_eh set = Gem::Resolver::APISet.new data = { - :name => 'a', - :number => '1', - :platform => 'ruby', + :name => "a", + :number => "1", + :platform => "ruby", :dependencies => [], } @@ -82,9 +82,9 @@ def test_installable_platform_eh assert a_spec.installable_platform? data = { - :name => 'b', - :number => '1', - :platform => 'cpu-other_platform-1', + :name => "b", + :number => "1", + :platform => "cpu-other_platform-1", :dependencies => [], } @@ -93,8 +93,8 @@ def test_installable_platform_eh refute b_spec.installable_platform? data = { - :name => 'c', - :number => '1', + :name => "c", + :number => "1", :platform => Gem::Platform.local.to_s, :dependencies => [], } @@ -107,9 +107,9 @@ def test_installable_platform_eh def test_source set = Gem::Resolver::APISet.new data = { - :name => 'a', - :number => '1', - :platform => 'ruby', + :name => "a", + :number => "1", + :platform => "ruby", :dependencies => [], } @@ -120,15 +120,15 @@ def test_source def test_spec spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end - dep_uri = URI(@gem_repo) + 'info' + dep_uri = URI(@gem_repo) + "info" set = Gem::Resolver::APISet.new dep_uri data = { - :name => 'a', - :number => '1', - :platform => 'ruby', + :name => "a", + :number => "1", + :platform => "ruby", :dependencies => [], } @@ -137,22 +137,22 @@ def test_spec spec = api_spec.spec assert_kind_of Gem::Specification, spec - assert_equal 'a-1', spec.full_name + assert_equal "a-1", spec.full_name end def test_spec_jruby_platform spec_fetcher do |fetcher| - fetcher.gem 'j', 1 do |spec| - spec.platform = 'jruby' + fetcher.gem "j", 1 do |spec| + spec.platform = "jruby" end end - dep_uri = URI(@gem_repo) + 'info' + dep_uri = URI(@gem_repo) + "info" set = Gem::Resolver::APISet.new dep_uri data = { - :name => 'j', - :number => '1', - :platform => 'jruby', + :name => "j", + :number => "1", + :platform => "jruby", :dependencies => [], } @@ -161,6 +161,6 @@ def test_spec_jruby_platform spec = api_spec.spec assert_kind_of Gem::Specification, spec - assert_equal 'j-1-java', spec.full_name + assert_equal "j-1-java", spec.full_name end end diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb index 0e279d16a868..c1c67ba8324b 100644 --- a/test/rubygems/test_gem_resolver_best_set.rb +++ b/test/rubygems/test_gem_resolver_best_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverBestSet < Gem::TestCase def setup @@ -16,14 +16,14 @@ def test_initialize def test_find_all_index spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'b', 1 + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "b", 1 end set = @DR::BestSet.new - dependency = dep 'a', '~> 1' + dependency = dep "a", "~> 1" req = @DR::DependencyRequest.new dependency, nil @@ -34,7 +34,7 @@ def test_find_all_index def test_find_all_fallback spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end set = @DR::BestSet.new @@ -43,7 +43,7 @@ def test_find_all_fallback set.sets << Gem::Resolver::APISet.new(api_uri) - dependency = dep 'a', '~> 1' + dependency = dep "a", "~> 1" req = @DR::DependencyRequest.new dependency, nil @@ -54,15 +54,15 @@ def test_find_all_fallback def test_find_all_local spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'b', 1 + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "b", 1 end set = @DR::BestSet.new set.remote = false - dependency = dep 'a', '~> 1' + dependency = dep "a", "~> 1" req = @DR::DependencyRequest.new dependency, nil @@ -73,7 +73,7 @@ def test_find_all_local def test_prefetch spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end set = @DR::BestSet.new @@ -85,7 +85,7 @@ def test_prefetch def test_prefetch_local spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end set = @DR::BestSet.new @@ -99,14 +99,14 @@ def test_prefetch_local def test_replace_failed_api_set set = @DR::BestSet.new - api_uri = URI(@gem_repo) + './info/' + api_uri = URI(@gem_repo) + "./info/" api_set = Gem::Resolver::APISet.new api_uri set.sets << api_set - error_uri = api_uri + 'a' + error_uri = api_uri + "a" - error = Gem::RemoteFetcher::FetchError.new 'bogus', error_uri + error = Gem::RemoteFetcher::FetchError.new "bogus", error_uri set.replace_failed_api_set error @@ -124,7 +124,7 @@ def test_replace_failed_api_set_no_api_set set.sets << index_set - error = Gem::RemoteFetcher::FetchError.new 'bogus', @gem_repo + error = Gem::RemoteFetcher::FetchError.new "bogus", @gem_repo e = assert_raise Gem::RemoteFetcher::FetchError do set.replace_failed_api_set error @@ -136,16 +136,16 @@ def test_replace_failed_api_set_no_api_set def test_replace_failed_api_set_uri_with_credentials set = @DR::BestSet.new - api_uri = URI(@gem_repo) + './info/' - api_uri.user = 'user' - api_uri.password = 'pass' + api_uri = URI(@gem_repo) + "./info/" + api_uri.user = "user" + api_uri.password = "pass" api_set = Gem::Resolver::APISet.new api_uri set.sets << api_set - error_uri = api_uri + 'a' + error_uri = api_uri + "a" - error = Gem::RemoteFetcher::FetchError.new 'bogus', error_uri + error = Gem::RemoteFetcher::FetchError.new "bogus", error_uri set.replace_failed_api_set error diff --git a/test/rubygems/test_gem_resolver_composed_set.rb b/test/rubygems/test_gem_resolver_composed_set.rb index 405753a37301..5feceebb34e9 100644 --- a/test/rubygems/test_gem_resolver_composed_set.rb +++ b/test/rubygems/test_gem_resolver_composed_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverComposedSet < Gem::TestCase def test_errors diff --git a/test/rubygems/test_gem_resolver_conflict.rb b/test/rubygems/test_gem_resolver_conflict.rb index 1d46e69c3f84..8bee6699c88c 100644 --- a/test/rubygems/test_gem_resolver_conflict.rb +++ b/test/rubygems/test_gem_resolver_conflict.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverConflict < Gem::TestCase def test_explanation root = - dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8' + dependency_request dep("net-ssh", ">= 2.0.13"), "rye", "0.9.8" child = - dependency_request dep('net-ssh', '>= 2.6.5'), 'net-ssh', '2.2.2', root + dependency_request dep("net-ssh", ">= 2.6.5"), "net-ssh", "2.2.2", root - dep = Gem::Resolver::DependencyRequest.new dep('net-ssh', '>= 2.0.13'), nil + dep = Gem::Resolver::DependencyRequest.new dep("net-ssh", ">= 2.0.13"), nil - spec = util_spec 'net-ssh', '2.2.2' + spec = util_spec "net-ssh", "2.2.2" active = Gem::Resolver::ActivationRequest.new spec, dep @@ -37,10 +37,10 @@ def test_explanation def test_explanation_user_request @DR = Gem::Resolver - spec = util_spec 'a', 2 + spec = util_spec "a", 2 - a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil - a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil + a1_req = @DR::DependencyRequest.new dep("a", "= 1"), nil + a2_req = @DR::DependencyRequest.new dep("a", "= 2"), nil activated = @DR::ActivationRequest.new spec, a2_req @@ -63,17 +63,17 @@ def test_explanation_user_request def test_request_path root = - dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8' + dependency_request dep("net-ssh", ">= 2.0.13"), "rye", "0.9.8" child = - dependency_request dep('other', '>= 1.0'), 'net-ssh', '2.2.2', root + dependency_request dep("other", ">= 1.0"), "net-ssh", "2.2.2", root conflict = Gem::Resolver::Conflict.new nil, nil expected = [ - 'net-ssh (>= 2.0.13), 2.2.2 activated', - 'rye (= 0.9.8), 0.9.8 activated', + "net-ssh (>= 2.0.13), 2.2.2 activated", + "rye (= 0.9.8), 0.9.8 activated", ] assert_equal expected, conflict.request_path(child.requester) diff --git a/test/rubygems/test_gem_resolver_dependency_request.rb b/test/rubygems/test_gem_resolver_dependency_request.rb index cea0a7952d35..6ad3a090283a 100644 --- a/test/rubygems/test_gem_resolver_dependency_request.rb +++ b/test/rubygems/test_gem_resolver_dependency_request.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverDependencyRequest < Gem::TestCase def setup @@ -9,13 +9,13 @@ def setup end def test_development_eh - a_dep = dep 'a', '>= 1' + a_dep = dep "a", ">= 1" a_dep_req = @DR.new a_dep, nil refute a_dep_req.development? - b_dep = dep 'b', '>= 1', :development + b_dep = dep "b", ">= 1", :development b_dep_req = @DR.new b_dep, nil @@ -23,8 +23,8 @@ def test_development_eh end def test_match_eh - spec = util_spec 'a', 1 - dependency = dep 'a', '>= 1' + spec = util_spec "a", 1 + dependency = dep "a", ">= 1" dr = @DR.new dependency, nil @@ -32,31 +32,31 @@ def test_match_eh end def test_match_eh_prerelease - spec = util_spec 'a', '1.a' + spec = util_spec "a", "1.a" - a_dep = dep 'a', '>= 1' + a_dep = dep "a", ">= 1" a_dr = @DR.new a_dep, nil refute a_dr.match? spec - a_pre_dep = dep 'a', '>= 1.a' + a_pre_dep = dep "a", ">= 1.a" a_pre_dr = @DR.new a_pre_dep, nil assert a_pre_dr.match? spec end def test_match_eh_prerelease_allow_prerelease - spec = util_spec 'a', '2.a' + spec = util_spec "a", "2.a" - a_dep = dep 'a', '>= 1' + a_dep = dep "a", ">= 1" a_dr = @DR.new a_dep, nil assert a_dr.match? spec, true end def test_matches_spec_eh - spec = util_spec 'a', 1 - dependency = dep 'a', '>= 1' + spec = util_spec "a", 1 + dependency = dep "a", ">= 1" dr = @DR.new dependency, nil @@ -64,16 +64,16 @@ def test_matches_spec_eh end def test_matches_spec_eh_prerelease - spec = util_spec 'a', '1.a' + spec = util_spec "a", "1.a" - dependency = dep 'a', '>= 0' + dependency = dep "a", ">= 0" dr = @DR.new dependency, nil assert dr.matches_spec? spec end def test_requirement - dependency = dep 'a', '>= 1' + dependency = dep "a", ">= 1" dr = @DR.new dependency, nil diff --git a/test/rubygems/test_gem_resolver_git_set.rb b/test/rubygems/test_gem_resolver_git_set.rb index 145cd6c7dfc4..f7063b3d454f 100644 --- a/test/rubygems/test_gem_resolver_git_set.rb +++ b/test/rubygems/test_gem_resolver_git_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverGitSet < Gem::TestCase def setup @@ -13,9 +13,9 @@ def setup def test_add_git_gem name, version, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false - dependency = dep 'a' + dependency = dep "a" specs = @set.find_all dependency @@ -27,9 +27,9 @@ def test_add_git_gem def test_add_git_gem_submodules name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', true + @set.add_git_gem name, repository, "master", true - dependency = dep 'a' + dependency = dep "a" refute_empty @set.find_all dependency @@ -41,7 +41,7 @@ def test_add_git_spec @set.add_git_spec name, version, repository, revision, true - dependency = dep 'a' + dependency = dep "a" specs = @set.find_all dependency @@ -57,9 +57,9 @@ def test_add_git_spec def test_find_all name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false - dependency = dep 'a', '~> 1.0' + dependency = dep "a", "~> 1.0" req = Gem::Resolver::DependencyRequest.new dependency, nil @reqs.add req @@ -67,16 +67,16 @@ def test_find_all found = @set.find_all dependency - assert_equal [@set.specs['a']], found + assert_equal [@set.specs["a"]], found end def test_find_all_local name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false @set.remote = false - dependency = dep 'a', '~> 1.0' + dependency = dep "a", "~> 1.0" req = Gem::Resolver::DependencyRequest.new dependency, nil @reqs.add req @@ -86,11 +86,11 @@ def test_find_all_local end def test_find_all_prerelease - name, _, repository, = git_gem 'a', '1.a' + name, _, repository, = git_gem "a", "1.a" - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false - dependency = dep 'a', '>= 0' + dependency = dep "a", ">= 0" req = Gem::Resolver::DependencyRequest.new dependency, nil @reqs.add req @@ -100,7 +100,7 @@ def test_find_all_prerelease assert_empty found - dependency = dep 'a', '>= 0.a' + dependency = dep "a", ">= 0.a" req = Gem::Resolver::DependencyRequest.new dependency, nil @reqs.add req @@ -122,7 +122,7 @@ def test_root_dir def test_prefetch name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false dependency = dep name req = Gem::Resolver::DependencyRequest.new dependency, nil @@ -136,7 +136,7 @@ def test_prefetch def test_prefetch_cache name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false dependency = dep name req = Gem::Resolver::DependencyRequest.new dependency, nil @@ -154,21 +154,21 @@ def test_prefetch_cache def test_prefetch_filter name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false - dependency = dep 'b' + dependency = dep "b" req = Gem::Resolver::DependencyRequest.new dependency, nil @reqs.add req @set.prefetch @reqs - refute_empty @set.specs, 'the git source does not filter' + refute_empty @set.specs, "the git source does not filter" end def test_prefetch_root_dir name, _, repository, = git_gem - @set.add_git_gem name, repository, 'master', false + @set.add_git_gem name, repository, "master", false dependency = dep name req = Gem::Resolver::DependencyRequest.new dependency, nil diff --git a/test/rubygems/test_gem_resolver_git_specification.rb b/test/rubygems/test_gem_resolver_git_specification.rb index 857452c15995..fef071aa7632 100644 --- a/test/rubygems/test_gem_resolver_git_specification.rb +++ b/test/rubygems/test_gem_resolver_git_specification.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/installer' +require_relative "helper" +require "rubygems/installer" class TestGemResolverGitSpecification < Gem::TestCase def setup super @set = Gem::Resolver::GitSet.new - @spec = Gem::Specification.new 'a', 1 + @spec = Gem::Specification.new "a", 1 end def test_equals2 @@ -15,7 +15,7 @@ def test_equals2 assert_equal g_spec_a, g_spec_a - spec_b = Gem::Specification.new 'b', 1 + spec_b = Gem::Specification.new "b", 1 g_spec_b = Gem::Resolver::GitSpecification.new @set, spec_b refute_equal g_spec_a, g_spec_b @@ -28,17 +28,17 @@ def test_equals2 i_set = Gem::Resolver::IndexSet.new source = Gem::Source.new @gem_repo i_spec = Gem::Resolver::IndexSpecification.new( - i_set, 'a', v(1), source, Gem::Platform::RUBY) + i_set, "a", v(1), source, Gem::Platform::RUBY) refute_equal g_spec_a, i_spec end def test_add_dependency - git_gem 'a', 1 + git_gem "a", 1 git_spec = Gem::Resolver::GitSpecification.new @set, @spec - b_dep = dep 'b' + b_dep = dep "b" git_spec.add_dependency b_dep @@ -46,7 +46,7 @@ def test_add_dependency end def test_install - git_gem 'a', 1 + git_gem "a", 1 git_spec = Gem::Resolver::GitSpecification.new @set, @spec @@ -63,28 +63,28 @@ def test_install def test_install_extension pend if Gem.java_platform? - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning - name, _, repository, = git_gem 'a', 1 do |s| - s.extensions << 'ext/extconf.rb' + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + name, _, repository, = git_gem "a", 1 do |s| + s.extensions << "ext/extconf.rb" end - Dir.chdir 'git/a' do - FileUtils.mkdir_p 'ext/lib' + Dir.chdir "git/a" do + FileUtils.mkdir_p "ext/lib" - File.open 'ext/extconf.rb', 'w' do |io| + File.open "ext/extconf.rb", "w" do |io| io.puts 'require "mkmf"' io.puts 'create_makefile "a"' end - FileUtils.touch 'ext/lib/b.rb' + FileUtils.touch "ext/lib/b.rb" - system @git, 'add', 'ext/extconf.rb' - system @git, 'add', 'ext/lib/b.rb' + system @git, "add", "ext/extconf.rb" + system @git, "add", "ext/lib/b.rb" - system @git, 'commit', '--quiet', '-m', 'Add extension files' + system @git, "commit", "--quiet", "-m", "Add extension files" end - source = Gem::Source::Git.new name, repository, 'master', true + source = Gem::Source::Git.new name, repository, "master", true spec = source.specs.first @@ -92,11 +92,11 @@ def test_install_extension git_spec.install({}) - assert_path_exist File.join git_spec.spec.extension_dir, 'b.rb' + assert_path_exist File.join git_spec.spec.extension_dir, "b.rb" end def test_install_installed - git_gem 'a', 1 + git_gem "a", 1 git_spec = Gem::Resolver::GitSpecification.new @set, @spec diff --git a/test/rubygems/test_gem_resolver_index_set.rb b/test/rubygems/test_gem_resolver_index_set.rb index ddae0c2b82d2..3b8f04780885 100644 --- a/test/rubygems/test_gem_resolver_index_set.rb +++ b/test/rubygems/test_gem_resolver_index_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverIndexSet < Gem::TestCase def setup @@ -17,7 +17,7 @@ def test_initialize end def test_initialize_source - set = @DR::IndexSet.new 'http://alternate.example' + set = @DR::IndexSet.new "http://alternate.example" fetcher = set.instance_variable_get :@f @@ -28,14 +28,14 @@ def test_initialize_source def test_find_all spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'b', 1 + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "b", 1 end set = @DR::IndexSet.new - dependency = dep 'a', '~> 1' + dependency = dep "a", "~> 1" req = @DR::DependencyRequest.new dependency, nil @@ -46,15 +46,15 @@ def test_find_all def test_find_all_local spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'b', 1 + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "b", 1 end set = @DR::IndexSet.new set.remote = false - dependency = dep 'a', '~> 1' + dependency = dep "a", "~> 1" req = @DR::DependencyRequest.new dependency, nil @@ -63,12 +63,12 @@ def test_find_all_local def test_find_all_prerelease spec_fetcher do |fetcher| - fetcher.spec 'a', '1.a' + fetcher.spec "a", "1.a" end set = @DR::IndexSet.new - dependency = dep 'a' + dependency = dep "a" req = @DR::DependencyRequest.new dependency, nil diff --git a/test/rubygems/test_gem_resolver_index_specification.rb b/test/rubygems/test_gem_resolver_index_specification.rb index ef9c17034e54..339445cb4458 100644 --- a/test/rubygems/test_gem_resolver_index_specification.rb +++ b/test/rubygems/test_gem_resolver_index_specification.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/available_set' +require_relative "helper" +require "rubygems/available_set" class TestGemResolverIndexSpecification < Gem::TestCase def test_initialize set = Gem::Resolver::IndexSet.new source = Gem::Source.new @gem_repo - version = Gem::Version.new '3.0.3' + version = Gem::Version.new "3.0.3" spec = Gem::Resolver::IndexSpecification.new( - set, 'rails', version, source, Gem::Platform::RUBY) + set, "rails", version, source, Gem::Platform::RUBY) - assert_equal 'rails', spec.name + assert_equal "rails", spec.name assert_equal version, spec.version assert_equal Gem::Platform::RUBY, spec.platform @@ -21,24 +21,24 @@ def test_initialize def test_initialize_platform set = Gem::Resolver::IndexSet.new source = Gem::Source::Local.new - version = Gem::Version.new '3.0.3' + version = Gem::Version.new "3.0.3" spec = Gem::Resolver::IndexSpecification.new( - set, 'rails', version, source, Gem::Platform.local) + set, "rails", version, source, Gem::Platform.local) assert_equal Gem::Platform.local.to_s, spec.platform end def test_install spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end set = Gem::Resolver::IndexSet.new source = Gem::Source.new @gem_repo spec = Gem::Resolver::IndexSpecification.new( - set, 'a', v(2), source, Gem::Platform::RUBY) + set, "a", v(2), source, Gem::Platform::RUBY) called = false @@ -46,15 +46,15 @@ def test_install called = installer end - assert_path_exist File.join @gemhome, 'specifications', 'a-2.gemspec' + assert_path_exist File.join @gemhome, "specifications", "a-2.gemspec" assert_kind_of Gem::Installer, called end def test_spec specs = spec_fetcher do |fetcher| - fetcher.spec 'a', 2 - fetcher.spec 'a', 2 do |s| + fetcher.spec "a", 2 + fetcher.spec "a", 2 do |s| s.platform = Gem::Platform.local end end @@ -64,7 +64,7 @@ def test_spec set = Gem::Resolver::IndexSet.new i_spec = Gem::Resolver::IndexSpecification.new \ - set, 'a', version, source, Gem::Platform.local + set, "a", version, source, Gem::Platform.local spec = i_spec.spec @@ -72,7 +72,7 @@ def test_spec end def test_spec_local - a_2_p = util_spec 'a', 2 do |s| + a_2_p = util_spec "a", 2 do |s| s.platform = Gem::Platform.local end @@ -83,7 +83,7 @@ def test_spec_local set.always_install << a_2_p i_spec = Gem::Resolver::IndexSpecification.new \ - set, 'a', v(2), source, Gem::Platform.local + set, "a", v(2), source, Gem::Platform.local spec = i_spec.spec diff --git a/test/rubygems/test_gem_resolver_installed_specification.rb b/test/rubygems/test_gem_resolver_installed_specification.rb index 0e5ea02fb999..156a88144da4 100644 --- a/test/rubygems/test_gem_resolver_installed_specification.rb +++ b/test/rubygems/test_gem_resolver_installed_specification.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverInstalledSpecification < Gem::TestCase def setup @@ -9,17 +9,17 @@ def setup end def test_initialize - source_spec = util_spec 'a' + source_spec = util_spec "a" spec = Gem::Resolver::InstalledSpecification.new @set, source_spec - assert_equal 'a', spec.name + assert_equal "a", spec.name assert_equal Gem::Version.new(2), spec.version assert_equal Gem::Platform::RUBY, spec.platform end def test_install - a = util_spec 'a' + a = util_spec "a" spec = Gem::Resolver::InstalledSpecification.new @set, a @@ -33,7 +33,7 @@ def test_install end def test_installable_platform_eh - b, b_gem = util_gem 'a', 1 do |s| + b, b_gem = util_gem "a", 1 do |s| s.platform = Gem::Platform.new %w[cpu other_platform 1] end diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb index 7a6d17f2b0d5..8d84c28172a7 100644 --- a/test/rubygems/test_gem_resolver_installer_set.rb +++ b/test/rubygems/test_gem_resolver_installer_set.rb @@ -1,26 +1,26 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverInstallerSet < Gem::TestCase def test_add_always_install spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 + fetcher.download "a", 1 + fetcher.download "a", 2 end - util_gem 'a', 1 + util_gem "a", 1 set = Gem::Resolver::InstallerSet.new :both - set.add_always_install dep('a') + set.add_always_install dep("a") assert_equal %w[a-2], set.always_install.map {|s| s.full_name } e = assert_raise Gem::UnsatisfiableDependencyError do - set.add_always_install dep('b') + set.add_always_install dep("b") end - assert_equal dep('b'), e.dependency.dependency + assert_equal dep("b"), e.dependency.dependency end def test_add_always_install_errors @@ -30,7 +30,7 @@ def test_add_always_install_errors set = Gem::Resolver::InstallerSet.new :both e = assert_raise Gem::UnsatisfiableDependencyError do - set.add_always_install dep 'a' + set.add_always_install dep "a" end refute_empty e.errors @@ -38,64 +38,64 @@ def test_add_always_install_errors def test_add_always_install_platform spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 do |s| - s.platform = Gem::Platform.new 'x86-freebsd-9' + fetcher.download "a", 1 + fetcher.download "a", 2 do |s| + s.platform = Gem::Platform.new "x86-freebsd-9" end end set = Gem::Resolver::InstallerSet.new :both - set.add_always_install dep('a') + set.add_always_install dep("a") assert_equal %w[a-1], set.always_install.map {|s| s.full_name } end def test_add_always_install_prerelease spec_fetcher do |fetcher| - fetcher.gem 'a', 1 - fetcher.gem 'a', '3.a' + fetcher.gem "a", 1 + fetcher.gem "a", "3.a" end set = Gem::Resolver::InstallerSet.new :both - set.add_always_install dep('a') + set.add_always_install dep("a") assert_equal %w[a-1], set.always_install.map {|s| s.full_name } end def test_add_always_install_prerelease_github_problem spec_fetcher do |fetcher| - fetcher.gem 'a', 1 + fetcher.gem "a", 1 end # Github has an issue in which it will generate a misleading prerelease output in its RubyGems server API and # returns a 0 version for the gem while it doesn't exist. @fetcher.data["#{@gem_repo}prerelease_specs.#{Gem.marshal_version}.gz"] = util_gzip(Marshal.dump([ - Gem::NameTuple.new('a', Gem::Version.new(0), 'ruby'), + Gem::NameTuple.new("a", Gem::Version.new(0), "ruby"), ])) set = Gem::Resolver::InstallerSet.new :both - set.add_always_install dep('a') + set.add_always_install dep("a") assert_equal %w[a-1], set.always_install.map {|s| s.full_name } end def test_add_always_install_prerelease_only spec_fetcher do |fetcher| - fetcher.gem 'a', '3.a' + fetcher.gem "a", "3.a" end set = Gem::Resolver::InstallerSet.new :both assert_raise Gem::UnsatisfiableDependencyError do - set.add_always_install dep('a') + set.add_always_install dep("a") end end def test_add_local - a_1, a_1_gem = util_gem 'a', 1 + a_1, a_1_gem = util_gem "a", 1 a_1_source = Gem::Source::SpecificFile.new a_1_gem @@ -108,7 +108,7 @@ def test_add_local FileUtils.rm a_1_gem util_clear_gems - req = Gem::Resolver::DependencyRequest.new dep('a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a"), nil assert_equal %w[a-1], set.find_all(req).map {|spec| spec.full_name } end @@ -146,7 +146,7 @@ def test_errors set.instance_variable_get(:@errors) << :a - req = Gem::Resolver::DependencyRequest.new dep('a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a"), nil set.find_all req @@ -155,33 +155,33 @@ def test_errors def test_find_all_always_install spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 end - util_gem 'a', 1 + util_gem "a", 1 set = Gem::Resolver::InstallerSet.new :both - set.add_always_install dep 'a' + set.add_always_install dep "a" - req = Gem::Resolver::DependencyRequest.new dep('a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a"), nil assert_equal %w[a-2], set.find_all(req).map {|spec| spec.full_name } end def test_find_all_prerelease spec_fetcher do |fetcher| - fetcher.download 'a', '1' - fetcher.download 'a', '1.a' + fetcher.download "a", "1" + fetcher.download "a", "1.a" end set = Gem::Resolver::InstallerSet.new :both - req = Gem::Resolver::DependencyRequest.new dep('a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a"), nil assert_equal %w[a-1], set.find_all(req).map {|spec| spec.full_name } - req = Gem::Resolver::DependencyRequest.new dep('a', '>= 0.a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a", ">= 0.a"), nil assert_equal %w[a-1 a-1.a], set.find_all(req).map {|spec| spec.full_name }.sort @@ -189,8 +189,8 @@ def test_find_all_prerelease def test_load_spec specs = spec_fetcher do |fetcher| - fetcher.spec 'a', 2 - fetcher.spec 'a', 2 do |s| + fetcher.spec "a", 2 + fetcher.spec "a", 2 do |s| s.platform = Gem::Platform.local end end @@ -200,7 +200,7 @@ def test_load_spec set = Gem::Resolver::InstallerSet.new :remote - spec = set.load_spec 'a', version, Gem::Platform.local, source + spec = set.load_spec "a", version, Gem::Platform.local, source assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name end diff --git a/test/rubygems/test_gem_resolver_local_specification.rb b/test/rubygems/test_gem_resolver_local_specification.rb index c11f73612829..4ada391cb96d 100644 --- a/test/rubygems/test_gem_resolver_local_specification.rb +++ b/test/rubygems/test_gem_resolver_local_specification.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/available_set' +require_relative "helper" +require "rubygems/available_set" class TestGemResolverLocalSpecification < Gem::TestCase def setup @@ -11,12 +11,12 @@ def setup def test_install specs = spec_fetcher do |fetcher| - fetcher.gem 'a', 2 + fetcher.gem "a", 2 end - source = Gem::Source::SpecificFile.new 'gems/a-2.gem' + source = Gem::Source::SpecificFile.new "gems/a-2.gem" - spec = Gem::Resolver::LocalSpecification.new @set, specs['a-2'], source + spec = Gem::Resolver::LocalSpecification.new @set, specs["a-2"], source called = false @@ -24,13 +24,13 @@ def test_install called = installer end - assert_path_exist File.join @gemhome, 'specifications', 'a-2.gemspec' + assert_path_exist File.join @gemhome, "specifications", "a-2.gemspec" assert_kind_of Gem::Installer, called end def test_installable_platform_eh - b, b_gem = util_gem 'a', 1 do |s| + b, b_gem = util_gem "a", 1 do |s| s.platform = Gem::Platform.new %w[cpu other_platform 1] end diff --git a/test/rubygems/test_gem_resolver_lock_set.rb b/test/rubygems/test_gem_resolver_lock_set.rb index dc7767a3f829..e01d73093c1b 100644 --- a/test/rubygems/test_gem_resolver_lock_set.rb +++ b/test/rubygems/test_gem_resolver_lock_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverLockSet < Gem::TestCase def setup @@ -12,7 +12,7 @@ def setup end def test_add - specs = @set.add 'a', '2', Gem::Platform::RUBY + specs = @set.add "a", "2", Gem::Platform::RUBY spec = specs.first assert_equal %w[a-2], @set.specs.map {|t| t.full_name } @@ -20,39 +20,39 @@ def test_add assert_kind_of Gem::Resolver::LockSpecification, spec assert_equal @set, spec.set - assert_equal 'a', spec.name + assert_equal "a", spec.name assert_equal v(2), spec.version assert_equal Gem::Platform::RUBY, spec.platform assert_equal @lock_source, spec.source end def test_find_all - @set.add 'a', '1.a', Gem::Platform::RUBY - @set.add 'a', '2', Gem::Platform::RUBY - @set.add 'b', '2', Gem::Platform::RUBY + @set.add "a", "1.a", Gem::Platform::RUBY + @set.add "a", "2", Gem::Platform::RUBY + @set.add "b", "2", Gem::Platform::RUBY - found = @set.find_all dep 'a' + found = @set.find_all dep "a" assert_equal %w[a-2], found.map {|s| s.full_name } - found = @set.find_all dep 'a', '>= 0.a' + found = @set.find_all dep "a", ">= 0.a" assert_equal %w[a-1.a a-2], found.map {|s| s.full_name } end def test_load_spec spec_fetcher do |fetcher| - fetcher.spec 'a', 2 + fetcher.spec "a", 2 end version = v(2) - @set.add 'a', version, Gem::Platform::RUBY + @set.add "a", version, Gem::Platform::RUBY - loaded = @set.load_spec 'a', version, Gem::Platform::RUBY, nil + loaded = @set.load_spec "a", version, Gem::Platform::RUBY, nil assert_kind_of Gem::Specification, loaded - assert_equal 'a-2', loaded.full_name + assert_equal "a-2", loaded.full_name end def test_prefetch diff --git a/test/rubygems/test_gem_resolver_lock_specification.rb b/test/rubygems/test_gem_resolver_lock_specification.rb index 46c8e5edd6f8..32adc25f94b6 100644 --- a/test/rubygems/test_gem_resolver_lock_specification.rb +++ b/test/rubygems/test_gem_resolver_lock_specification.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/installer' -require 'rubygems/resolver' +require_relative "helper" +require "rubygems/installer" +require "rubygems/resolver" class TestGemResolverLockSpecification < Gem::TestCase def setup @@ -14,9 +14,9 @@ def setup end def test_initialize - spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY + spec = @LS.new @set, "a", v(2), [@source], Gem::Platform::RUBY - assert_equal 'a', spec.name + assert_equal "a", spec.name assert_equal v(2), spec.version assert_equal Gem::Platform::RUBY, spec.platform @@ -24,9 +24,9 @@ def test_initialize end def test_add_dependency - l_spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY + l_spec = @LS.new @set, "a", v(2), [@source], Gem::Platform::RUBY - b_dep = dep('b', '>= 0') + b_dep = dep("b", ">= 0") l_spec.add_dependency b_dep @@ -35,10 +35,10 @@ def test_add_dependency def test_install spec_fetcher do |fetcher| - fetcher.download 'a', 2 + fetcher.download "a", 2 end - spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY + spec = @LS.new @set, "a", v(2), [@source], Gem::Platform::RUBY called = false @@ -50,9 +50,9 @@ def test_install end def test_install_installed - spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY + spec = @LS.new @set, "a", v(2), [@source], Gem::Platform::RUBY - FileUtils.touch File.join(@gemhome, 'specifications', spec.spec.spec_name) + FileUtils.touch File.join(@gemhome, "specifications", spec.spec.spec_name) called = false @@ -66,17 +66,17 @@ def test_install_installed def test_spec version = v(2) - l_spec = @LS.new @set, 'a', version, [@source], Gem::Platform::RUBY + l_spec = @LS.new @set, "a", version, [@source], Gem::Platform::RUBY - b_dep = dep 'b', '>= 0' - c_dep = dep 'c', '~> 1' + b_dep = dep "b", ">= 0" + c_dep = dep "c", "~> 1" l_spec.add_dependency b_dep l_spec.add_dependency c_dep spec = l_spec.spec - assert_equal 'a', spec.name + assert_equal "a", spec.name assert_equal version, spec.version assert_equal Gem::Platform::RUBY, spec.platform @@ -84,13 +84,13 @@ def test_spec end def test_spec_loaded - real_spec = util_spec 'a', 2 + real_spec = util_spec "a", 2 install_specs real_spec real_spec.activate version = v(2) - l_spec = @LS.new @set, 'a', version, [@source], Gem::Platform::RUBY + l_spec = @LS.new @set, "a", version, [@source], Gem::Platform::RUBY assert_same real_spec, l_spec.spec end diff --git a/test/rubygems/test_gem_resolver_requirement_list.rb b/test/rubygems/test_gem_resolver_requirement_list.rb index 806c3876690a..e9e0d87bf552 100644 --- a/test/rubygems/test_gem_resolver_requirement_list.rb +++ b/test/rubygems/test_gem_resolver_requirement_list.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverRequirementList < Gem::TestCase def setup diff --git a/test/rubygems/test_gem_resolver_specification.rb b/test/rubygems/test_gem_resolver_specification.rb index 9f28c1c0cf5f..a8cba3dfd6c0 100644 --- a/test/rubygems/test_gem_resolver_specification.rb +++ b/test/rubygems/test_gem_resolver_specification.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverSpecification < Gem::TestCase class TestSpec < Gem::Resolver::Specification @@ -16,31 +16,31 @@ def initialize(spec) def test_install gemhome = "#{@gemhome}2" spec_fetcher do |fetcher| - fetcher.gem 'a', 1 + fetcher.gem "a", 1 end - a = util_spec 'a', 1 + a = util_spec "a", 1 a_spec = TestSpec.new a a_spec.source = Gem::Source.new @gem_repo a_spec.install :install_dir => gemhome - assert_path_exist File.join gemhome, 'gems', a.full_name + assert_path_exist File.join gemhome, "gems", a.full_name - expected = File.join gemhome, 'specifications', a.spec_name + expected = File.join gemhome, "specifications", a.spec_name assert_equal expected, a_spec.spec.loaded_from end def test_installable_platform_eh - a = util_spec 'a', 1 + a = util_spec "a", 1 a_spec = TestSpec.new a assert a_spec.installable_platform? - b = util_spec 'a', 1 do |s| + b = util_spec "a", 1 do |s| s.platform = Gem::Platform.new %w[cpu other_platform 1] end @@ -50,7 +50,7 @@ def test_installable_platform_eh end def test_source - a = util_spec 'a', 1 + a = util_spec "a", 1 source = Gem::Source.new @gem_repo diff --git a/test/rubygems/test_gem_resolver_vendor_set.rb b/test/rubygems/test_gem_resolver_vendor_set.rb index e16d43ac1aff..9517a4b06e75 100644 --- a/test/rubygems/test_gem_resolver_vendor_set.rb +++ b/test/rubygems/test_gem_resolver_vendor_set.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverVendorSet < Gem::TestCase def setup @@ -40,7 +40,7 @@ def test_find_all @set.add_vendor_gem name, directory - dependency = dep 'a', '~> 1' + dependency = dep "a", "~> 1" req = Gem::Resolver::DependencyRequest.new dependency, nil @@ -58,15 +58,15 @@ def test_find_all end def test_find_all_prerelease - name, _, directory = vendor_gem 'a', '1.a' + name, _, directory = vendor_gem "a", "1.a" @set.add_vendor_gem name, directory - req = Gem::Resolver::DependencyRequest.new dep('a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a"), nil assert_empty @set.find_all req - req = Gem::Resolver::DependencyRequest.new dep('a', '>= 0.a'), nil + req = Gem::Resolver::DependencyRequest.new dep("a", ">= 0.a"), nil refute_empty @set.find_all req end @@ -75,7 +75,7 @@ def test_load_spec error = Object.const_defined?(:KeyError) ? KeyError : IndexError assert_raise error do - @set.load_spec 'b', v(1), Gem::Platform::RUBY, nil + @set.load_spec "b", v(1), Gem::Platform::RUBY, nil end end end diff --git a/test/rubygems/test_gem_resolver_vendor_specification.rb b/test/rubygems/test_gem_resolver_vendor_specification.rb index 93382ccd81f2..d92ef0b01058 100644 --- a/test/rubygems/test_gem_resolver_vendor_specification.rb +++ b/test/rubygems/test_gem_resolver_vendor_specification.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemResolverVendorSpecification < Gem::TestCase def setup super @set = Gem::Resolver::VendorSet.new - @spec = Gem::Specification.new 'a', 1 + @spec = Gem::Specification.new "a", 1 end def test_equals2 @@ -14,7 +14,7 @@ def test_equals2 assert_equal v_spec_a, v_spec_a - spec_b = Gem::Specification.new 'b', 1 + spec_b = Gem::Specification.new "b", 1 v_spec_b = Gem::Resolver::VendorSpecification.new @set, spec_b refute_equal v_spec_a, v_spec_b @@ -27,24 +27,24 @@ def test_equals2 i_set = Gem::Resolver::IndexSet.new source = Gem::Source.new @gem_repo i_spec = Gem::Resolver::IndexSpecification.new( - i_set, 'a', v(1), source, Gem::Platform::RUBY) + i_set, "a", v(1), source, Gem::Platform::RUBY) refute_equal v_spec_a, i_spec end def test_dependencies - @spec.add_dependency 'b' - @spec.add_dependency 'c' + @spec.add_dependency "b" + @spec.add_dependency "c" v_spec = Gem::Resolver::VendorSpecification.new @set, @spec - assert_equal [dep('b'), dep('c')], v_spec.dependencies + assert_equal [dep("b"), dep("c")], v_spec.dependencies end def test_full_name v_spec = Gem::Resolver::VendorSpecification.new @set, @spec - assert_equal 'a-1', v_spec.full_name + assert_equal "a-1", v_spec.full_name end def test_install @@ -62,7 +62,7 @@ def test_install def test_name v_spec = Gem::Resolver::VendorSpecification.new @set, @spec - assert_equal 'a', v_spec.name + assert_equal "a", v_spec.name end def test_platform @@ -72,7 +72,7 @@ def test_platform end def test_version - spec = Gem::Specification.new 'a', 1 + spec = Gem::Specification.new "a", 1 v_spec = Gem::Resolver::VendorSpecification.new @set, spec diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb index 415ec2b5f648..f0b9824aabb6 100644 --- a/test/rubygems/test_gem_security.rb +++ b/test/rubygems/test_gem_security.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/security' +require_relative "helper" +require "rubygems/security" unless Gem::HAVE_OPENSSL - warn 'Skipping Gem::Security tests. openssl not found.' + warn "Skipping Gem::Security tests. openssl not found." end if Gem.java_platform? - warn 'Skipping Gem::Security tests on jruby.' + warn "Skipping Gem::Security tests on jruby." end class TestGemSecurity < Gem::TestCase - CHILD_KEY = load_key 'child' - EC_KEY = load_key 'private_ec', 'Foo bar' + CHILD_KEY = load_key "child" + EC_KEY = load_key "private_ec", "Foo bar" - ALTERNATE_CERT = load_cert 'child' - CHILD_CERT = load_cert 'child' - EXPIRED_CERT = load_cert 'expired' + ALTERNATE_CERT = load_cert "child" + CHILD_CERT = load_cert "child" + EXPIRED_CERT = load_cert "expired" def setup super @@ -42,19 +42,19 @@ def test_class_create_cert assert_equal 3, cert.extensions.length, cert.extensions.map {|e| e.to_a.first } - constraints = cert.extensions.find {|ext| ext.oid == 'basicConstraints' } - assert_equal 'CA:FALSE', constraints.value + constraints = cert.extensions.find {|ext| ext.oid == "basicConstraints" } + assert_equal "CA:FALSE", constraints.value - key_usage = cert.extensions.find {|ext| ext.oid == 'keyUsage' } - assert_equal 'Digital Signature, Key Encipherment, Data Encipherment', + key_usage = cert.extensions.find {|ext| ext.oid == "keyUsage" } + assert_equal "Digital Signature, Key Encipherment, Data Encipherment", key_usage.value - key_ident = cert.extensions.find {|ext| ext.oid == 'subjectKeyIdentifier' } + key_ident = cert.extensions.find {|ext| ext.oid == "subjectKeyIdentifier" } assert_equal 59, key_ident.value.length - assert_equal '5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B', + assert_equal "5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B", key_ident.value - assert_equal '', cert.issuer.to_s + assert_equal "", cert.issuer.to_s assert_equal name.to_s, cert.subject.to_s end @@ -63,12 +63,12 @@ def test_class_create_cert_self_signed cert = @SEC.create_cert_self_signed subject, PRIVATE_KEY, 60 - assert_equal '/CN=nobody/DC=example', cert.issuer.to_s + assert_equal "/CN=nobody/DC=example", cert.issuer.to_s assert_equal "sha256WithRSAEncryption", cert.signature_algorithm end def test_class_create_cert_email - email = 'nobody@example' + email = "nobody@example" name = PUBLIC_CERT.subject key = PRIVATE_KEY @@ -87,37 +87,37 @@ def test_class_create_cert_email assert_equal 5, cert.extensions.length, cert.extensions.map {|e| e.to_a.first } - constraints = cert.extensions.find {|ext| ext.oid == 'subjectAltName' } - assert_equal 'email:nobody@example', constraints.value + constraints = cert.extensions.find {|ext| ext.oid == "subjectAltName" } + assert_equal "email:nobody@example", constraints.value - constraints = cert.extensions.find {|ext| ext.oid == 'basicConstraints' } - assert_equal 'CA:FALSE', constraints.value + constraints = cert.extensions.find {|ext| ext.oid == "basicConstraints" } + assert_equal "CA:FALSE", constraints.value - key_usage = cert.extensions.find {|ext| ext.oid == 'keyUsage' } - assert_equal 'Digital Signature, Key Encipherment, Data Encipherment', + key_usage = cert.extensions.find {|ext| ext.oid == "keyUsage" } + assert_equal "Digital Signature, Key Encipherment, Data Encipherment", key_usage.value - key_ident = cert.extensions.find {|ext| ext.oid == 'subjectKeyIdentifier' } + key_ident = cert.extensions.find {|ext| ext.oid == "subjectKeyIdentifier" } assert_equal 59, key_ident.value.length - assert_equal '5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B', + assert_equal "5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B", key_ident.value end def test_class_create_key - key = @SEC.create_key 'rsa' + key = @SEC.create_key "rsa" assert_kind_of OpenSSL::PKey::RSA, key end def test_class_create_key_downcases - key = @SEC.create_key 'DSA' + key = @SEC.create_key "DSA" assert_kind_of OpenSSL::PKey::DSA, key end def test_class_create_key_raises_unknown_algorithm e = assert_raise Gem::Security::Exception do - @SEC.create_key 'NOT_RSA' + @SEC.create_key "NOT_RSA" end assert_equal "NOT_RSA algorithm not found. RSA, DSA, and EC algorithms are supported.", @@ -137,17 +137,17 @@ def test_class_get_public_key_ec end def test_class_email_to_name - assert_equal '/CN=nobody/DC=example', - @SEC.email_to_name('nobody@example').to_s + assert_equal "/CN=nobody/DC=example", + @SEC.email_to_name("nobody@example").to_s - assert_equal '/CN=nobody/DC=example/DC=com', - @SEC.email_to_name('nobody@example.com').to_s + assert_equal "/CN=nobody/DC=example/DC=com", + @SEC.email_to_name("nobody@example.com").to_s - assert_equal '/CN=no.body/DC=example', - @SEC.email_to_name('no.body@example').to_s + assert_equal "/CN=no.body/DC=example", + @SEC.email_to_name("no.body@example").to_s - assert_equal '/CN=no_body/DC=example', - @SEC.email_to_name('no+body@example').to_s + assert_equal "/CN=no_body/DC=example", + @SEC.email_to_name("no+body@example").to_s end def test_class_re_sign @@ -168,7 +168,7 @@ def test_class_re_sign_not_self_signed end child_alt_name = CHILD_CERT.extensions.find do |extension| - extension.oid == 'subjectAltName' + extension.oid == "subjectAltName" end assert_equal "#{child_alt_name.value} is not self-signed, contact " + @@ -217,20 +217,20 @@ def test_class_sign assert_equal 4, signed.extensions.length, signed.extensions.map {|e| e.to_a.first } - constraints = signed.extensions.find {|ext| ext.oid == 'issuerAltName' } - assert_equal 'email:nobody@example', constraints.value, 'issuerAltName' + constraints = signed.extensions.find {|ext| ext.oid == "issuerAltName" } + assert_equal "email:nobody@example", constraints.value, "issuerAltName" - constraints = signed.extensions.find {|ext| ext.oid == 'basicConstraints' } - assert_equal 'CA:FALSE', constraints.value + constraints = signed.extensions.find {|ext| ext.oid == "basicConstraints" } + assert_equal "CA:FALSE", constraints.value - key_usage = signed.extensions.find {|ext| ext.oid == 'keyUsage' } - assert_equal 'Digital Signature, Key Encipherment, Data Encipherment', + key_usage = signed.extensions.find {|ext| ext.oid == "keyUsage" } + assert_equal "Digital Signature, Key Encipherment, Data Encipherment", key_usage.value key_ident = - signed.extensions.find {|ext| ext.oid == 'subjectKeyIdentifier' } + signed.extensions.find {|ext| ext.oid == "subjectKeyIdentifier" } assert_equal 59, key_ident.value.length - assert_equal '5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B', + assert_equal "5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B", key_ident.value assert signed.verify key @@ -240,7 +240,7 @@ def test_class_sign_AltName issuer = PUBLIC_CERT.subject signee = OpenSSL::X509::Name.parse "/CN=signee/DC=example" - cert = @SEC.create_cert_email 'signee@example', PRIVATE_KEY + cert = @SEC.create_cert_email "signee@example", PRIVATE_KEY signed = @SEC.sign cert, PRIVATE_KEY, PUBLIC_CERT, 60 @@ -256,23 +256,23 @@ def test_class_sign_AltName assert_equal 5, signed.extensions.length, signed.extensions.map {|e| e.to_a.first } - constraints = signed.extensions.find {|ext| ext.oid == 'issuerAltName' } - assert_equal 'email:nobody@example', constraints.value, 'issuerAltName' + constraints = signed.extensions.find {|ext| ext.oid == "issuerAltName" } + assert_equal "email:nobody@example", constraints.value, "issuerAltName" - constraints = signed.extensions.find {|ext| ext.oid == 'subjectAltName' } - assert_equal 'email:signee@example', constraints.value, 'subjectAltName' + constraints = signed.extensions.find {|ext| ext.oid == "subjectAltName" } + assert_equal "email:signee@example", constraints.value, "subjectAltName" - constraints = signed.extensions.find {|ext| ext.oid == 'basicConstraints' } - assert_equal 'CA:FALSE', constraints.value + constraints = signed.extensions.find {|ext| ext.oid == "basicConstraints" } + assert_equal "CA:FALSE", constraints.value - key_usage = signed.extensions.find {|ext| ext.oid == 'keyUsage' } - assert_equal 'Digital Signature, Key Encipherment, Data Encipherment', + key_usage = signed.extensions.find {|ext| ext.oid == "keyUsage" } + assert_equal "Digital Signature, Key Encipherment, Data Encipherment", key_usage.value key_ident = - signed.extensions.find {|ext| ext.oid == 'subjectKeyIdentifier' } + signed.extensions.find {|ext| ext.oid == "subjectKeyIdentifier" } assert_equal 59, key_ident.value.length - assert_equal '5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B', + assert_equal "5F:43:6E:F6:9A:8E:45:25:E9:22:E3:7D:37:5E:A4:D5:36:02:85:1B", key_ident.value assert signed.verify PUBLIC_KEY @@ -281,15 +281,15 @@ def test_class_sign_AltName def test_class_trust_dir trust_dir = @SEC.trust_dir - expected = File.join Gem.user_home, '.gem/trust' + expected = File.join Gem.user_home, ".gem/trust" assert_equal expected, trust_dir.dir end def test_class_write - key = @SEC.create_key 'rsa' + key = @SEC.create_key "rsa" - path = File.join @tempdir, 'test-private_key.pem' + path = File.join @tempdir, "test-private_key.pem" @SEC.write key, path @@ -301,11 +301,11 @@ def test_class_write end def test_class_write_encrypted - key = @SEC.create_key 'rsa' + key = @SEC.create_key "rsa" - path = File.join @tempdir, 'test-private_encrypted_key.pem' + path = File.join @tempdir, "test-private_encrypted_key.pem" - passphrase = 'It should be long.' + passphrase = "It should be long." @SEC.write key, path, 0600, passphrase @@ -317,13 +317,13 @@ def test_class_write_encrypted end def test_class_write_encrypted_cipher - key = @SEC.create_key 'rsa' + key = @SEC.create_key "rsa" - path = File.join @tempdir, 'test-private_encrypted__with_non_default_cipher_key.pem' + path = File.join @tempdir, "test-private_encrypted__with_non_default_cipher_key.pem" - passphrase = 'It should be long.' + passphrase = "It should be long." - cipher = OpenSSL::Cipher.new 'AES-192-CBC' + cipher = OpenSSL::Cipher.new "AES-192-CBC" @SEC.write key, path, 0600, passphrase, cipher diff --git a/test/rubygems/test_gem_security_policy.rb b/test/rubygems/test_gem_security_policy.rb index 515b8ea00bfc..6680238245c7 100644 --- a/test/rubygems/test_gem_security_policy.rb +++ b/test/rubygems/test_gem_security_policy.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" unless Gem::HAVE_OPENSSL - warn 'Skipping Gem::Security::Policy tests. openssl not found.' + warn "Skipping Gem::Security::Policy tests. openssl not found." end class TestGemSecurityPolicy < Gem::TestCase - ALTERNATE_KEY = load_key 'alternate' - INVALID_KEY = load_key 'invalid' - CHILD_KEY = load_key 'child' - GRANDCHILD_KEY = load_key 'grandchild' - INVALIDCHILD_KEY = load_key 'invalidchild' - - ALTERNATE_CERT = load_cert 'alternate' - CA_CERT = load_cert 'ca' - CHILD_CERT = load_cert 'child' - EXPIRED_CERT = load_cert 'expired' - FUTURE_CERT = load_cert 'future' - GRANDCHILD_CERT = load_cert 'grandchild' - INVALIDCHILD_CERT = load_cert 'invalidchild' - INVALID_ISSUER_CERT = load_cert 'invalid_issuer' - INVALID_SIGNER_CERT = load_cert 'invalid_signer' - WRONG_KEY_CERT = load_cert 'wrong_key' + ALTERNATE_KEY = load_key "alternate" + INVALID_KEY = load_key "invalid" + CHILD_KEY = load_key "child" + GRANDCHILD_KEY = load_key "grandchild" + INVALIDCHILD_KEY = load_key "invalidchild" + + ALTERNATE_CERT = load_cert "alternate" + CA_CERT = load_cert "ca" + CHILD_CERT = load_cert "child" + EXPIRED_CERT = load_cert "expired" + FUTURE_CERT = load_cert "future" + GRANDCHILD_CERT = load_cert "grandchild" + INVALIDCHILD_CERT = load_cert "invalidchild" + INVALID_ISSUER_CERT = load_cert "invalid_issuer" + INVALID_SIGNER_CERT = load_cert "invalid_signer" + WRONG_KEY_CERT = load_cert "wrong_key" def setup super - @spec = quick_gem 'a' do |s| - s.description = 'Ï€' + @spec = quick_gem "a" do |s| + s.description = "Ï€" s.files = %w[lib/code.rb] end @@ -42,7 +42,7 @@ def setup @high = Gem::Security::HighSecurity @chain = Gem::Security::Policy.new( - 'Chain', + "Chain", :verify_data => true, :verify_signer => true, :verify_chain => true, @@ -52,7 +52,7 @@ def setup ) @root = Gem::Security::Policy.new( - 'Root', + "Root", :verify_data => true, :verify_signer => true, :verify_chain => true, @@ -63,7 +63,7 @@ def setup end def test_check_data - data = digest 'hello' + data = digest "hello" signature = sign data @@ -71,17 +71,17 @@ def test_check_data end def test_check_data_invalid - data = digest 'hello' + data = digest "hello" signature = sign data - invalid = digest 'hello!' + invalid = digest "hello!" e = assert_raise Gem::Security::Exception do @almost_no.check_data PUBLIC_KEY, @digest, signature, invalid end - assert_equal 'invalid signature', e.message + assert_equal "invalid signature", e.message end def test_check_chain @@ -95,7 +95,7 @@ def test_check_chain_empty_chain @chain.check_chain [], Time.now end - assert_equal 'empty signing chain', e.message + assert_equal "empty signing chain", e.message end def test_check_chain_invalid @@ -115,7 +115,7 @@ def test_check_chain_no_chain @chain.check_chain nil, Time.now end - assert_equal 'missing signing chain', e.message + assert_equal "missing signing chain", e.message end def test_check_cert @@ -161,7 +161,7 @@ def test_check_cert_no_signer @high.check_cert(nil, nil, Time.now) end - assert_equal 'missing signing certificate', e.message + assert_equal "missing signing certificate", e.message end def test_check_key @@ -175,7 +175,7 @@ def test_check_key_no_signer @high.check_key(nil, nil) end - assert_equal 'missing key or signature', e.message + assert_equal "missing key or signature", e.message end def test_check_key_wrong_key @@ -198,7 +198,7 @@ def test_check_root_empty_chain @chain.check_root [], Time.now end - assert_equal 'missing root certificate', e.message + assert_equal "missing root certificate", e.message end def test_check_root_invalid_signer @@ -230,7 +230,7 @@ def test_check_root_no_chain @chain.check_root nil, Time.now end - assert_equal 'missing signing chain', e.message + assert_equal "missing signing chain", e.message end def test_check_trust @@ -250,7 +250,7 @@ def test_check_trust_empty_chain @chain.check_trust [], @digest, @trust_dir end - assert_equal 'missing root certificate', e.message + assert_equal "missing root certificate", e.message end def test_check_trust_mismatch @@ -269,7 +269,7 @@ def test_check_trust_no_chain @chain.check_trust nil, @digest, @trust_dir end - assert_equal 'missing signing chain', e.message + assert_equal "missing signing chain", e.message end def test_check_trust_no_trust @@ -290,8 +290,8 @@ def test_check_trust_no_trust_child end def test_subject - assert_equal 'email:nobody@example', @no.subject(PUBLIC_CERT) - assert_equal '/C=JP/ST=Tokyo/O=RubyGemsTest/CN=CA', @no.subject(CA_CERT) + assert_equal "email:nobody@example", @no.subject(PUBLIC_CERT) + assert_equal "/C=JP/ST=Tokyo/O=RubyGemsTest/CN=CA", @no.subject(CA_CERT) end def test_verify @@ -319,7 +319,7 @@ def test_verify_no_digests @almost_no.verify [PUBLIC_CERT], nil, {}, signatures end - assert_equal 'no digests provided (probable bug)', e.message + assert_equal "no digests provided (probable bug)", e.message end def test_verify_no_digests_no_security @@ -331,7 +331,7 @@ def test_verify_no_digests_no_security @no.verify [PUBLIC_CERT], nil, {}, signatures end - assert_equal 'missing digest for 0', e.message + assert_equal "missing digest for 0", e.message end def test_verify_no_signatures @@ -340,7 +340,7 @@ def test_verify_no_signatures digests, = dummy_signatures use_ui @ui do - @no.verify [PUBLIC_CERT], nil, digests, {}, 'some_gem' + @no.verify [PUBLIC_CERT], nil, digests, {}, "some_gem" end assert_match "WARNING: some_gem is not signed\n", @ui.error @@ -354,7 +354,7 @@ def test_verify_no_signatures_no_digests Gem::Security.trust_dir.trust_cert PUBLIC_CERT use_ui @ui do - @no.verify [PUBLIC_CERT], nil, {}, {}, 'some_gem' + @no.verify [PUBLIC_CERT], nil, {}, {}, "some_gem" end assert_empty @ui.output @@ -366,7 +366,7 @@ def test_verify_not_enough_signatures digests, signatures = dummy_signatures - data = digest 'goodbye' + data = digest "goodbye" signatures[1] = PRIVATE_KEY.sign @digest.new, data.digest @@ -374,14 +374,14 @@ def test_verify_not_enough_signatures @almost_no.verify [PUBLIC_CERT], nil, digests, signatures end - assert_equal 'missing digest for 1', e.message + assert_equal "missing digest for 1", e.message end def test_verify_no_trust digests, signatures = dummy_signatures use_ui @ui do - @low.verify [PUBLIC_CERT], nil, digests, signatures, 'some_gem' + @low.verify [PUBLIC_CERT], nil, digests, signatures, "some_gem" end assert_equal "WARNING: email:nobody@example is not trusted for some_gem\n", @@ -395,18 +395,18 @@ def test_verify_no_trust def test_verify_wrong_digest_type Gem::Security.trust_dir.trust_cert PUBLIC_CERT - data = OpenSSL::Digest.new('SHA512') - data << 'hello' + data = OpenSSL::Digest.new("SHA512") + data << "hello" - digests = { 'SHA512' => { 0 => data } } - signature = PRIVATE_KEY.sign 'sha512', data.digest + digests = { "SHA512" => { 0 => data } } + signature = PRIVATE_KEY.sign "sha512", data.digest signatures = { 0 => signature } e = assert_raise Gem::Security::Exception do @almost_no.verify [PUBLIC_CERT], nil, digests, signatures end - assert_equal 'no digests provided (probable bug)', e.message + assert_equal "no digests provided (probable bug)", e.message end def test_verify_signatures_chain @@ -448,17 +448,17 @@ def test_verify_signatures metadata_gz = Gem::Util.gzip @spec.to_yaml - package = Gem::Package.new 'nonexistent.gem' + package = Gem::Package.new "nonexistent.gem" package.checksums[Gem::Security::DIGEST_NAME] = {} s = StringIO.new metadata_gz - def s.full_name() 'metadata.gz' end + def s.full_name() "metadata.gz" end digests = package.digest s - metadata_gz_digest = digests[Gem::Security::DIGEST_NAME]['metadata.gz'] + metadata_gz_digest = digests[Gem::Security::DIGEST_NAME]["metadata.gz"] signatures = {} - signatures['metadata.gz'] = + signatures["metadata.gz"] = PRIVATE_KEY.sign @digest.new, metadata_gz_digest.digest assert @high.verify_signatures @spec, digests, signatures @@ -471,26 +471,26 @@ def test_verify_signatures_missing metadata_gz = Gem::Util.gzip @spec.to_yaml - package = Gem::Package.new 'nonexistent.gem' + package = Gem::Package.new "nonexistent.gem" package.checksums[Gem::Security::DIGEST_NAME] = {} s = StringIO.new metadata_gz - def s.full_name() 'metadata.gz' end + def s.full_name() "metadata.gz" end digests = package.digest s - digests[Gem::Security::DIGEST_NAME]['data.tar.gz'] = @digest.hexdigest 'hello' + digests[Gem::Security::DIGEST_NAME]["data.tar.gz"] = @digest.hexdigest "hello" - metadata_gz_digest = digests[Gem::Security::DIGEST_NAME]['metadata.gz'] + metadata_gz_digest = digests[Gem::Security::DIGEST_NAME]["metadata.gz"] signatures = {} - signatures['metadata.gz'] = + signatures["metadata.gz"] = PRIVATE_KEY.sign @digest.new, metadata_gz_digest.digest e = assert_raise Gem::Security::Exception do @high.verify_signatures @spec, digests, signatures end - assert_equal 'missing signature for data.tar.gz', e.message + assert_equal "missing signature for data.tar.gz", e.message end def test_verify_signatures_none @@ -500,14 +500,14 @@ def test_verify_signatures_none metadata_gz = Gem::Util.gzip @spec.to_yaml - package = Gem::Package.new 'nonexistent.gem' + package = Gem::Package.new "nonexistent.gem" package.checksums[Gem::Security::DIGEST_NAME] = {} s = StringIO.new metadata_gz - def s.full_name() 'metadata.gz' end + def s.full_name() "metadata.gz" end digests = package.digest s - digests[Gem::Security::DIGEST_NAME]['data.tar.gz'] = @digest.hexdigest 'hello' + digests[Gem::Security::DIGEST_NAME]["data.tar.gz"] = @digest.hexdigest "hello" assert_raise Gem::Security::Exception do @high.verify_signatures @spec, digests, {} @@ -525,7 +525,7 @@ def sign(data, key = PRIVATE_KEY) end def dummy_signatures(key = PRIVATE_KEY) - data = digest 'hello' + data = digest "hello" digests = { Gem::Security::DIGEST_NAME => { 0 => data } } signatures = { 0 => sign(data, key) } diff --git a/test/rubygems/test_gem_security_signer.rb b/test/rubygems/test_gem_security_signer.rb index 7bd6510b501d..d9f320eeb01d 100644 --- a/test/rubygems/test_gem_security_signer.rb +++ b/test/rubygems/test_gem_security_signer.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" unless Gem::HAVE_OPENSSL - warn 'Skipping Gem::Security::Signer tests. openssl not found.' + warn "Skipping Gem::Security::Signer tests. openssl not found." end class TestGemSecuritySigner < Gem::TestCase - ALTERNATE_KEY = load_key 'alternate' - CHILD_KEY = load_key 'child' - GRANDCHILD_KEY = load_key 'grandchild' + ALTERNATE_KEY = load_key "alternate" + CHILD_KEY = load_key "child" + GRANDCHILD_KEY = load_key "grandchild" - CHILD_CERT = load_cert 'child' - GRANDCHILD_CERT = load_cert 'grandchild' - EXPIRED_CERT = load_cert 'expired' + CHILD_CERT = load_cert "child" + GRANDCHILD_CERT = load_cert "grandchild" + EXPIRED_CERT = load_cert "expired" def setup super @@ -42,7 +42,7 @@ def test_initialize_cert_chain_mixed def test_initialize_cert_chain_invalid assert_raise OpenSSL::X509::CertificateError do - Gem::Security::Signer.new nil, ['garbage'] + Gem::Security::Signer.new nil, ["garbage"] end end @@ -54,12 +54,12 @@ def test_initialize_cert_chain_path end def test_initialize_default - FileUtils.mkdir_p File.join(Gem.user_home, '.gem') + FileUtils.mkdir_p File.join(Gem.user_home, ".gem") - private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem' + private_key_path = File.join Gem.user_home, ".gem", "gem-private_key.pem" Gem::Security.write PRIVATE_KEY, private_key_path - public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + public_cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" Gem::Security.write PUBLIC_CERT, public_cert_path signer = Gem::Security::Signer.new nil, nil @@ -87,7 +87,7 @@ def test_initialize_encrypted_key_path def test_extract_name signer = Gem::Security::Signer.new nil, nil - assert_equal 'child@example', signer.extract_name(CHILD_CERT) + assert_equal "child@example", signer.extract_name(CHILD_CERT) end def test_load_cert_chain @@ -117,7 +117,7 @@ def test_load_cert_chain_broken def test_sign signer = Gem::Security::Signer.new PRIVATE_KEY, [PUBLIC_CERT] - signature = signer.sign 'hello' + signature = signer.sign "hello" expected = <<-EXPECTED cHze2sEfRysoUMCfGVAx/7o8jxj5liJJ2ptNxe2jf3l+EZvyjdqpXo9Ndzxx @@ -128,14 +128,14 @@ def test_sign toqvglr0kdbknSRRjBVLK6tsgr07aLT9gNP7mTW2PA== EXPECTED - assert_equal expected, [signature].pack('m') + assert_equal expected, [signature].pack("m") end def test_sign_expired signer = Gem::Security::Signer.new PRIVATE_KEY, [EXPIRED_CERT] e = assert_raise Gem::Security::Exception do - signer.sign 'hello' + signer.sign "hello" end assert_match "certificate /CN=nobody/DC=example not valid after 1970-01-01 00:00:00 UTC", e.message @@ -143,17 +143,17 @@ def test_sign_expired def test_sign_expired_auto_update pend if Gem.java_platform? - FileUtils.mkdir_p File.join(Gem.user_home, '.gem'), :mode => 0700 + FileUtils.mkdir_p File.join(Gem.user_home, ".gem"), :mode => 0700 - private_key_path = File.join(Gem.user_home, '.gem', 'gem-private_key.pem') + private_key_path = File.join(Gem.user_home, ".gem", "gem-private_key.pem") Gem::Security.write PRIVATE_KEY, private_key_path - cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem' + cert_path = File.join Gem.user_home, ".gem", "gem-public_cert.pem" Gem::Security.write EXPIRED_CERT, cert_path signer = Gem::Security::Signer.new PRIVATE_KEY, [EXPIRED_CERT] - signer.sign 'hello' + signer.sign "hello" cert = OpenSSL::X509::Certificate.new File.read cert_path @@ -163,14 +163,14 @@ def test_sign_expired_auto_update expiry = EXPIRED_CERT.not_after.strftime "%Y%m%d%H%M%S" expired_path = - File.join Gem.user_home, '.gem', "gem-public_cert.pem.expired.#{expiry}" + File.join Gem.user_home, ".gem", "gem-public_cert.pem.expired.#{expiry}" assert_path_exist expired_path assert_equal EXPIRED_CERT.to_pem, File.read(expired_path) end def test_sign_expired_auto_update_exists - FileUtils.mkdir_p File.join(Gem.user_home, '.gem'), :mode => 0700 + FileUtils.mkdir_p File.join(Gem.user_home, ".gem"), :mode => 0700 expiry = EXPIRED_CERT.not_after.strftime "%Y%m%d%H%M%S" expired_path = @@ -178,16 +178,16 @@ def test_sign_expired_auto_update_exists Gem::Security.write EXPIRED_CERT, expired_path - private_key_path = File.join(Gem.user_home, 'gem-private_key.pem') + private_key_path = File.join(Gem.user_home, "gem-private_key.pem") Gem::Security.write PRIVATE_KEY, private_key_path - cert_path = File.join Gem.user_home, 'gem-public_cert.pem' + cert_path = File.join Gem.user_home, "gem-public_cert.pem" Gem::Security.write EXPIRED_CERT, cert_path signer = Gem::Security::Signer.new PRIVATE_KEY, [EXPIRED_CERT] e = assert_raise Gem::Security::Exception do - signer.sign 'hello' + signer.sign "hello" end assert_match %r{certificate /CN=nobody/DC=example not valid}, e.message @@ -196,14 +196,14 @@ def test_sign_expired_auto_update_exists def test_sign_no_key signer = Gem::Security::Signer.new nil, nil - assert_nil signer.sign 'stuff' + assert_nil signer.sign "stuff" end def test_sign_wrong_key signer = Gem::Security::Signer.new ALTERNATE_KEY, [PUBLIC_CERT] assert_raise Gem::Security::Exception do - signer.sign 'hello' + signer.sign "hello" end end @@ -211,7 +211,7 @@ def test_sign_no_certs signer = Gem::Security::Signer.new ALTERNATE_KEY, [] assert_raise Gem::Security::Exception do - signer.sign 'hello' + signer.sign "hello" end end end if Gem::HAVE_OPENSSL diff --git a/test/rubygems/test_gem_security_trust_dir.rb b/test/rubygems/test_gem_security_trust_dir.rb index fc88c8486527..8c59286679e4 100644 --- a/test/rubygems/test_gem_security_trust_dir.rb +++ b/test/rubygems/test_gem_security_trust_dir.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" unless Gem::HAVE_OPENSSL - warn 'Skipping Gem::Security::TrustDir tests. openssl not found.' + warn "Skipping Gem::Security::TrustDir tests. openssl not found." end class TestGemSecurityTrustDir < Gem::TestCase - CHILD_CERT = load_cert 'child' + CHILD_CERT = load_cert "child" def setup super - @dest_dir = File.join @tempdir, 'trust' + @dest_dir = File.join @tempdir, "trust" @trust_dir = Gem::Security::TrustDir.new @dest_dir end diff --git a/test/rubygems/test_gem_silent_ui.rb b/test/rubygems/test_gem_silent_ui.rb index d23d6f4cbaa2..c5d2a35c34b4 100644 --- a/test/rubygems/test_gem_silent_ui.rb +++ b/test/rubygems/test_gem_silent_ui.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/user_interaction' -require 'timeout' +require_relative "helper" +require "rubygems/user_interaction" +require "timeout" class TestGemSilentUI < Gem::TestCase def setup @@ -18,28 +18,28 @@ def test_ask value = nil out, err = capture_output do use_ui @sui do - value = @sui.ask 'Problem?' + value = @sui.ask "Problem?" end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" - assert_nil value, 'No value' + assert_nil value, "No value" end def test_ask_for_password value = nil out, err = capture_output do use_ui @sui do - value = @sui.ask_for_password 'Problem?' + value = @sui.ask_for_password "Problem?" end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" - assert_nil value, 'No value' + assert_nil value, "No value" end def test_ask_yes_no @@ -47,71 +47,71 @@ def test_ask_yes_no out, err = capture_output do use_ui @sui do assert_raise(Gem::OperationNotSupportedError) do - @sui.ask_yes_no 'Problem?' + @sui.ask_yes_no "Problem?" end end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" out, err = capture_output do use_ui @sui do - value = @sui.ask_yes_no 'Problem?', true + value = @sui.ask_yes_no "Problem?", true end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" - assert value, 'Value is true' + assert value, "Value is true" out, err = capture_output do use_ui @sui do - value = @sui.ask_yes_no 'Problem?', false + value = @sui.ask_yes_no "Problem?", false end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" - assert_equal value, false, 'Value is false' + assert_equal value, false, "Value is false" end def test_choose_from_list value = nil out, err = capture_output do use_ui @sui do - value = @sui.choose_from_list 'Problem?', %w[yes no] + value = @sui.choose_from_list "Problem?", %w[yes no] end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" - assert_equal [nil, nil], value, 'Value is nil!' + assert_equal [nil, nil], value, "Value is nil!" end def test_progress_reporter out, err = capture_output do use_ui @sui do - @sui.progress_reporter 10, 'hi' + @sui.progress_reporter 10, "hi" end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" end def test_download_reporter out, err = capture_output do use_ui @sui do - @sui.download_reporter.fetch 'a.gem', 1024 + @sui.download_reporter.fetch "a.gem", 1024 end end - assert_empty out, 'No output' - assert_empty err, 'No output' + assert_empty out, "No output" + assert_empty err, "No output" end def test_new_without_dev_null diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb index 24312626f4be..e164215b57a8 100644 --- a/test/rubygems/test_gem_source.rb +++ b/test/rubygems/test_gem_source.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' -require 'rubygems/indexer' +require_relative "helper" +require "rubygems/source" +require "rubygems/indexer" class TestGemSource < Gem::TestCase def tuple(*args) @@ -12,10 +12,10 @@ def setup super @specs = spec_fetcher do |fetcher| - fetcher.spec 'a', '1.a' - fetcher.gem 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'b', 2 + fetcher.spec "a", "1.a" + fetcher.gem "a", 1 + fetcher.spec "a", 2 + fetcher.spec "b", 2 end @source = Gem::Source.new(@gem_repo) @@ -23,14 +23,14 @@ def setup def test_initialize_invalid_uri assert_raise URI::InvalidURIError do - Gem::Source.new 'git@example:a.git' + Gem::Source.new "git@example:a.git" end end def test_initialize_git - repository = 'git@example:a.git' + repository = "git@example:a.git" - source = Gem::Source::Git.new 'a', repository, 'master', false + source = Gem::Source::Git.new "a", repository, "master", false assert_equal repository, source.uri end @@ -38,13 +38,13 @@ def test_initialize_git def test_cache_dir_escapes_windows_paths uri = URI.parse("file:///C:/WINDOWS/Temp/gem_repo") root = Gem.spec_cache_dir - cache_dir = @source.cache_dir(uri).gsub(root, '') + cache_dir = @source.cache_dir(uri).gsub(root, "") assert cache_dir !~ /:/, "#{cache_dir} should not contain a :" end def test_dependency_resolver_set_bundler_api - response = Net::HTTPResponse.new '1.1', 200, 'OK' - response.uri = URI('http://example') + response = Net::HTTPResponse.new "1.1", 200, "OK" + response.uri = URI("http://example") @fetcher.data[@gem_repo] = response @@ -70,11 +70,11 @@ def test_dependency_resolver_set_marshal_api end def test_fetch_spec - a1 = @specs['a-1'] + a1 = @specs["a-1"] spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}" - spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby') + spec = @source.fetch_spec tuple("a", Gem::Version.new(1), "ruby") assert_equal a1.full_name, spec.full_name cache_dir = @source.cache_dir URI.parse(spec_uri) @@ -85,7 +85,7 @@ def test_fetch_spec end def test_fetch_spec_cached - a1 = @specs['a-1'] + a1 = @specs["a-1"] spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}" @fetcher.data["#{spec_uri}.rz"] = nil @@ -95,11 +95,11 @@ def test_fetch_spec_cached cache_file = File.join cache_dir, a1.spec_name - File.open cache_file, 'wb' do |io| + File.open cache_file, "wb" do |io| Marshal.dump a1, io end - spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby') + spec = @source.fetch_spec tuple("a", Gem::Version.new(1), "ruby") assert_equal a1.full_name, spec.full_name end @@ -108,24 +108,24 @@ def test_fetch_spec_platform fetcher.legacy_platform end - spec = @source.fetch_spec tuple('pl', Gem::Version.new(1), 'i386-linux') + spec = @source.fetch_spec tuple("pl", Gem::Version.new(1), "i386-linux") - assert_equal specs['pl-1-x86-linux'].full_name, spec.full_name + assert_equal specs["pl-1-x86-linux"].full_name, spec.full_name end def test_fetch_spec_platform_ruby - spec = @source.fetch_spec tuple('a', Gem::Version.new(1), nil) - assert_equal @specs['a-1'].full_name, spec.full_name + spec = @source.fetch_spec tuple("a", Gem::Version.new(1), nil) + assert_equal @specs["a-1"].full_name, spec.full_name - spec = @source.fetch_spec tuple('a', Gem::Version.new(1), '') - assert_equal @specs['a-1'].full_name, spec.full_name + spec = @source.fetch_spec tuple("a", Gem::Version.new(1), "") + assert_equal @specs["a-1"].full_name, spec.full_name end def test_load_specs released = @source.load_specs(:released).map {|spec| spec.full_name } assert_equal %W[a-2 a-1 b-2], released - cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80' + cache_dir = File.join Gem.spec_cache_dir, "gems.example.com%80" assert File.exist?(cache_dir), "#{cache_dir} does not exist" cache_file = File.join cache_dir, "specs.#{Gem.marshal_version}" @@ -136,19 +136,19 @@ def test_load_specs_cached latest_specs = @source.load_specs :latest # Make sure the cached version is actually different: - latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby') + latest_specs << Gem::NameTuple.new("cached", Gem::Version.new("1.0.0"), "ruby") @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] = - ' ' * Marshal.dump(latest_specs).length + " " * Marshal.dump(latest_specs).length - cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80' + cache_dir = File.join Gem.spec_cache_dir, "gems.example.com%80" FileUtils.mkdir_p cache_dir cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" - File.open cache_file, 'wb' do |io| + File.open cache_file, "wb" do |io| Marshal.dump latest_specs, io end @@ -161,18 +161,18 @@ def test_load_specs_cached_empty latest_specs = @source.load_specs :latest # Make sure the cached version is actually different: - latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby') + latest_specs << Gem::NameTuple.new("fixed", Gem::Version.new("1.0.0"), "ruby") # Setup valid data on the 'remote' @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = util_gzip(Marshal.dump(latest_specs)) - cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80' + cache_dir = File.join Gem.spec_cache_dir, "gems.example.com%80" FileUtils.mkdir_p cache_dir cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" - File.open cache_file, 'wb' do |io| + File.open cache_file, "wb" do |io| # Setup invalid data in the cache: io.write Marshal.dump(latest_specs)[0, 10] end @@ -192,34 +192,34 @@ def test_load_specs_from_unavailable_uri def test_spaceship remote = @source - specific = Gem::Source::SpecificFile.new @specs['a-1'].cache_file + specific = Gem::Source::SpecificFile.new @specs["a-1"].cache_file installed = Gem::Source::Installed.new local = Gem::Source::Local.new - assert_equal(0, remote.<=>(remote), 'remote <=> remote') + assert_equal(0, remote.<=>(remote), "remote <=> remote") - assert_equal(-1, remote.<=>(specific), 'remote <=> specific') - assert_equal(1, specific.<=>(remote), 'specific <=> remote') + assert_equal(-1, remote.<=>(specific), "remote <=> specific") + assert_equal(1, specific.<=>(remote), "specific <=> remote") - assert_equal(-1, remote.<=>(local), 'remote <=> local') - assert_equal(1, local.<=>(remote), 'local <=> remote') + assert_equal(-1, remote.<=>(local), "remote <=> local") + assert_equal(1, local.<=>(remote), "local <=> remote") - assert_equal(-1, remote.<=>(installed), 'remote <=> installed') - assert_equal(1, installed.<=>(remote), 'installed <=> remote') + assert_equal(-1, remote.<=>(installed), "remote <=> installed") + assert_equal(1, installed.<=>(remote), "installed <=> remote") no_uri = @source.dup no_uri.instance_variable_set :@uri, nil - assert_equal(-1, remote.<=>(no_uri), 'remote <=> no_uri') + assert_equal(-1, remote.<=>(no_uri), "remote <=> no_uri") end def test_spaceship_order_is_preserved_when_uri_differs sourceA = Gem::Source.new "http://example.com/a" sourceB = Gem::Source.new "http://example.com/b" - assert_equal(0, sourceA.<=>(sourceA), 'sourceA <=> sourceA') - assert_equal(1, sourceA.<=>(sourceB), 'sourceA <=> sourceB') - assert_equal(1, sourceB.<=>(sourceA), 'sourceB <=> sourceA') + assert_equal(0, sourceA.<=>(sourceA), "sourceA <=> sourceA") + assert_equal(1, sourceA.<=>(sourceB), "sourceA <=> sourceB") + assert_equal(1, sourceB.<=>(sourceA), "sourceB <=> sourceA") end def test_update_cache_eh diff --git a/test/rubygems/test_gem_source_fetch_problem.rb b/test/rubygems/test_gem_source_fetch_problem.rb index 816407781d41..143c29050ea7 100644 --- a/test/rubygems/test_gem_source_fetch_problem.rb +++ b/test/rubygems/test_gem_source_fetch_problem.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemSourceFetchProblem < Gem::TestCase def test_exception source = Gem::Source.new @gem_repo - error = RuntimeError.new 'test' + error = RuntimeError.new "test" sf = Gem::SourceFetchProblem.new source, error @@ -12,25 +12,25 @@ def test_exception raise sf end - assert_equal 'test', e.message + assert_equal "test", e.message end def test_password_redacted - source = Gem::Source.new 'https://username:secret@gemsource.com' - error = RuntimeError.new 'test' + source = Gem::Source.new "https://username:secret@gemsource.com" + error = RuntimeError.new "test" sf = Gem::SourceFetchProblem.new source, error - refute_match sf.wordy, 'secret' + refute_match sf.wordy, "secret" end def test_source_password_no_redacted - source = Gem::Source.new 'https://username:secret@gemsource.com' - error = RuntimeError.new 'test' + source = Gem::Source.new "https://username:secret@gemsource.com" + error = RuntimeError.new "test" sf = Gem::SourceFetchProblem.new source, error sf.wordy - assert_match 'secret', source.uri.to_s + assert_match "secret", source.uri.to_s end end diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb index b97556d61d11..5702da05974b 100644 --- a/test/rubygems/test_gem_source_git.rb +++ b/test/rubygems/test_gem_source_git.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' +require_relative "helper" +require "rubygems/source" class TestGemSourceGit < Gem::TestCase def setup @@ -10,36 +10,36 @@ def setup @hash = Digest::SHA1.hexdigest @repository - @source = Gem::Source::Git.new @name, @repository, 'master', false + @source = Gem::Source::Git.new @name, @repository, "master", false end def test_base_dir - assert_equal File.join(Gem.dir, 'bundler'), @source.base_dir + assert_equal File.join(Gem.dir, "bundler"), @source.base_dir @source.root_dir = "#{@gemhome}2" - assert_equal File.join("#{@gemhome}2", 'bundler'), @source.base_dir + assert_equal File.join("#{@gemhome}2", "bundler"), @source.base_dir end def test_checkout @source.checkout - assert_path_exist File.join @source.install_dir, 'a.gemspec' + assert_path_exist File.join @source.install_dir, "a.gemspec" end def test_checkout_master Dir.chdir @repository do - system @git, 'checkout', '-q', '-b', 'other' - system @git, 'mv', 'a.gemspec', 'b.gemspec' - system @git, 'commit', '-q', '-a', '-m', 'rename gemspec' - system @git, 'checkout', '-q', 'master' + system @git, "checkout", "-q", "-b", "other" + system @git, "mv", "a.gemspec", "b.gemspec" + system @git, "commit", "-q", "-a", "-m", "rename gemspec" + system @git, "checkout", "-q", "master" end - @source = Gem::Source::Git.new @name, @repository, 'other', false + @source = Gem::Source::Git.new @name, @repository, "other", false @source.checkout - assert_path_exist File.join @source.install_dir, 'b.gemspec' + assert_path_exist File.join @source.install_dir, "b.gemspec" end def test_checkout_local @@ -47,9 +47,9 @@ def test_checkout_local @source.checkout - install_dir = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}" + install_dir = File.join Gem.dir, "bundler", "gems", "a-#{@head[0..11]}" - assert_path_not_exist File.join install_dir, 'a.gemspec' + assert_path_not_exist File.join install_dir, "a.gemspec" end def test_checkout_local_cached @@ -59,26 +59,26 @@ def test_checkout_local_cached @source.checkout - assert_path_exist File.join @source.install_dir, 'a.gemspec' + assert_path_exist File.join @source.install_dir, "a.gemspec" end def test_checkout_submodules - source = Gem::Source::Git.new @name, @repository, 'master', true + source = Gem::Source::Git.new @name, @repository, "master", true - git_gem 'b' + git_gem "b" - Dir.chdir 'git/a' do + Dir.chdir "git/a" do require "open3" - output, status = Open3.capture2e(@git, 'submodule', '--quiet', 'add', File.expand_path('../b'), 'b') + output, status = Open3.capture2e(@git, "submodule", "--quiet", "add", File.expand_path("../b"), "b") assert status.success?, output - system @git, 'commit', '--quiet', '-m', 'add submodule b' + system @git, "commit", "--quiet", "-m", "add submodule b" end source.checkout - assert_path_exist File.join source.install_dir, 'a.gemspec' - assert_path_exist File.join source.install_dir, 'b/b.gemspec' + assert_path_exist File.join source.install_dir, "a.gemspec" + assert_path_exist File.join source.install_dir, "b/b.gemspec" end def test_cache @@ -87,7 +87,7 @@ def test_cache assert_path_exist @source.repo_cache_dir Dir.chdir @source.repo_cache_dir do - assert_equal @head, Gem::Util.popen(@git, 'rev-parse', 'master').strip + assert_equal @head, Gem::Util.popen(@git, "rev-parse", "master").strip end end @@ -115,17 +115,17 @@ def test_equals2 assert_equal @source, @source.dup source = - Gem::Source::Git.new @source.name, @source.repository, 'other', false + Gem::Source::Git.new @source.name, @source.repository, "other", false refute_equal @source, source source = - Gem::Source::Git.new @source.name, 'repo/other', @source.reference, false + Gem::Source::Git.new @source.name, "repo/other", @source.reference, false refute_equal @source, source source = - Gem::Source::Git.new 'b', @source.repository, @source.reference, false + Gem::Source::Git.new "b", @source.repository, @source.reference, false refute_equal @source, source @@ -139,7 +139,7 @@ def test_equals2 def test_install_dir @source.cache - expected = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}" + expected = File.join Gem.dir, "bundler", "gems", "a-#{@head[0..11]}" assert_equal expected, @source.install_dir end @@ -152,14 +152,14 @@ def test_install_dir_local def test_repo_cache_dir expected = - File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}" + File.join Gem.dir, "cache", "bundler", "git", "a-#{@hash}" assert_equal expected, @source.repo_cache_dir @source.root_dir = "#{@gemhome}2" expected = - File.join "#{@gemhome}2", 'cache', 'bundler', 'git', "a-#{@hash}" + File.join "#{@gemhome}2", "cache", "bundler", "git", "a-#{@hash}" assert_equal expected, @source.repo_cache_dir end @@ -170,20 +170,20 @@ def test_rev_parse assert_equal @head, @source.rev_parse Dir.chdir @repository do - system @git, 'checkout', '--quiet', '-b', 'other' + system @git, "checkout", "--quiet", "-b", "other" end master_head = @head - git_gem 'a', 2 + git_gem "a", 2 - source = Gem::Source::Git.new @name, @repository, 'other', false + source = Gem::Source::Git.new @name, @repository, "other", false source.cache refute_equal master_head, source.rev_parse - source = Gem::Source::Git.new @name, @repository, 'nonexistent', false + source = Gem::Source::Git.new @name, @repository, "nonexistent", false source.cache @@ -204,38 +204,38 @@ def test_root_dir end def test_spaceship - git = Gem::Source::Git.new 'a', 'git/a', 'master', false + git = Gem::Source::Git.new "a", "git/a", "master", false remote = Gem::Source.new @gem_repo installed = Gem::Source::Installed.new - vendor = Gem::Source::Vendor.new 'vendor/foo' + vendor = Gem::Source::Vendor.new "vendor/foo" - assert_equal(0, git.<=>(git), 'git <=> git') + assert_equal(0, git.<=>(git), "git <=> git") - assert_equal(1, git.<=>(remote), 'git <=> remote') - assert_equal(-1, remote.<=>(git), 'remote <=> git') + assert_equal(1, git.<=>(remote), "git <=> remote") + assert_equal(-1, remote.<=>(git), "remote <=> git") - assert_equal(1, git.<=>(installed), 'git <=> installed') - assert_equal(-1, installed.<=>(git), 'installed <=> git') + assert_equal(1, git.<=>(installed), "git <=> installed") + assert_equal(-1, installed.<=>(git), "installed <=> git") - assert_equal(-1, git.<=>(vendor), 'git <=> vendor') - assert_equal(1, vendor.<=>(git), 'vendor <=> git') + assert_equal(-1, git.<=>(vendor), "git <=> vendor") + assert_equal(1, vendor.<=>(git), "vendor <=> git") end def test_specs - source = Gem::Source::Git.new @name, @repository, 'master', true + source = Gem::Source::Git.new @name, @repository, "master", true - Dir.chdir 'git/a' do - FileUtils.mkdir 'b' + Dir.chdir "git/a" do + FileUtils.mkdir "b" - Dir.chdir 'b' do - b = Gem::Specification.new 'b', 1 + Dir.chdir "b" do + b = Gem::Specification.new "b", 1 - File.open 'b.gemspec', 'w' do |io| + File.open "b.gemspec", "w" do |io| io.write b.to_ruby end - system @git, 'add', 'b.gemspec' - system @git, 'commit', '--quiet', '-m', 'add b/b.gemspec' + system @git, "add", "b.gemspec" + system @git, "commit", "--quiet", "-m", "add b/b.gemspec" end end @@ -252,11 +252,11 @@ def test_specs base_dir = File.dirname File.dirname source.install_dir assert_equal source.install_dir, a_spec.full_gem_path - assert_equal File.join(source.install_dir, 'a.gemspec'), a_spec.loaded_from + assert_equal File.join(source.install_dir, "a.gemspec"), a_spec.loaded_from assert_equal base_dir, a_spec.base_dir extension_dir = - File.join Gem.dir, 'bundler', 'extensions', + File.join Gem.dir, "bundler", "extensions", Gem::Platform.local.to_s, Gem.extension_api_version, "a-#{source.dir_shortref}" @@ -264,8 +264,8 @@ def test_specs b_spec = specs.shift - assert_equal File.join(source.install_dir, 'b'), b_spec.full_gem_path - assert_equal File.join(source.install_dir, 'b', 'b.gemspec'), + assert_equal File.join(source.install_dir, "b"), b_spec.full_gem_path + assert_equal File.join(source.install_dir, "b", "b.gemspec"), b_spec.loaded_from assert_equal base_dir, b_spec.base_dir @@ -273,7 +273,7 @@ def test_specs end def test_specs_local - source = Gem::Source::Git.new @name, @repository, 'master', true + source = Gem::Source::Git.new @name, @repository, "master", true source.remote = false capture_output do @@ -289,15 +289,15 @@ def test_uri_hash assert_equal @hash, @source.uri_hash source = - Gem::Source::Git.new 'a', 'http://git@example/repo.git', 'master', false + Gem::Source::Git.new "a", "http://git@example/repo.git", "master", false - assert_equal '291c4caac7feba8bb64c297987028acb3dde6cfe', + assert_equal "291c4caac7feba8bb64c297987028acb3dde6cfe", source.uri_hash source = - Gem::Source::Git.new 'a', 'HTTP://git@EXAMPLE/repo.git', 'master', false + Gem::Source::Git.new "a", "HTTP://git@EXAMPLE/repo.git", "master", false - assert_equal '291c4caac7feba8bb64c297987028acb3dde6cfe', + assert_equal "291c4caac7feba8bb64c297987028acb3dde6cfe", source.uri_hash end end diff --git a/test/rubygems/test_gem_source_installed.rb b/test/rubygems/test_gem_source_installed.rb index ef9b63e6113d..7fb5017c5970 100644 --- a/test/rubygems/test_gem_source_installed.rb +++ b/test/rubygems/test_gem_source_installed.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' +require_relative "helper" +require "rubygems/source" class TestGemSourceInstalled < Gem::TestCase def test_spaceship - a1 = quick_gem 'a', '1' + a1 = quick_gem "a", "1" util_build_gem a1 remote = Gem::Source.new @gem_repo specific = Gem::Source::SpecificFile.new a1.cache_file installed = Gem::Source::Installed.new local = Gem::Source::Local.new - git = Gem::Source::Git.new 'a', 'a', 'master' - vendor = Gem::Source::Vendor.new 'a' + git = Gem::Source::Git.new "a", "a", "master" + vendor = Gem::Source::Vendor.new "a" - assert_equal(0, installed.<=>(installed), 'installed <=> installed') + assert_equal(0, installed.<=>(installed), "installed <=> installed") - assert_equal(-1, remote.<=>(installed), 'remote <=> installed') - assert_equal(1, installed.<=>(remote), 'installed <=> remote') + assert_equal(-1, remote.<=>(installed), "remote <=> installed") + assert_equal(1, installed.<=>(remote), "installed <=> remote") - assert_equal(1, installed.<=>(local), 'installed <=> local') - assert_equal(-1, local.<=>(installed), 'local <=> installed') + assert_equal(1, installed.<=>(local), "installed <=> local") + assert_equal(-1, local.<=>(installed), "local <=> installed") - assert_equal(-1, specific.<=>(installed), 'specific <=> installed') - assert_equal(1, installed.<=>(specific), 'installed <=> specific') + assert_equal(-1, specific.<=>(installed), "specific <=> installed") + assert_equal(1, installed.<=>(specific), "installed <=> specific") - assert_equal(1, git. <=>(installed), 'git <=> installed') - assert_equal(-1, installed.<=>(git), 'installed <=> git') + assert_equal(1, git. <=>(installed), "git <=> installed") + assert_equal(-1, installed.<=>(git), "installed <=> git") - assert_equal(1, vendor.<=>(installed), 'vendor <=> installed') - assert_equal(-1, installed.<=>(vendor), 'installed <=> vendor') + assert_equal(1, vendor.<=>(installed), "vendor <=> installed") + assert_equal(-1, installed.<=>(vendor), "installed <=> vendor") end end diff --git a/test/rubygems/test_gem_source_list.rb b/test/rubygems/test_gem_source_list.rb index 6ac5dbb2a670..9fd1b3bdf981 100644 --- a/test/rubygems/test_gem_source_list.rb +++ b/test/rubygems/test_gem_source_list.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'rubygems' -require 'rubygems/source_list' -require_relative 'helper' +require "rubygems" +require "rubygems/source_list" +require_relative "helper" class TestGemSourceList < Gem::TestCase def setup @@ -45,7 +45,7 @@ def test_append def test_clear sl = Gem::SourceList.new - sl << 'http://source.example' + sl << "http://source.example" sl.clear @@ -76,7 +76,7 @@ def test_empty? assert_empty sl - sl << 'http://source.example' + sl << "http://source.example" refute_empty sl end diff --git a/test/rubygems/test_gem_source_local.rb b/test/rubygems/test_gem_source_local.rb index 2d4ddbc3a460..ace392300952 100644 --- a/test/rubygems/test_gem_source_local.rb +++ b/test/rubygems/test_gem_source_local.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' +require_relative "helper" +require "rubygems/source" -require 'fileutils' +require "fileutils" class TestGemSourceLocal < Gem::TestCase def setup @@ -10,9 +10,9 @@ def setup @sl = Gem::Source::Local.new - @a, @a_gem = util_gem "a", '1' - @ap, @ap_gem = util_gem "a", '2.a' - @b, @b_gem = util_gem "b", '1' + @a, @a_gem = util_gem "a", "1" + @ap, @ap_gem = util_gem "a", "2.a" + @b, @b_gem = util_gem "b", "1" FileUtils.mv @a_gem, @tempdir FileUtils.mv @ap_gem, @tempdir @@ -84,7 +84,7 @@ def test_download end def test_spaceship - a1 = quick_gem 'a', '1' + a1 = quick_gem "a", "1" util_build_gem a1 remote = Gem::Source.new @gem_repo @@ -92,15 +92,15 @@ def test_spaceship installed = Gem::Source::Installed.new local = Gem::Source::Local.new - assert_equal(0, local.<=>(local), 'local <=> local') + assert_equal(0, local.<=>(local), "local <=> local") - assert_equal(-1, remote.<=>(local), 'remote <=> local') - assert_equal(1, local.<=>(remote), 'local <=> remote') + assert_equal(-1, remote.<=>(local), "remote <=> local") + assert_equal(1, local.<=>(remote), "local <=> remote") - assert_equal(1, installed.<=>(local), 'installed <=> local') - assert_equal(-1, local.<=>(installed), 'local <=> installed') + assert_equal(1, installed.<=>(local), "installed <=> local") + assert_equal(-1, local.<=>(installed), "local <=> installed") - assert_equal(-1, specific.<=>(local), 'specific <=> local') - assert_equal(1, local.<=>(specific), 'local <=> specific') + assert_equal(-1, specific.<=>(local), "specific <=> local") + assert_equal(1, local.<=>(specific), "local <=> specific") end end diff --git a/test/rubygems/test_gem_source_lock.rb b/test/rubygems/test_gem_source_lock.rb index 5f916cdf7ff9..ff9465d0ad33 100644 --- a/test/rubygems/test_gem_source_lock.rb +++ b/test/rubygems/test_gem_source_lock.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemSourceLock < Gem::TestCase def test_fetch_spec spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end - name_tuple = Gem::NameTuple.new 'a', v(1), 'ruby' + name_tuple = Gem::NameTuple.new "a", v(1), "ruby" remote = Gem::Source.new @gem_repo lock = Gem::Source::Lock.new remote spec = lock.fetch_spec name_tuple - assert_equal 'a-1', spec.full_name + assert_equal "a-1", spec.full_name end def test_equals2 - git = Gem::Source::Git.new 'a', 'git/a', 'master', false + git = Gem::Source::Git.new "a", "git/a", "master", false g_lock = Gem::Source::Lock.new git installed = Gem::Source::Installed.new @@ -30,77 +30,77 @@ def test_equals2 end def test_spaceship - git = Gem::Source::Git.new 'a', 'git/a', 'master', false + git = Gem::Source::Git.new "a", "git/a", "master", false g_lock = Gem::Source::Lock.new git installed = Gem::Source::Installed.new i_lock = Gem::Source::Lock.new installed - vendor = Gem::Source::Vendor.new 'vendor/a' + vendor = Gem::Source::Vendor.new "vendor/a" v_lock = Gem::Source::Lock.new vendor - assert_equal(0, g_lock.<=>(g_lock), 'g_lock <=> g_lock') - assert_equal(0, i_lock.<=>(i_lock), 'i_lock <=> i_lock') - assert_equal(0, v_lock.<=>(v_lock), 'v_lock <=> v_lock') + assert_equal(0, g_lock.<=>(g_lock), "g_lock <=> g_lock") + assert_equal(0, i_lock.<=>(i_lock), "i_lock <=> i_lock") + assert_equal(0, v_lock.<=>(v_lock), "v_lock <=> v_lock") - assert_equal(1, g_lock.<=>(i_lock), 'g_lock <=> i_lock') - assert_equal(-1, i_lock.<=>(g_lock), 'i_lock <=> g_lock') + assert_equal(1, g_lock.<=>(i_lock), "g_lock <=> i_lock") + assert_equal(-1, i_lock.<=>(g_lock), "i_lock <=> g_lock") - assert_equal(-1, g_lock.<=>(v_lock), 'g_lock <=> v_lock') - assert_equal(1, v_lock.<=>(g_lock), 'v_lock <=> g_lock') + assert_equal(-1, g_lock.<=>(v_lock), "g_lock <=> v_lock") + assert_equal(1, v_lock.<=>(g_lock), "v_lock <=> g_lock") - assert_equal(-1, i_lock.<=>(v_lock), 'i_lock <=> v_lock') - assert_equal(1, v_lock.<=>(i_lock), 'i_lock <=> v_lock') + assert_equal(-1, i_lock.<=>(v_lock), "i_lock <=> v_lock") + assert_equal(1, v_lock.<=>(i_lock), "i_lock <=> v_lock") end def test_spaceship_git - git = Gem::Source::Git.new 'a', 'git/a', 'master', false + git = Gem::Source::Git.new "a", "git/a", "master", false lock = Gem::Source::Lock.new git - assert_equal(1, lock.<=>(git), 'lock <=> git') - assert_equal(-1, git.<=>(lock), 'git <=> lock') + assert_equal(1, lock.<=>(git), "lock <=> git") + assert_equal(-1, git.<=>(lock), "git <=> lock") end def test_spaceship_installed installed = Gem::Source::Installed.new lock = Gem::Source::Lock.new installed - assert_equal(1, lock.<=>(installed), 'lock <=> installed') - assert_equal(-1, installed.<=>(lock), 'installed <=> lock') + assert_equal(1, lock.<=>(installed), "lock <=> installed") + assert_equal(-1, installed.<=>(lock), "installed <=> lock") end def test_spaceship_local local = Gem::Source::Local.new lock = Gem::Source::Lock.new local # nonsense - assert_equal(1, lock.<=>(local), 'lock <=> local') - assert_equal(-1, local.<=>(lock), 'local <=> lock') + assert_equal(1, lock.<=>(local), "lock <=> local") + assert_equal(-1, local.<=>(lock), "local <=> lock") end def test_spaceship_remote remote = Gem::Source.new @gem_repo lock = Gem::Source::Lock.new remote - assert_equal(1, lock.<=>(remote), 'lock <=> remote') - assert_equal(-1, remote.<=>(lock), 'remote <=> lock') + assert_equal(1, lock.<=>(remote), "lock <=> remote") + assert_equal(-1, remote.<=>(lock), "remote <=> lock") end def test_spaceship_specific_file - _, gem = util_gem 'a', 1 + _, gem = util_gem "a", 1 specific = Gem::Source::SpecificFile.new gem lock = Gem::Source::Lock.new specific # nonsense - assert_equal(1, lock.<=>(specific), 'lock <=> specific') - assert_equal(-1, specific.<=>(lock), 'specific <=> lock') + assert_equal(1, lock.<=>(specific), "lock <=> specific") + assert_equal(-1, specific.<=>(lock), "specific <=> lock") end def test_spaceship_vendor - vendor = Gem::Source::Vendor.new 'vendor/a' + vendor = Gem::Source::Vendor.new "vendor/a" lock = Gem::Source::Lock.new vendor - assert_equal(1, lock.<=>(vendor), 'lock <=> vendor') - assert_equal(-1, vendor.<=>(lock), 'vendor <=> lock') + assert_equal(1, lock.<=>(vendor), "lock <=> vendor") + assert_equal(-1, vendor.<=>(lock), "vendor <=> lock") end def test_uri diff --git a/test/rubygems/test_gem_source_specific_file.rb b/test/rubygems/test_gem_source_specific_file.rb index 72ed993a8817..f9a572b76d23 100644 --- a/test/rubygems/test_gem_source_specific_file.rb +++ b/test/rubygems/test_gem_source_specific_file.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' +require_relative "helper" +require "rubygems/source" class TestGemSourceSpecificFile < Gem::TestCase def setup super - @a, @a_gem = util_gem "a", '1' + @a, @a_gem = util_gem "a", "1" @sf = Gem::Source::SpecificFile.new(@a_gem) end @@ -37,7 +37,7 @@ def test_download end def test_spaceship - a1 = quick_gem 'a', '1' + a1 = quick_gem "a", "1" util_build_gem a1 remote = Gem::Source.new @gem_repo @@ -45,31 +45,31 @@ def test_spaceship installed = Gem::Source::Installed.new local = Gem::Source::Local.new - assert_equal(0, specific.<=>(specific), 'specific <=> specific') + assert_equal(0, specific.<=>(specific), "specific <=> specific") - assert_equal(-1, remote.<=>(specific), 'remote <=> specific') - assert_equal(1, specific.<=>(remote), 'specific <=> remote') + assert_equal(-1, remote.<=>(specific), "remote <=> specific") + assert_equal(1, specific.<=>(remote), "specific <=> remote") - assert_equal(-1, specific.<=>(local), 'specific <=> local') - assert_equal(1, local. <=>(specific), 'local <=> specific') + assert_equal(-1, specific.<=>(local), "specific <=> local") + assert_equal(1, local. <=>(specific), "local <=> specific") - assert_equal(-1, specific. <=>(installed), 'specific <=> installed') - assert_equal(1, installed.<=>(specific), 'installed <=> specific') + assert_equal(-1, specific. <=>(installed), "specific <=> installed") + assert_equal(1, installed.<=>(specific), "installed <=> specific") - a2 = quick_gem 'a', '2' + a2 = quick_gem "a", "2" util_build_gem a2 - b1 = quick_gem 'b', '1' + b1 = quick_gem "b", "1" util_build_gem b1 a1_source = specific a2_source = Gem::Source::SpecificFile.new a2.cache_file b1_source = Gem::Source::SpecificFile.new b1.cache_file - assert_nil a1_source.<=>(b1_source), 'a1_source <=> b1_source' + assert_nil a1_source.<=>(b1_source), "a1_source <=> b1_source" - assert_equal(-1, a1_source.<=>(a2_source), 'a1_source <=> a2_source') - assert_equal(0, a1_source.<=>(a1_source), 'a1_source <=> a1_source') - assert_equal(1, a2_source.<=>(a1_source), 'a2_source <=> a1_source') + assert_equal(-1, a1_source.<=>(a2_source), "a1_source <=> a2_source") + assert_equal(0, a1_source.<=>(a1_source), "a1_source <=> a1_source") + assert_equal(1, a2_source.<=>(a1_source), "a2_source <=> a1_source") end end diff --git a/test/rubygems/test_gem_source_subpath_problem.rb b/test/rubygems/test_gem_source_subpath_problem.rb index c37df39f0c41..219c3442904f 100644 --- a/test/rubygems/test_gem_source_subpath_problem.rb +++ b/test/rubygems/test_gem_source_subpath_problem.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' +require_relative "helper" +require "rubygems/source" class TestGemSourceSubpathProblem < Gem::TestCase def tuple(*args) @@ -20,8 +20,8 @@ def setup end def test_dependency_resolver_set - response = Net::HTTPResponse.new '1.1', 200, 'OK' - response.uri = URI('http://example') + response = Net::HTTPResponse.new "1.1", 200, "OK" + response.uri = URI("http://example") @fetcher.data["#{@gem_repo}/"] = response @@ -33,14 +33,14 @@ def test_dependency_resolver_set def test_fetch_spec @fetcher.data["#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] = Zlib::Deflate.deflate(Marshal.dump(@a1)) - spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby') + spec = @source.fetch_spec tuple("a", Gem::Version.new(1), "ruby") assert_equal @a1.full_name, spec.full_name end def test_load_specs @fetcher.data["#{@gem_repo}/latest_specs.#{Gem.marshal_version}.gz"] = util_gzip(Marshal.dump([ - Gem::NameTuple.new(@a1.name, @a1.version, 'ruby'), - Gem::NameTuple.new(@b2.name, @b2.version, 'ruby'), + Gem::NameTuple.new(@a1.name, @a1.version, "ruby"), + Gem::NameTuple.new(@b2.name, @b2.version, "ruby"), ])) released = @source.load_specs(:latest).map {|spec| spec.full_name } diff --git a/test/rubygems/test_gem_source_vendor.rb b/test/rubygems/test_gem_source_vendor.rb index a5ffb0f223a4..29846e5c1360 100644 --- a/test/rubygems/test_gem_source_vendor.rb +++ b/test/rubygems/test_gem_source_vendor.rb @@ -1,29 +1,29 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/source' +require_relative "helper" +require "rubygems/source" class TestGemSourceVendor < Gem::TestCase def test_initialize - source = Gem::Source::Vendor.new 'vendor/foo' + source = Gem::Source::Vendor.new "vendor/foo" - assert_equal 'vendor/foo', source.uri + assert_equal "vendor/foo", source.uri end def test_spaceship - vendor = Gem::Source::Vendor.new 'vendor/foo' + vendor = Gem::Source::Vendor.new "vendor/foo" remote = Gem::Source.new @gem_repo - git = Gem::Source::Git.new 'a', 'a', 'master' + git = Gem::Source::Git.new "a", "a", "master" installed = Gem::Source::Installed.new - assert_equal(0, vendor.<=>(vendor), 'vendor <=> vendor') + assert_equal(0, vendor.<=>(vendor), "vendor <=> vendor") - assert_equal(1, vendor.<=>(remote), 'vendor <=> remote') - assert_equal(-1, remote.<=>(vendor), 'remote <=> vendor') + assert_equal(1, vendor.<=>(remote), "vendor <=> remote") + assert_equal(-1, remote.<=>(vendor), "remote <=> vendor") - assert_equal(1, vendor.<=>(git), 'vendor <=> git') - assert_equal(-1, git.<=>(vendor), 'git <=> vendor') + assert_equal(1, vendor.<=>(git), "vendor <=> git") + assert_equal(-1, git.<=>(vendor), "git <=> vendor") - assert_equal(1, vendor.<=>(installed), 'vendor <=> installed') - assert_equal(-1, installed.<=>(vendor), 'installed <=> vendor') + assert_equal(1, vendor.<=>(installed), "vendor <=> installed") + assert_equal(-1, installed.<=>(vendor), "installed <=> vendor") end end diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb index afae46e12086..f23a93350bcf 100644 --- a/test/rubygems/test_gem_spec_fetcher.rb +++ b/test/rubygems/test_gem_spec_fetcher.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/spec_fetcher' +require_relative "helper" +require "rubygems/spec_fetcher" class TestGemSpecFetcher < Gem::TestCase def tuple(*args) @@ -23,7 +23,7 @@ def test_initialize end def test_initialize_source - alternate = 'http://alternate.example' + alternate = "http://alternate.example" fetcher = Gem::SpecFetcher.new alternate refute_same Gem.sources, fetcher.sources @@ -38,7 +38,7 @@ def test_initialize_nonexistent_home_dir end def test_initialize_unwritable_home_dir - pend 'chmod not supported' if Gem.win_platform? + pend "chmod not supported" if Gem.win_platform? FileUtils.chmod 0000, Gem.user_home @@ -51,13 +51,13 @@ def test_initialize_unwritable_home_dir def test_spec_for_dependency_all spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" end - dep = Gem::Dependency.new 'a', ">= 1" + dep = Gem::Dependency.new "a", ">= 1" specs_and_sources, _ = @sf.spec_for_dependency dep @@ -65,7 +65,7 @@ def test_spec_for_dependency_all [spec.full_name, source_uri] end - expected = [['a-1', @source], ['a-2', @source]] + expected = [["a-1", @source], ["a-2", @source]] assert_equal expected, spec_names @@ -74,63 +74,63 @@ def test_spec_for_dependency_all def test_spec_for_dependency_latest spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" end - dep = Gem::Dependency.new 'a' + dep = Gem::Dependency.new "a" specs_and_sources, _ = @sf.spec_for_dependency dep spec_names = specs_and_sources.map do |spec, source_uri| [spec.full_name, source_uri] end - assert_equal [['a-2', Gem::Source.new(@gem_repo)]], + assert_equal [["a-2", Gem::Source.new(@gem_repo)]], spec_names end def test_spec_for_dependency_prerelease spec_fetcher do |fetcher| - fetcher.spec 'a', '1.a' - fetcher.spec 'a', 1 + fetcher.spec "a", "1.a" + fetcher.spec "a", 1 end - specs_and_sources, _ = @sf.spec_for_dependency dep('a', '1.a') + specs_and_sources, _ = @sf.spec_for_dependency dep("a", "1.a") spec_names = specs_and_sources.map do |spec, source_uri| [spec.full_name, source_uri] end - assert_equal [['a-1.a', Gem::Source.new(@gem_repo)]], spec_names + assert_equal [["a-1.a", Gem::Source.new(@gem_repo)]], spec_names end def test_spec_for_dependency_platform - util_set_arch 'i386-linux' + util_set_arch "i386-linux" spec_fetcher do |fetcher| fetcher.legacy_platform end - dep = Gem::Dependency.new 'pl', 1 + dep = Gem::Dependency.new "pl", 1 specs_and_sources, _ = @sf.spec_for_dependency dep spec_names = specs_and_sources.map do |spec, source_uri| [spec.full_name, source_uri] end - assert_equal [['pl-1-x86-linux', Gem::Source.new(@gem_repo)]], + assert_equal [["pl-1-x86-linux", Gem::Source.new(@gem_repo)]], spec_names end def test_spec_for_dependency_mismatched_platform - util_set_arch 'hrpa-989' + util_set_arch "hrpa-989" spec_fetcher do |fetcher| fetcher.legacy_platform end - dep = Gem::Dependency.new 'pl', 1 + dep = Gem::Dependency.new "pl", 1 specs_and_sources, errors = @sf.spec_for_dependency dep assert_equal 0, specs_and_sources.size @@ -150,13 +150,13 @@ def src.fetch_spec(name) Gem.sources.replace [src] spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" end - dep = Gem::Dependency.new 'a', ">= 1" + dep = Gem::Dependency.new "a", ">= 1" specs_and_sources, errors = @sf.spec_for_dependency dep @@ -170,38 +170,38 @@ def src.fetch_spec(name) def test_suggest_gems_from_name_latest spec_fetcher do|fetcher| - fetcher.spec 'example', 1 - fetcher.spec 'other-example', 1 - fetcher.spec 'examp', 1 + fetcher.spec "example", 1 + fetcher.spec "other-example", 1 + fetcher.spec "examp", 1 end - suggestions = @sf.suggest_gems_from_name('examplw', :latest, 1) - assert_equal ['example'], suggestions + suggestions = @sf.suggest_gems_from_name("examplw", :latest, 1) + assert_equal ["example"], suggestions - suggestions = @sf.suggest_gems_from_name('other') - assert_equal ['other-example'], suggestions + suggestions = @sf.suggest_gems_from_name("other") + assert_equal ["other-example"], suggestions - suggestions = @sf.suggest_gems_from_name('exam') - assert suggestions.any? { ['examp'] } - assert suggestions.any? { ['example'] } - assert suggestions.any? { ['other-example'] } + suggestions = @sf.suggest_gems_from_name("exam") + assert suggestions.any? { ["examp"] } + assert suggestions.any? { ["example"] } + assert suggestions.any? { ["other-example"] } end def test_suggest_gems_from_name_prerelease spec_fetcher do|fetcher| - fetcher.spec 'example', '1.a' - fetcher.spec 'other-example', 1 + fetcher.spec "example", "1.a" + fetcher.spec "other-example", 1 end - suggestions = @sf.suggest_gems_from_name('examplw') - assert_equal ['example'], suggestions + suggestions = @sf.suggest_gems_from_name("examplw") + assert_equal ["example"], suggestions end def test_available_specs_latest spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' + fetcher.spec "a", 1 + fetcher.spec "a", 2 + fetcher.spec "a", "3.a" fetcher.legacy_platform end @@ -210,15 +210,15 @@ def test_available_specs_latest assert_equal [@source], specs.keys expected = Gem::NameTuple.from_list \ - [['a', v(2), Gem::Platform::RUBY], - ['pl', v(1), 'i386-linux']] + [["a", v(2), Gem::Platform::RUBY], + ["pl", v(1), "i386-linux"]] assert_equal expected, specs[@source] end def test_available_specs_released spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 fetcher.legacy_platform end @@ -227,17 +227,17 @@ def test_available_specs_released assert_equal [@source], specs.keys expected = Gem::NameTuple.from_list \ - [['a', v(1), Gem::Platform::RUBY], - ['pl', v(1), 'i386-linux']] + [["a", v(1), Gem::Platform::RUBY], + ["pl", v(1), "i386-linux"]] assert_equal expected, specs[@source] end def test_available_specs_complete spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'b', 2 + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "b", 2 fetcher.legacy_platform end @@ -246,19 +246,19 @@ def test_available_specs_complete assert_equal [@source], specs.keys expected = Gem::NameTuple.from_list \ - [['a', v(1), Gem::Platform::RUBY], - ['a', v('2.a'), Gem::Platform::RUBY], - ['b', v(2), Gem::Platform::RUBY], - ['pl', v(1), 'i386-linux']] + [["a", v(1), Gem::Platform::RUBY], + ["a", v("2.a"), Gem::Platform::RUBY], + ["b", v(2), Gem::Platform::RUBY], + ["pl", v(1), "i386-linux"]] assert_equal expected, specs[@source] end def test_available_specs_complete_handles_no_prerelease spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'b', 2 + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "b", 2 fetcher.legacy_platform end @@ -270,16 +270,16 @@ def test_available_specs_complete_handles_no_prerelease assert_equal [@source], specs.keys expected = Gem::NameTuple.from_list \ - [['a', v(1), Gem::Platform::RUBY], - ['b', v(2), Gem::Platform::RUBY], - ['pl', v(1), 'i386-linux']] + [["a", v(1), Gem::Platform::RUBY], + ["b", v(2), Gem::Platform::RUBY], + ["pl", v(1), "i386-linux"]] assert_equal expected, specs[@source] end def test_available_specs_cache spec_fetcher do |fetcher| - fetcher.spec 'a', 1 + fetcher.spec "a", 1 end specs, _ = @sf.available_specs(:latest) @@ -295,9 +295,9 @@ def test_available_specs_cache def test_available_specs_cache_released spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' - fetcher.spec 'b', 2 + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" + fetcher.spec "b", 2 fetcher.legacy_platform end @@ -314,14 +314,14 @@ def test_available_specs_cache_released def test_available_specs_prerelease spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', '2.a' + fetcher.spec "a", 1 + fetcher.spec "a", "2.a" end specs, _ = @sf.available_specs(:prerelease) expected = Gem::NameTuple.from_list \ - [['a', v('2.a'), Gem::Platform::RUBY]] + [["a", v("2.a"), Gem::Platform::RUBY]] assert_equal expected, specs[@source] end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 3f955ce65616..6117e81a81a4 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'benchmark' -require_relative 'helper' -require 'date' -require 'pathname' -require 'stringio' -require 'rubygems/ext' -require 'rubygems/specification' -require 'rubygems/installer' -require 'rubygems/platform' +require "benchmark" +require_relative "helper" +require "date" +require "pathname" +require "stringio" +require "rubygems/ext" +require "rubygems/specification" +require "rubygems/installer" +require "rubygems/platform" class TestGemSpecification < Gem::TestCase LEGACY_YAML_SPEC = <<-EOF.freeze @@ -44,16 +44,16 @@ class TestGemSpecification < Gem::TestCase EOF def make_spec_c1 - @c1 = util_spec 'a', '1' do |s| - s.executable = 'exec' - s.extensions << 'ext/a/extconf.rb' - s.test_file = 'test/suite.rb' - s.requirements << 'A working computer' - s.license = 'MIT' + @c1 = util_spec "a", "1" do |s| + s.executable = "exec" + s.extensions << "ext/a/extconf.rb" + s.test_file = "test/suite.rb" + s.requirements << "A working computer" + s.license = "MIT" - s.add_dependency 'rake', '> 0.4' - s.add_dependency 'jabber4r', '> 0.0.0' - s.add_dependency 'pqa', ['> 0.4', '<= 0.6'] + s.add_dependency "rake", "> 0.4" + s.add_dependency "jabber4r", "> 0.0.0" + s.add_dependency "pqa", ["> 0.4", "<= 0.6"] s.mark_version s.files = %w[lib/code.rb] @@ -61,16 +61,16 @@ def make_spec_c1 end def ext_spec(platform: Gem::Platform::RUBY) - @ext = util_spec 'ext', '1' do |s| - s.executable = 'exec' - s.test_file = 'test/suite.rb' + @ext = util_spec "ext", "1" do |s| + s.executable = "exec" + s.test_file = "test/suite.rb" s.extensions = %w[ext/extconf.rb] - s.license = 'MIT' + s.license = "MIT" s.platform = platform s.mark_version s.files = %w[lib/code.rb] - s.installed_by_version = v('2.2') + s.installed_by_version = v("2.2") end end @@ -88,40 +88,40 @@ def setup # is not set. Gem.instance_variable_set(:'@default_source_date_epoch', nil) - @a1 = util_spec 'a', '1' do |s| - s.executable = 'exec' - s.test_file = 'test/suite.rb' - s.requirements << 'A working computer' - s.license = 'MIT' + @a1 = util_spec "a", "1" do |s| + s.executable = "exec" + s.test_file = "test/suite.rb" + s.requirements << "A working computer" + s.license = "MIT" s.mark_version s.files = %w[lib/code.rb] end - @a2 = util_spec 'a', '2' do |s| + @a2 = util_spec "a", "2" do |s| s.files = %w[lib/code.rb] end - @a3 = util_spec 'a', '3' do |s| - s.metadata['allowed_push_host'] = "https://privategemserver.com" + @a3 = util_spec "a", "3" do |s| + s.metadata["allowed_push_host"] = "https://privategemserver.com" end @current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION end def test_self_find_active_stub_by_path - spec = util_spec('a', '1', nil, 'lib/foo.rb') + spec = util_spec("a", "1", nil, "lib/foo.rb") spec.activated = true # There used to be a bug (introduced in a9c1aaf) when Gem::Specification # objects are present in the @stubs collection. This test verifies that # this scenario works correctly. Gem::Specification.all = [spec] - assert_equal spec, Gem::Specification.find_active_stub_by_path('foo') + assert_equal spec, Gem::Specification.find_active_stub_by_path("foo") end def test_self_activate - foo = util_spec 'foo', '1' + foo = util_spec "foo", "1" assert_activate %w[foo-1], foo end @@ -147,7 +147,7 @@ def test_self_activate_ambiguous_direct end def test_find_in_unresolved_tree_is_not_exponentiental - pend "currently slower in CI on TruffleRuby" if RUBY_ENGINE == 'truffleruby' + pend "currently slower in CI on TruffleRuby" if RUBY_ENGINE == "truffleruby" num_of_pkg = 7 num_of_version_per_pkg = 3 packages = (0..num_of_pkg).map do |pkgi| @@ -166,7 +166,7 @@ def test_find_in_unresolved_tree_is_not_exponentiental base.activate tms = Benchmark.measure do - assert_raise(LoadError) { require 'no_such_file_foo' } + assert_raise(LoadError) { require "no_such_file_foo" } end assert_operator tms.total, :<=, 10 end @@ -372,13 +372,13 @@ def test_inner_clonflict_in_indirect_gems_reversed # [B] ~> 1.0 (satisfied by 1.0) def test_self_activate_checks_dependencies - a = util_spec 'a', '1.0' - a.add_dependency 'c', '= 1.0' - a.add_dependency 'b', '~> 1.0' + a = util_spec "a", "1.0" + a.add_dependency "c", "= 1.0" + a.add_dependency "b", "~> 1.0" - b1 = util_spec 'b', '1.0' - b2 = util_spec 'b', '2.0' - c = util_spec 'c', '1.0', 'b' => '= 2.0' + b1 = util_spec "b", "1.0" + b2 = util_spec "b", "2.0" + c = util_spec "c", "1.0", "b" => "= 2.0" install_specs b1, b2, c, a e = assert_raise Gem::LoadError do @@ -396,10 +396,10 @@ def test_self_activate_checks_dependencies # [B] = 2.0 def test_self_activate_divergent - a = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0' - b1 = util_spec 'b', '1.0' - b2 = util_spec 'b', '2.0' - c = util_spec 'c', '1.0', 'b' => '= 2.0' + a = util_spec "a", "1.0", "b" => "~> 1.0", "c" => "= 1.0" + b1 = util_spec "b", "1.0" + b2 = util_spec "b", "2.0" + c = util_spec "c", "1.0", "b" => "= 2.0" install_specs b1, b2, c, a @@ -415,9 +415,9 @@ def test_self_activate_divergent # DOC def test_self_activate_old_required - e1, = util_spec 'e', '1', 'd' => '= 1' - @d1 = util_spec 'd', '1' - @d2 = util_spec 'd', '2' + e1, = util_spec "e", "1", "d" => "= 1" + @d1 = util_spec "d", "1" + @d2 = util_spec "d", "2" install_specs @d1, @d2, e1 @@ -428,17 +428,17 @@ def test_self_activate_old_required # DOC def test_self_activate_platform_alternate - @x1_m = util_spec 'x', '1' do |s| + @x1_m = util_spec "x", "1" do |s| s.platform = Gem::Platform.new %w[cpu my_platform 1] end - @x1_o = util_spec 'x', '1' do |s| + @x1_o = util_spec "x", "1" do |s| s.platform = Gem::Platform.new %w[cpu other_platform 1] end - @w1 = util_spec 'w', '1', 'x' => nil + @w1 = util_spec "w", "1", "x" => nil - util_set_arch 'cpu-my_platform1' + util_set_arch "cpu-my_platform1" install_specs @x1_m, @x1_o, @w1 assert_activate %w[x-1-cpu-my_platform-1 w-1], @w1, @x1_m @@ -448,13 +448,13 @@ def test_self_activate_platform_alternate # DOC def test_self_activate_platform_bump - @y1 = util_spec 'y', '1' + @y1 = util_spec "y", "1" - @y1_1_p = util_spec 'y', '1.1' do |s| + @y1_1_p = util_spec "y", "1.1" do |s| s.platform = Gem::Platform.new %w[cpu my_platform 1] end - @z1 = util_spec 'z', '1', 'y' => nil + @z1 = util_spec "z", "1", "y" => nil install_specs @y1, @y1_1_p, @z1 assert_activate %w[y-1 z-1], @z1, @y1 @@ -467,11 +467,11 @@ def test_self_activate_platform_bump # [A] >= 0 (satisfied by 1.a) def test_self_activate_prerelease - @c1_pre = util_spec 'c', '1.a', "a" => "1.a", "b" => "1" - @a1_pre = util_spec 'a', '1.a' - @b1 = util_spec 'b', '1' do |s| - s.add_dependency 'a' - s.add_development_dependency 'aa' + @c1_pre = util_spec "c", "1.a", "a" => "1.a", "b" => "1" + @a1_pre = util_spec "a", "1.a" + @b1 = util_spec "b", "1" do |s| + s.add_dependency "a" + s.add_development_dependency "aa" end install_specs @a1_pre, @b1, @c1_pre @@ -533,7 +533,7 @@ def test_self_activate_deep_unambiguous end def test_self_activate_loaded - foo = util_spec 'foo', '1' + foo = util_spec "foo", "1" assert foo.activate refute foo.activate @@ -545,9 +545,9 @@ def test_self_activate_loaded # [C] depends on nothing def test_self_activate_unrelated - a = util_spec 'a', '1.0', 'b' => '>= 1.0' - b = util_spec 'b', '1.0' - c = util_spec 'c', '1.0' + a = util_spec "a", "1.0", "b" => ">= 1.0" + b = util_spec "b", "1.0" + c = util_spec "c", "1.0" install_specs b, c, a assert_activate %w[b-1.0 c-1.0 a-1.0], a, c, "b" @@ -563,11 +563,11 @@ def test_self_activate_unrelated # TODO: move these to specification def test_self_activate_over - a = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '= 1.0' - install_specs util_spec 'b', '1.0' - install_specs util_spec 'b', '1.1' - install_specs util_spec 'b', '2.0' - install_specs util_spec 'c', '1.0', 'b' => '~> 1.0' + a = util_spec "a", "1.0", "b" => ">= 1.0", "c" => "= 1.0" + install_specs util_spec "b", "1.0" + install_specs util_spec "b", "1.1" + install_specs util_spec "b", "2.0" + install_specs util_spec "c", "1.0", "b" => "~> 1.0" install_specs a a.activate @@ -588,10 +588,10 @@ def test_self_activate_over # first resolve through a dependency that is later pruned. def test_self_activate_under - a = util_spec 'a', '1.0', 'b' => '~> 1.0', 'c' => '= 1.0' - b1 = util_spec 'b', '1.0' - b1_1 = util_spec 'b', '1.1' - c = util_spec 'c', '1.0', 'b' => '= 1.0' + a = util_spec "a", "1.0", "b" => "~> 1.0", "c" => "= 1.0" + b1 = util_spec "b", "1.0" + b1_1 = util_spec "b", "1.1" + c = util_spec "c", "1.0", "b" => "= 1.0" install_specs b1, b1_1, c, a @@ -607,10 +607,10 @@ def test_self_activate_under # [C1] depends on nothing def test_self_activate_dropped - a1 = util_spec 'a', '1', 'b' => nil - b1 = util_spec 'b', '1', 'c' => nil - b2 = util_spec 'b', '2' - c1 = util_spec 'c', '1' + a1 = util_spec "a", "1", "b" => nil + b1 = util_spec "b", "1", "c" => nil + b2 = util_spec "b", "2" + c1 = util_spec "c", "1" install_specs c1, b1, b2, a1 assert_activate %w[b-2 a-1], a1, "b" @@ -627,11 +627,11 @@ def test_self_activate_dropped # resolve. def test_self_activate_raggi_the_edgecase_generator - a = util_spec 'a', '1.0', 'b' => '>= 1.0', 'c' => '>= 1.0' - b1 = util_spec 'b', '1.0' - b1_0 = util_spec 'b', '1.1', 'z' => '>= 1.0' - c = util_spec 'c', '1.0', 'b' => '= 1.0' - z = util_spec 'z', '1' + a = util_spec "a", "1.0", "b" => ">= 1.0", "c" => ">= 1.0" + b1 = util_spec "b", "1.0" + b1_0 = util_spec "b", "1.1", "z" => ">= 1.0" + c = util_spec "c", "1.0", "b" => "= 1.0" + z = util_spec "z", "1" install_specs z, b1, b1_0, c, z @@ -639,8 +639,8 @@ def test_self_activate_raggi_the_edgecase_generator end def test_self_activate_conflict - install_specs util_spec 'b', '1.0' - install_specs util_spec 'b', '2.0' + install_specs util_spec "b", "1.0" + install_specs util_spec "b", "2.0" gem "b", "= 1.0" @@ -655,7 +655,7 @@ def test_self_all_equals install_specs a Gem::Specification.all = [a] - assert_equal a, Gem::Specification.find_inactive_by_path('foo') + assert_equal a, Gem::Specification.find_inactive_by_path("foo") end def test_self_attribute_names @@ -698,13 +698,13 @@ def test_self_attribute_names def test_self__load_future spec = Gem::Specification.new - spec.name = 'a' - spec.version = '1' + spec.name = "a" + spec.version = "1" spec.specification_version = @current_version + 1 load_spec = Marshal.load Marshal.dump(spec) - assert_equal 'a', load_spec.name + assert_equal "a", load_spec.name assert_equal Gem::Version.new(1), load_spec.version assert_equal @current_version, load_spec.specification_version end @@ -783,20 +783,20 @@ def test_self_load end def test_self_load_relative - File.open 'a-2.gemspec', 'w' do |io| + File.open "a-2.gemspec", "w" do |io| io.write @a2.to_ruby_for_cache end - spec = Gem::Specification.load 'a-2.gemspec' + spec = Gem::Specification.load "a-2.gemspec" @a2.files.clear assert_equal @a2, spec - assert_equal File.join(@tempdir, 'a-2.gemspec'), spec.loaded_from + assert_equal File.join(@tempdir, "a-2.gemspec"), spec.loaded_from end - if RUBY_ENGINE == 'ruby' and RUBY_VERSION < '2.7' + if RUBY_ENGINE == "ruby" and RUBY_VERSION < "2.7" def test_self_load_tainted full_path = @a2.spec_file write_file full_path do |io| @@ -874,13 +874,13 @@ def test_self_load_escape_quote end def test_self_load_utf8_with_ascii_encoding - with_internal_encoding('US-ASCII') do + with_internal_encoding("US-ASCII") do spec2 = @a2.dup bin = "\u5678".dup spec2.authors = [bin] full_path = spec2.spec_file write_file full_path do |io| - io.write spec2.to_ruby_for_cache.force_encoding('BINARY').sub("\\u{5678}", bin.force_encoding('BINARY')) + io.write spec2.to_ruby_for_cache.force_encoding("BINARY").sub("\\u{5678}", bin.force_encoding("BINARY")) end spec = Gem::Specification.load full_path @@ -895,10 +895,10 @@ def test_self_load_legacy_ruby spec = Gem::Deprecate.skip_during do eval LEGACY_RUBY_SPEC end - assert_equal 'keyedlist', spec.name - assert_equal '0.4.0', spec.version.to_s + assert_equal "keyedlist", spec.name + assert_equal "0.4.0", spec.version.to_s assert_kind_of Time, spec.date - assert spec.required_ruby_version.satisfied_by?(Gem::Version.new('1')) + assert spec.required_ruby_version.satisfied_by?(Gem::Version.new("1")) assert_equal false, spec.has_unit_tests? end @@ -933,9 +933,9 @@ def test_self_normalize_yaml_input_with_192_yaml def test_self_outdated spec_fetcher do |fetcher| - fetcher.download 'a', 4 + fetcher.download "a", 4 - fetcher.spec 'a', 3 + fetcher.spec "a", 3 end assert_equal %w[a], Gem::Specification.outdated @@ -943,16 +943,16 @@ def test_self_outdated def test_self_outdated_and_latest_remotes spec_fetcher do |fetcher| - fetcher.download 'a', 4 - fetcher.download 'b', 3 + fetcher.download "a", 4 + fetcher.download "b", 3 - fetcher.spec 'a', '3.a' - fetcher.spec 'b', 2 + fetcher.spec "a", "3.a" + fetcher.spec "b", 2 end expected = [ - [Gem::Specification.stubs.find {|s| s.full_name == 'a-3.a' }, v(4)], - [Gem::Specification.stubs.find {|s| s.full_name == 'b-2' }, v(3)], + [Gem::Specification.stubs.find {|s| s.full_name == "a-3.a" }, v(4)], + [Gem::Specification.stubs.find {|s| s.full_name == "b-2" }, v(3)], ] assert_equal expected, Gem::Specification.outdated_and_latest_version.to_a @@ -961,18 +961,18 @@ def test_self_outdated_and_latest_remotes def test_self_remove_spec install_specs @a1 - assert_includes Gem::Specification.all_names, 'a-1' - assert_includes Gem::Specification.stubs.map {|s| s.full_name }, 'a-1' + assert_includes Gem::Specification.all_names, "a-1" + assert_includes Gem::Specification.stubs.map {|s| s.full_name }, "a-1" uninstall_gem @a1 Gem::Specification.reset - refute_includes Gem::Specification.all_names, 'a-1' - refute_includes Gem::Specification.stubs.map {|s| s.full_name }, 'a-1' + refute_includes Gem::Specification.all_names, "a-1" + refute_includes Gem::Specification.stubs.map {|s| s.full_name }, "a-1" end def test_self_remove_spec_removed - File.open @a1.spec_file, 'w' do |io| + File.open @a1.spec_file, "w" do |io| io.write @a1.to_ruby end @@ -982,40 +982,40 @@ def test_self_remove_spec_removed Gem::Specification.reset - refute_includes Gem::Specification.all_names, 'a-1' - refute_includes Gem::Specification.stubs.map {|s| s.full_name }, 'a-1' + refute_includes Gem::Specification.all_names, "a-1" + refute_includes Gem::Specification.stubs.map {|s| s.full_name }, "a-1" end def test_self_stubs_for_lazy_loading Gem.loaded_specs.clear Gem::Specification.class_variable_set(:@@stubs, nil) - dir_standard_specs = File.join Gem.dir, 'specifications' + dir_standard_specs = File.join Gem.dir, "specifications" - save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' } - save_gemspec('b-1', '1', dir_standard_specs) {|s| s.name = 'b' } + save_gemspec("a-1", "1", dir_standard_specs) {|s| s.name = "a" } + save_gemspec("b-1", "1", dir_standard_specs) {|s| s.name = "b" } - assert_equal ['a-1'], Gem::Specification.stubs_for('a').map {|s| s.full_name } + assert_equal ["a-1"], Gem::Specification.stubs_for("a").map {|s| s.full_name } assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length - assert_equal ['b-1'], Gem::Specification.stubs_for('b').map {|s| s.full_name } + assert_equal ["b-1"], Gem::Specification.stubs_for("b").map {|s| s.full_name } assert_equal 2, Gem::Specification.class_variable_get(:@@stubs_by_name).length assert_equal( - Gem::Specification.stubs_for('a').map {|s| s.object_id }, - Gem::Specification.stubs_for('a').map {|s| s.object_id } + Gem::Specification.stubs_for("a").map {|s| s.object_id }, + Gem::Specification.stubs_for("a").map {|s| s.object_id } ) - Gem.loaded_specs.delete 'a' - Gem.loaded_specs.delete 'b' + Gem.loaded_specs.delete "a" + Gem.loaded_specs.delete "b" Gem::Specification.class_variable_set(:@@stubs, nil) end def test_self_stubs_for_no_lazy_loading_after_all_specs_setup - Gem::Specification.all = [util_spec('a', '1')] + Gem::Specification.all = [util_spec("a", "1")] - save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')) {|s| s.name = 'b' } + save_gemspec("b-1", "1", File.join(Gem.dir, "specifications")) {|s| s.name = "b" } - assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name } + assert_equal [], Gem::Specification.stubs_for("b").map {|s| s.full_name } end def test_self_stubs_for_mult_platforms @@ -1025,30 +1025,30 @@ def test_self_stubs_for_mult_platforms orig_platform = Gem.platforms.dup # create user spec - user_spec_dir = File.join Gem.user_dir, 'specifications' + user_spec_dir = File.join Gem.user_dir, "specifications" FileUtils.mkdir_p(user_spec_dir) unless Dir.exist? user_spec_dir # dirs doesn't include user ? Gem::Specification.dirs << user_spec_dir - gem = 'mingw' - v = '1.1.1' - platforms = ['x86-mingw32', 'x64-mingw32'] + gem = "mingw" + v = "1.1.1" + platforms = ["x86-mingw32", "x64-mingw32"] #create specs platforms.each do |plat| spec = Gem::Specification.new(gem, v) {|s| s.platform = plat } - File.open File.join(user_spec_dir, "#{gem}-#{v}-#{plat}.gemspec"), 'w' do |io| + File.open File.join(user_spec_dir, "#{gem}-#{v}-#{plat}.gemspec"), "w" do |io| io.write spec.to_ruby end end platforms.each do |plat| cur_plat = Gem::Platform.new plat - Gem.platforms = ['ruby', cur_plat] + Gem.platforms = ["ruby", cur_plat] Gem::Specification.class_variable_set :@@stubs, nil Gem::Specification.stubs if plat == platforms.last # test loading via stubs - t = Gem::Specification.stubs_for 'mingw' + t = Gem::Specification.stubs_for "mingw" assert_equal 1, t.length assert_equal cur_plat, t.first.platform @@ -1058,17 +1058,17 @@ def test_self_stubs_for_mult_platforms end def test_self_stubs_returns_only_specified_named_specs - dir_standard_specs = File.join Gem.dir, 'specifications' + dir_standard_specs = File.join Gem.dir, "specifications" - save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' } - save_gemspec('a-2', '2', dir_standard_specs) {|s| s.name = 'a' } - save_gemspec('a-a', '3', dir_standard_specs) {|s| s.name = 'a-a' } + save_gemspec("a-1", "1", dir_standard_specs) {|s| s.name = "a" } + save_gemspec("a-2", "2", dir_standard_specs) {|s| s.name = "a" } + save_gemspec("a-a", "3", dir_standard_specs) {|s| s.name = "a-a" } - assert_equal ['a-1', 'a-2'], Gem::Specification.stubs_for('a').map(&:full_name).sort + assert_equal ["a-1", "a-2"], Gem::Specification.stubs_for("a").map(&:full_name).sort end def test_handles_private_null_type - path = File.expand_path 'data/pry-0.4.7.gemspec.rz', __dir__ + path = File.expand_path "data/pry-0.4.7.gemspec.rz", __dir__ data = Marshal.load Gem::Util.inflate(Gem.read_binary(path)) @@ -1076,7 +1076,7 @@ def test_handles_private_null_type end def test_handles_dependencies_with_syck_requirements_bug - path = File.expand_path 'data/excon-0.7.7.gemspec.rz', __dir__ + path = File.expand_path "data/excon-0.7.7.gemspec.rz", __dir__ data = Marshal.load Gem::Util.inflate(Gem.read_binary(path)) @@ -1102,9 +1102,9 @@ def test_initialize assert_equal [], spec.extensions assert_equal [], spec.requirements assert_equal [], spec.dependencies - assert_equal 'bin', spec.bindir - assert_equal '>= 0', spec.required_ruby_version.to_s - assert_equal '>= 0', spec.required_rubygems_version.to_s + assert_equal "bin", spec.bindir + assert_equal ">= 0", spec.required_ruby_version.to_s + assert_equal ">= 0", spec.required_rubygems_version.to_s end def test_initialize_future @@ -1126,18 +1126,18 @@ def test_initialize_copy spec = Gem::Specification.new do |s| s.name = "blah" s.version = "1.3.5" - s.summary = 'summary' - s.description = 'description' - s.authors = 'author a', 'author b' - s.licenses = 'BSD-2-Clause' - s.files = 'lib/file.rb' - s.test_files = 'test/file.rb' - s.rdoc_options = '--foo' - s.extra_rdoc_files = 'README.txt' - s.executables = 'exec' - s.extensions = 'ext/extconf.rb' - s.requirements = 'requirement' - s.add_dependency 'some_gem' + s.summary = "summary" + s.description = "description" + s.authors = "author a", "author b" + s.licenses = "BSD-2-Clause" + s.files = "lib/file.rb" + s.test_files = "test/file.rb" + s.rdoc_options = "--foo" + s.extra_rdoc_files = "README.txt" + s.executables = "exec" + s.extensions = "ext/extconf.rb" + s.requirements = "requirement" + s.add_dependency "some_gem" end dup_spec = spec.dup @@ -1151,69 +1151,69 @@ def test_initialize_copy assert_equal Gem::Platform::RUBY, spec.platform assert_same spec.platform, dup_spec.platform - assert_equal 'summary', spec.summary + assert_equal "summary", spec.summary assert_same spec.summary, dup_spec.summary assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb test/file.rb].sort, spec.files - refute_same spec.files, dup_spec.files, 'files' + refute_same spec.files, dup_spec.files, "files" assert_equal %w[test/file.rb], spec.test_files - refute_same spec.test_files, dup_spec.test_files, 'test_files' + refute_same spec.test_files, dup_spec.test_files, "test_files" assert_equal %w[--foo], spec.rdoc_options - refute_same spec.rdoc_options, dup_spec.rdoc_options, 'rdoc_options' + refute_same spec.rdoc_options, dup_spec.rdoc_options, "rdoc_options" assert_equal %w[README.txt], spec.extra_rdoc_files refute_same spec.extra_rdoc_files, dup_spec.extra_rdoc_files, - 'extra_rdoc_files' + "extra_rdoc_files" assert_equal %w[exec], spec.executables - refute_same spec.executables, dup_spec.executables, 'executables' + refute_same spec.executables, dup_spec.executables, "executables" assert_equal %w[ext/extconf.rb], spec.extensions - refute_same spec.extensions, dup_spec.extensions, 'extensions' + refute_same spec.extensions, dup_spec.extensions, "extensions" assert_equal %w[requirement], spec.requirements - refute_same spec.requirements, dup_spec.requirements, 'requirements' + refute_same spec.requirements, dup_spec.requirements, "requirements" - assert_equal [Gem::Dependency.new('some_gem', Gem::Requirement.default)], + assert_equal [Gem::Dependency.new("some_gem", Gem::Requirement.default)], spec.dependencies - refute_same spec.dependencies, dup_spec.dependencies, 'dependencies' + refute_same spec.dependencies, dup_spec.dependencies, "dependencies" - assert_equal 'bin', spec.bindir + assert_equal "bin", spec.bindir assert_same spec.bindir, dup_spec.bindir - assert_equal '>= 0', spec.required_ruby_version.to_s + assert_equal ">= 0", spec.required_ruby_version.to_s assert_same spec.required_ruby_version, dup_spec.required_ruby_version - assert_equal '>= 0', spec.required_rubygems_version.to_s + assert_equal ">= 0", spec.required_rubygems_version.to_s assert_same spec.required_rubygems_version, dup_spec.required_rubygems_version end def test_initialize_copy_broken spec = Gem::Specification.new do |s| - s.name = 'a' - s.version = '1' + s.name = "a" + s.version = "1" end spec.instance_variable_set :@licenses, (class << (Object.new);self;end) - spec.loaded_from = '/path/to/file' + spec.loaded_from = "/path/to/file" e = assert_raise Gem::FormatException do spec.dup end - assert_equal 'a-1 has an invalid value for @licenses', e.message - assert_equal '/path/to/file', e.file_path + assert_equal "a-1 has an invalid value for @licenses", e.message + assert_equal "/path/to/file", e.file_path end def test_initialize_prerelease_version_before_name spec = Gem::Specification.new do |s| - s.version = '1.0.0.dev' - s.name = 'a' + s.version = "1.0.0.dev" + s.name = "a" end assert_equal "a", spec.name @@ -1222,13 +1222,13 @@ def test_initialize_prerelease_version_before_name def test__dump @a2.platform = Gem::Platform.local - @a2.instance_variable_set :@original_platform, 'old_platform' + @a2.instance_variable_set :@original_platform, "old_platform" data = Marshal.dump @a2 same_spec = Marshal.load data - assert_equal 'old_platform', same_spec.original_platform + assert_equal "old_platform", same_spec.original_platform end def test_activate @@ -1247,7 +1247,7 @@ def test_add_dependency_with_type end def test_add_dependency_from_existing_dependency - dep = Gem::Dependency.new("existing_dep", Gem::Requirement.new('> 1'), :runtime) + dep = Gem::Dependency.new("existing_dep", Gem::Requirement.new("> 1"), :runtime) spec = Gem::Specification.new {|s| s.add_dependency dep } assert_equal dep, spec.dependencies.first end @@ -1262,22 +1262,22 @@ def test_add_dependency_with_type_explicit end def test_author - assert_equal 'A User', @a1.author + assert_equal "A User", @a1.author end def test_authors - assert_equal ['A User'], @a1.authors + assert_equal ["A User"], @a1.authors end def test_bindir_equals - @a1.bindir = 'apps' + @a1.bindir = "apps" - assert_equal 'apps', @a1.bindir + assert_equal "apps", @a1.bindir end def test_bindir_equals_nil @a2.bindir = nil - @a2.executable = 'app' + @a2.executable = "app" assert_nil @a2.bindir assert_equal %w[app lib/code.rb].sort, @a2.files @@ -1313,14 +1313,14 @@ def test_build_args assert_empty @ext.build_args - File.open @ext.build_info_file, 'w' do |io| + File.open @ext.build_info_file, "w" do |io| io.puts end assert_empty @ext.build_args - File.open @ext.build_info_file, 'w' do |io| - io.puts '--with-foo-dir=wherever' + File.open @ext.build_info_file, "w" do |io| + io.puts "--with-foo-dir=wherever" end assert_equal %w[--with-foo-dir=wherever], @ext.build_args @@ -1330,13 +1330,13 @@ def test_build_extensions pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec - assert_path_not_exist @ext.extension_dir, 'sanity check' - refute_empty @ext.extensions, 'sanity check' + assert_path_not_exist @ext.extension_dir, "sanity check" + refute_empty @ext.extensions, "sanity check" extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -1352,13 +1352,13 @@ def test_build_extensions end def test_default_spec_stub_is_marked_default - default = new_default_spec 'default', 2 + default = new_default_spec "default", 2 install_default_gems default - stub = Gem::Specification.stubs.find {|s| s.name == 'default' } + stub = Gem::Specification.stubs.find {|s| s.name == "default" } assert_predicate stub, :default_gem? - stub = Gem::Specification.find_all_by_name('default').first + stub = Gem::Specification.find_all_by_name("default").first assert_predicate stub, :default_gem? end @@ -1366,28 +1366,28 @@ def test_build_extensions_built pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec - refute_empty @ext.extensions, 'sanity check' + refute_empty @ext.extensions, "sanity check" gem_build_complete = - File.join @ext.extension_dir, 'gem.build_complete' + File.join @ext.extension_dir, "gem.build_complete" FileUtils.mkdir_p @ext.extension_dir FileUtils.touch gem_build_complete @ext.build_extensions - gem_make_out = File.join @ext.extension_dir, 'gem_make.out' + gem_make_out = File.join @ext.extension_dir, "gem_make.out" assert_path_not_exist gem_make_out end def test_build_extensions_default_gem - spec = new_default_spec 'default', 1 - spec.extensions << 'extconf.rb' + spec = new_default_spec "default", 1 + spec.extensions << "extconf.rb" extconf_rb = File.join spec.gem_dir, spec.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "default:\n\techo built" @@ -1405,7 +1405,7 @@ def test_build_extensions_error pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec - refute_empty @ext.extensions, 'sanity check' + refute_empty @ext.extensions, "sanity check" assert_raise Gem::Ext::BuildError do @ext.build_extensions @@ -1413,18 +1413,18 @@ def test_build_extensions_error end def test_build_extensions_extensions_dir_unwritable - pend 'chmod not supported' if Gem.win_platform? - pend 'skipped in root privilege' if Process.uid.zero? + pend "chmod not supported" if Gem.win_platform? + pend "skipped in root privilege" if Process.uid.zero? pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec - refute_empty @ext.extensions, 'sanity check' + refute_empty @ext.extensions, "sanity check" extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -1434,30 +1434,30 @@ def test_build_extensions_extensions_dir_unwritable RUBY end - FileUtils.mkdir_p File.join @ext.base_dir, 'extensions' + FileUtils.mkdir_p File.join @ext.base_dir, "extensions" FileUtils.chmod 0555, @ext.base_dir - FileUtils.chmod 0555, File.join(@ext.base_dir, 'extensions') + FileUtils.chmod 0555, File.join(@ext.base_dir, "extensions") @ext.build_extensions assert_path_not_exist @ext.extension_dir ensure unless ($DEBUG or win_platform? or Process.uid.zero? or Gem.java_platform?) - FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions') + FileUtils.chmod 0755, File.join(@ext.base_dir, "extensions") FileUtils.chmod 0755, @ext.base_dir end end def test_build_extensions_no_extensions_dir_unwritable - pend 'chmod not supported' if Gem.win_platform? + pend "chmod not supported" if Gem.win_platform? pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec - refute_empty @ext.extensions, 'sanity check' + refute_empty @ext.extensions, "sanity check" extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -1467,20 +1467,20 @@ def test_build_extensions_no_extensions_dir_unwritable RUBY end - FileUtils.rm_r File.join @gemhome, 'extensions' + FileUtils.rm_r File.join @gemhome, "extensions" FileUtils.chmod 0555, @gemhome @ext.build_extensions - gem_make_out = File.join @ext.extension_dir, 'gem_make.out' + gem_make_out = File.join @ext.extension_dir, "gem_make.out" assert_path_not_exist gem_make_out ensure FileUtils.chmod 0755, @gemhome end def test_build_extensions_none - assert_path_not_exist @a1.extension_dir, 'sanity check' - assert_empty @a1.extensions, 'sanity check' + assert_path_not_exist @a1.extension_dir, "sanity check" + assert_empty @a1.extensions, "sanity check" @a1.build_extensions @@ -1494,7 +1494,7 @@ def test_build_extensions_preview extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -1504,22 +1504,22 @@ def test_build_extensions_preview RUBY end - refute_empty @ext.extensions, 'sanity check' + refute_empty @ext.extensions, "sanity check" - @ext.installed_by_version = v('2.2.0.preview.2') + @ext.installed_by_version = v("2.2.0.preview.2") @ext.build_extensions - gem_make_out = File.join @ext.extension_dir, 'gem_make.out' + gem_make_out = File.join @ext.extension_dir, "gem_make.out" assert_path_exist gem_make_out end def test_contains_requirable_file_eh - code_rb = File.join @a1.gem_dir, 'lib', 'code.rb' + code_rb = File.join @a1.gem_dir, "lib", "code.rb" FileUtils.mkdir_p File.dirname code_rb FileUtils.touch code_rb - assert @a1.contains_requirable_file? 'code' + assert @a1.contains_requirable_file? "code" end def test_contains_requirable_file_eh_extension @@ -1527,7 +1527,7 @@ def test_contains_requirable_file_eh_extension ext_spec _, err = capture_output do - refute @ext.contains_requirable_file? 'nonexistent' + refute @ext.contains_requirable_file? "nonexistent" end expected = "Ignoring ext-1 because its extensions are not built. " + @@ -1540,7 +1540,7 @@ def test_contains_requirable_file_eh_extension_java_platform ext_spec(platform: Gem::Platform.new("java")) _, err = capture_output do - refute @ext.contains_requirable_file? 'nonexistent' + refute @ext.contains_requirable_file? "nonexistent" end assert_empty err @@ -1556,13 +1556,13 @@ def test_date_equals_date end def test_date_equals_string - @a1.date = '2003-09-17' + @a1.date = "2003-09-17" assert_equal Time.utc(2003, 9, 17, 0,0,0), @a1.date end def test_date_equals_string_bad assert_raise Gem::InvalidSpecificationException do - @a1.date = '9/11/2003' + @a1.date = "9/11/2003" end end @@ -1609,7 +1609,7 @@ def test_dependent_gems assert_empty @gem.dependent_gems - bonobo = util_spec 'bonobo', 1 + bonobo = util_spec "bonobo", 1 install_gem bonobo install_gem @gem @@ -1621,11 +1621,11 @@ def test_dependent_gems end def test_doc_dir - assert_equal File.join(@gemhome, 'doc', 'a-1'), @a1.doc_dir + assert_equal File.join(@gemhome, "doc", "a-1"), @a1.doc_dir end def test_doc_dir_type - assert_equal File.join(@gemhome, 'doc', 'a-1', 'ri'), @a1.doc_dir('ri') + assert_equal File.join(@gemhome, "doc", "a-1", "ri"), @a1.doc_dir("ri") end def test_runtime_dependencies @@ -1639,12 +1639,12 @@ def test_development_dependencies end def test_description - assert_equal 'This is a test description', @a1.description + assert_equal "This is a test description", @a1.description end def test_eql_eh - g1 = util_spec 'gem', 1 - g2 = util_spec 'gem', 1 + g1 = util_spec "gem", 1 + g2 = util_spec "gem", 1 assert_equal g1, g2 assert_equal g1.hash, g2.hash @@ -1653,47 +1653,47 @@ def test_eql_eh def test_eql_eh_extensions spec = @a1.dup - spec.extensions = 'xx' + spec.extensions = "xx" refute_operator @a1, :eql?, spec refute_operator spec, :eql?, @a1 end def test_executables - @a1.executable = 'app' + @a1.executable = "app" assert_equal %w[app], @a1.executables end def test_executable_equals - @a2.executable = 'app' - assert_equal 'app', @a2.executable + @a2.executable = "app" + assert_equal "app", @a2.executable assert_equal %w[bin/app lib/code.rb].sort, @a2.files end def test_extensions - assert_equal ['ext/extconf.rb'], ext_spec.extensions + assert_equal ["ext/extconf.rb"], ext_spec.extensions end def test_extension_dir - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'no' + enable_shared, RbConfig::CONFIG["ENABLE_SHARED"] = + RbConfig::CONFIG["ENABLE_SHARED"], "no" ext_spec refute_empty @ext.extensions expected = - File.join(@ext.base_dir, 'extensions', Gem::Platform.local.to_s, + File.join(@ext.base_dir, "extensions", Gem::Platform.local.to_s, "#{Gem.ruby_api_version}-static", @ext.full_name) assert_equal expected, @ext.extension_dir ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + RbConfig::CONFIG["ENABLE_SHARED"] = enable_shared end def test_extension_dir_override - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] = - RbConfig::CONFIG['ENABLE_SHARED'], 'no' + enable_shared, RbConfig::CONFIG["ENABLE_SHARED"] = + RbConfig::CONFIG["ENABLE_SHARED"], "no" class << Gem alias orig_default_ext_dir_for default_ext_dir_for @@ -1701,7 +1701,7 @@ class << Gem remove_method :default_ext_dir_for def Gem.default_ext_dir_for(base_dir) - 'elsewhere' + "elsewhere" end end @@ -1709,11 +1709,11 @@ def Gem.default_ext_dir_for(base_dir) refute_empty @ext.extensions - expected = File.join @tempdir, 'elsewhere', @ext.full_name + expected = File.join @tempdir, "elsewhere", @ext.full_name assert_equal expected, @ext.extension_dir ensure - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared + RbConfig::CONFIG["ENABLE_SHARED"] = enable_shared class << Gem remove_method :default_ext_dir_for @@ -1803,9 +1803,9 @@ def test_files_non_array_pathological end def test_for_cache - @a2.add_runtime_dependency 'b', '1' + @a2.add_runtime_dependency "b", "1" @a2.dependencies.first.instance_variable_set :@type, nil - @a2.required_rubygems_version = Gem::Requirement.new '> 0' + @a2.required_rubygems_version = Gem::Requirement.new "> 0" @a2.test_files = %w[test/test_b.rb] refute_empty @a2.files @@ -1821,11 +1821,11 @@ def test_for_cache end def test_full_gem_path - assert_equal File.join(@gemhome, 'gems', @a1.full_name), @a1.full_gem_path + assert_equal File.join(@gemhome, "gems", @a1.full_name), @a1.full_gem_path - @a1.original_platform = 'mswin32' + @a1.original_platform = "mswin32" - assert_equal File.join(@gemhome, 'gems', @a1.original_name), + assert_equal File.join(@gemhome, "gems", @a1.original_name), @a1.full_gem_path end @@ -1838,40 +1838,40 @@ def test_full_gem_path_double_slash end def test_full_name - assert_equal 'a-1', @a1.full_name + assert_equal "a-1", @a1.full_name @a1 = Gem::Specification.new "a", 1 - @a1.platform = Gem::Platform.new ['universal', 'darwin', nil] - assert_equal 'a-1-universal-darwin', @a1.full_name + @a1.platform = Gem::Platform.new ["universal", "darwin", nil] + assert_equal "a-1-universal-darwin", @a1.full_name @a1 = Gem::Specification.new "a", 1 - @a1.instance_variable_set :@new_platform, 'mswin32' - assert_equal 'a-1-mswin32', @a1.full_name, 'legacy' + @a1.instance_variable_set :@new_platform, "mswin32" + assert_equal "a-1-mswin32", @a1.full_name, "legacy" return if win_platform? @a1 = Gem::Specification.new "a", 1 - @a1.platform = 'current' - assert_equal 'a-1-x86-darwin-8', @a1.full_name + @a1.platform = "current" + assert_equal "a-1-x86-darwin-8", @a1.full_name end def test_full_name_windows test_cases = { - 'i386-mswin32' => 'a-1-x86-mswin32-60', - 'i386-mswin32_80' => 'a-1-x86-mswin32-80', - 'i386-mingw32' => 'a-1-x86-mingw32', + "i386-mswin32" => "a-1-x86-mswin32-60", + "i386-mswin32_80" => "a-1-x86-mswin32-80", + "i386-mingw32" => "a-1-x86-mingw32", } test_cases.each do |arch, expected| @a1 = Gem::Specification.new "a", 1 util_set_arch arch - @a1.platform = 'current' + @a1.platform = "current" assert_equal expected, @a1.full_name end end def test_gem_build_complete_path - expected = File.join @a1.extension_dir, 'gem.build_complete' + expected = File.join @a1.extension_dir, "gem.build_complete" assert_equal expected, @a1.gem_build_complete_path end @@ -1915,23 +1915,23 @@ def test_lib_files end def test_license - assert_equal 'MIT', @a1.license + assert_equal "MIT", @a1.license end def test_licenses - assert_equal ['MIT'], @a1.licenses + assert_equal ["MIT"], @a1.licenses end def test_name - assert_equal 'a', @a1.name + assert_equal "a", @a1.name end def test_original_name - assert_equal 'a-1', @a1.full_name + assert_equal "a-1", @a1.full_name - @a1.platform = 'i386-linux' - @a1.instance_variable_set :@original_platform, 'i386-linux' - assert_equal 'a-1-i386-linux', @a1.original_name + @a1.platform = "i386-linux" + @a1.instance_variable_set :@original_platform, "i386-linux" + assert_equal "a-1-i386-linux", @a1.original_name end def test_platform @@ -1960,10 +1960,10 @@ def test_platform_equals assert_equal Gem::Platform::RUBY, @a1.platform test_cases = { - 'i386-mswin32' => ['x86', 'mswin32', '60'], - 'i386-mswin32_80' => ['x86', 'mswin32', '80'], - 'i386-mingw32' => ['x86', 'mingw32', nil ], - 'x86-darwin8' => ['x86', 'darwin', '8' ], + "i386-mswin32" => ["x86", "mswin32", "60"], + "i386-mswin32_80" => ["x86", "mswin32", "80"], + "i386-mingw32" => ["x86", "mingw32", nil ], + "x86-darwin8" => ["x86", "darwin", "8" ], } test_cases.each do |arch, expected| @@ -1980,29 +1980,29 @@ def test_platform_equals_current end def test_platform_equals_legacy - @a1.platform = 'mswin32' - assert_equal Gem::Platform.new('x86-mswin32'), @a1.platform + @a1.platform = "mswin32" + assert_equal Gem::Platform.new("x86-mswin32"), @a1.platform - @a1.platform = 'i586-linux' - assert_equal Gem::Platform.new('x86-linux'), @a1.platform + @a1.platform = "i586-linux" + assert_equal Gem::Platform.new("x86-linux"), @a1.platform - @a1.platform = 'powerpc-darwin' - assert_equal Gem::Platform.new('ppc-darwin'), @a1.platform + @a1.platform = "powerpc-darwin" + assert_equal Gem::Platform.new("ppc-darwin"), @a1.platform end def test_prerelease_spec_adds_required_rubygems_version - @prerelease = util_spec('tardis', '2.2.0.a') - refute @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.3.1')) - assert @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.4.0')) + @prerelease = util_spec("tardis", "2.2.0.a") + refute @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new("1.3.1")) + assert @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new("1.4.0")) end def test_require_paths - enable_shared 'no' do + enable_shared "no" do ext_spec - @ext.require_paths = 'lib' + @ext.require_paths = "lib" - assert_equal [@ext.extension_dir, 'lib'], @ext.require_paths + assert_equal [@ext.extension_dir, "lib"], @ext.require_paths end end @@ -2014,15 +2014,15 @@ class << Gem end def Gem.default_ext_dir_for(base_dir) - '/foo' + "/foo" end - enable_shared 'no' do + enable_shared "no" do ext_spec - @ext.require_paths = 'lib' + @ext.require_paths = "lib" - assert_equal [File.expand_path('/foo/ext-1'), 'lib'], @ext.require_paths + assert_equal [File.expand_path("/foo/ext-1"), "lib"], @ext.require_paths end ensure class << Gem @@ -2040,7 +2040,7 @@ def test_source_paths ext_spec @ext.require_paths = %w[lib ext foo] - @ext.extensions << 'bar/baz' + @ext.extensions << "bar/baz" expected = %w[ lib @@ -2055,10 +2055,10 @@ def test_source_paths def test_full_require_paths ext_spec - @ext.require_paths = 'lib' + @ext.require_paths = "lib" expected = [ - File.join(@gemhome, 'gems', @ext.original_name, 'lib'), + File.join(@gemhome, "gems", @ext.original_name, "lib"), @ext.extension_dir, ] @@ -2068,10 +2068,10 @@ def test_full_require_paths def test_to_fullpath ext_spec - @ext.require_paths = 'lib' + @ext.require_paths = "lib" - dir = File.join(@gemhome, 'gems', @ext.original_name, 'lib') - expected_rb = File.join(dir, 'code.rb') + dir = File.join(@gemhome, "gems", @ext.original_name, "lib") + expected_rb = File.join(dir, "code.rb") FileUtils.mkdir_p dir FileUtils.touch expected_rb @@ -2105,10 +2105,10 @@ def test_to_fullpath def test_fullpath_return_rb_extension_file_when_exist_the_same_name_file ext_spec - @ext.require_paths = 'lib' + @ext.require_paths = "lib" - dir = File.join(@gemhome, 'gems', @ext.original_name, 'lib') - expected_rb = File.join(dir, 'code.rb') + dir = File.join(@gemhome, "gems", @ext.original_name, "lib") + expected_rb = File.join(dir, "code.rb") FileUtils.mkdir_p dir FileUtils.touch expected_rb @@ -2160,12 +2160,12 @@ def test_require_already_activated_indirect_conflict end def test_requirements - assert_equal ['A working computer'], @a1.requirements + assert_equal ["A working computer"], @a1.requirements end def test_allowed_push_host - assert_nil @a1.metadata['allowed_push_host'] - assert_equal 'https://privategemserver.com', @a3.metadata['allowed_push_host'] + assert_nil @a1.metadata["allowed_push_host"] + assert_equal "https://privategemserver.com", @a3.metadata["allowed_push_host"] end def test_runtime_dependencies_legacy @@ -2181,8 +2181,8 @@ def test_runtime_dependencies_legacy end def test_spaceship_name - s1 = util_spec 'a', '1' - s2 = util_spec 'b', '1' + s1 = util_spec "a", "1" + s2 = util_spec "b", "1" assert_equal(-1, (s1 <=> s2)) assert_equal(0, (s1 <=> s1)) @@ -2190,9 +2190,9 @@ def test_spaceship_name end def test_spaceship_platform - s1 = util_spec 'a', '1' - s2 = util_spec 'a', '1' do |s| - s.platform = Gem::Platform.new 'x86-my_platform1' + s1 = util_spec "a", "1" + s2 = util_spec "a", "1" do |s| + s.platform = Gem::Platform.new "x86-my_platform1" end assert_equal(-1, (s1 <=> s2)) @@ -2201,8 +2201,8 @@ def test_spaceship_platform end def test_spaceship_version - s1 = util_spec 'a', '1' - s2 = util_spec 'a', '2' + s1 = util_spec "a", "1" + s2 = util_spec "a", "2" assert_equal(-1, (s1 <=> s2)) assert_equal(0, (s1 <=> s1)) @@ -2210,25 +2210,25 @@ def test_spaceship_version end def test_spec_file - assert_equal File.join(@gemhome, 'specifications', 'a-1.gemspec'), + assert_equal File.join(@gemhome, "specifications", "a-1.gemspec"), @a1.spec_file end def test_spec_name - assert_equal 'a-1.gemspec', @a1.spec_name + assert_equal "a-1.gemspec", @a1.spec_name end def test_summary - assert_equal 'this is a summary', @a1.summary + assert_equal "this is a summary", @a1.summary end def test_test_files - @a1.test_file = 'test/suite.rb' - assert_equal ['test/suite.rb'], @a1.test_files + @a1.test_file = "test/suite.rb" + assert_equal ["test/suite.rb"], @a1.test_files end def test_runtime_predicate_true - @a2.add_runtime_dependency 'b', '1' + @a2.add_runtime_dependency "b", "1" assert_predicate @a2.dependencies.first, :runtime? @a2.dependencies.first.instance_variable_set :@type, nil @@ -2236,15 +2236,15 @@ def test_runtime_predicate_true end def test_runtime_predicate_false - @a2.add_development_dependency 'b', '1' + @a2.add_development_dependency "b", "1" refute_predicate @a2.dependencies.first, :runtime? end def test_to_ruby - @a2.add_runtime_dependency 'b', '1' + @a2.add_runtime_dependency "b", "1" @a2.dependencies.first.instance_variable_set :@type, nil - @a2.required_rubygems_version = Gem::Requirement.new '> 0' - @a2.require_paths << 'other' + @a2.required_rubygems_version = Gem::Requirement.new "> 0" + @a2.require_paths << "other" ruby_code = @a2.to_ruby @@ -2281,8 +2281,8 @@ def test_to_ruby end def test_to_ruby_with_rsa_key - require 'rubygems/openssl' - pend 'openssl is missing' unless defined?(OpenSSL::PKey::RSA) + require "rubygems/openssl" + pend "openssl is missing" unless defined?(OpenSSL::PKey::RSA) rsa_key = OpenSSL::PKey::RSA.new(2048) @a2.signing_key = rsa_key @@ -2313,9 +2313,9 @@ def test_to_ruby_with_rsa_key end def test_to_ruby_for_cache - @a2.add_runtime_dependency 'b', '1' + @a2.add_runtime_dependency "b", "1" @a2.dependencies.first.instance_variable_set :@type, nil - @a2.required_rubygems_version = Gem::Requirement.new '> 0' + @a2.required_rubygems_version = Gem::Requirement.new "> 0" @a2.installed_by_version = Gem.rubygems_version # cached specs do not have spec.files populated: @@ -2410,8 +2410,8 @@ def test_to_ruby_fancy end def test_to_ruby_keeps_requirements_as_originally_specified - spec = util_spec 'a', '1' do |s| - s.add_dependency 'b', ['~> 1.0', '>= 1.0.0'] + spec = util_spec "a", "1" do |s| + s.add_dependency "b", ["~> 1.0", ">= 1.0.0"] end assert_includes spec.to_ruby, '"~> 1.0", ">= 1.0.0"' @@ -2440,13 +2440,13 @@ def test_to_ruby_nested_hash def test_to_ruby_platform @a2.platform = Gem::Platform.local - @a2.instance_variable_set :@original_platform, 'old_platform' + @a2.instance_variable_set :@original_platform, "old_platform" ruby_code = @a2.to_ruby same_spec = eval ruby_code - assert_equal 'old_platform', same_spec.original_platform + assert_equal "old_platform", same_spec.original_platform end def test_to_yaml @@ -2471,21 +2471,21 @@ def test_to_yaml_fancy end def test_to_yaml_platform_empty_string - @a1.instance_variable_set :@original_platform, '' + @a1.instance_variable_set :@original_platform, "" assert_match %r{^platform: ruby$}, @a1.to_yaml end def test_to_yaml_platform_legacy - @a1.platform = 'powerpc-darwin7.9.0' - @a1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0' + @a1.platform = "powerpc-darwin7.9.0" + @a1.instance_variable_set :@original_platform, "powerpc-darwin7.9.0" yaml_str = @a1.to_yaml same_spec = load_yaml yaml_str - assert_equal Gem::Platform.new('powerpc-darwin7'), same_spec.platform - assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform + assert_equal Gem::Platform.new("powerpc-darwin7"), same_spec.platform + assert_equal "powerpc-darwin7.9.0", same_spec.original_platform end def test_to_yaml_platform_nil @@ -2502,7 +2502,7 @@ def test_validate end end - def x(s); s.gsub(/xxx/, ''); end + def x(s); s.gsub(/xxx/, ""); end def w; x "WARxxxNING"; end def t; x "TOxxxDO"; end def f; x "FxxxIXME"; end @@ -2517,7 +2517,7 @@ def test_validate_authors @a1.validate end - assert_match "#{w}: no author specified\n", @ui.error, 'error' + assert_match "#{w}: no author specified\n", @ui.error, "error" @a1.authors = [Object.new] @@ -2551,14 +2551,14 @@ def test_validate_autorequire util_setup_validate Dir.chdir @tempdir do - @a1.autorequire = 'code' + @a1.autorequire = "code" use_ui @ui do @a1.validate end assert_match "#{w}: deprecated autorequire specified\n", - @ui.error, 'error' + @ui.error, "error" end end @@ -2566,19 +2566,19 @@ def test_validate_dependencies util_setup_validate Dir.chdir @tempdir do - @a1.add_runtime_dependency 'b', '>= 1.0.rc1' - @a1.add_development_dependency 'c', '>= 2.0.rc2' - @a1.add_runtime_dependency 'd', '~> 1.2.3' - @a1.add_runtime_dependency 'e', '~> 1.2.3.4' - @a1.add_runtime_dependency 'g', '~> 1.2.3', '>= 1.2.3.4' - @a1.add_runtime_dependency 'h', '>= 1.2.3', '<= 2' - @a1.add_runtime_dependency 'i', '>= 1.2' - @a1.add_runtime_dependency 'j', '>= 1.2.3' - @a1.add_runtime_dependency 'k', '> 1.2' - @a1.add_runtime_dependency 'l', '> 1.2.3' - @a1.add_runtime_dependency 'm', '~> 2.1.0' - @a1.add_runtime_dependency 'n', '~> 0.1.0' - @a1.add_runtime_dependency 'o' + @a1.add_runtime_dependency "b", ">= 1.0.rc1" + @a1.add_development_dependency "c", ">= 2.0.rc2" + @a1.add_runtime_dependency "d", "~> 1.2.3" + @a1.add_runtime_dependency "e", "~> 1.2.3.4" + @a1.add_runtime_dependency "g", "~> 1.2.3", ">= 1.2.3.4" + @a1.add_runtime_dependency "h", ">= 1.2.3", "<= 2" + @a1.add_runtime_dependency "i", ">= 1.2" + @a1.add_runtime_dependency "j", ">= 1.2.3" + @a1.add_runtime_dependency "k", "> 1.2" + @a1.add_runtime_dependency "l", "> 1.2.3" + @a1.add_runtime_dependency "m", "~> 2.1.0" + @a1.add_runtime_dependency "n", "~> 0.1.0" + @a1.add_runtime_dependency "o" use_ui @ui do @a1.validate @@ -2604,7 +2604,7 @@ def test_validate_dependencies #{w}: See https://guides.rubygems.org/specification-reference/ for help EXPECTED - assert_equal expected, @ui.error, 'warning' + assert_equal expected, @ui.error, "warning" end end @@ -2612,10 +2612,10 @@ def test_validate_dependencies_duplicates util_setup_validate Dir.chdir @tempdir do - @a1.add_runtime_dependency 'b', '~> 1.2' - @a1.add_runtime_dependency 'b', '>= 1.2.3' - @a1.add_development_dependency 'c', '~> 1.2' - @a1.add_development_dependency 'c', '>= 1.2.3' + @a1.add_runtime_dependency "b", "~> 1.2" + @a1.add_runtime_dependency "b", ">= 1.2.3" + @a1.add_development_dependency "c", "~> 1.2" + @a1.add_development_dependency "c", ">= 1.2.3" use_ui @ui do e = assert_raise Gem::InvalidSpecificationException do @@ -2642,14 +2642,14 @@ def test_validate_dependencies_allowed_duplicates util_setup_validate Dir.chdir @tempdir do - @a1.add_runtime_dependency 'b', '~> 1.2' - @a1.add_development_dependency 'b', '= 1.2.3' + @a1.add_runtime_dependency "b", "~> 1.2" + @a1.add_development_dependency "b", "= 1.2.3" use_ui @ui do @a1.validate end - assert_equal '', @ui.error, 'warning' + assert_equal "", @ui.error, "warning" end end @@ -2657,14 +2657,14 @@ def test_validate_prerelease_dependencies_with_prerelease_version util_setup_validate Dir.chdir @tempdir do - @a1.version = '1.0.0.beta.1' - @a1.add_runtime_dependency 'b', '~> 1.2.0.beta.1' + @a1.version = "1.0.0.beta.1" + @a1.add_runtime_dependency "b", "~> 1.2.0.beta.1" use_ui @ui do @a1.validate end - assert_equal '', @ui.error, 'warning' + assert_equal "", @ui.error, "warning" end end @@ -2672,8 +2672,8 @@ def test_validate_rake_extension_have_rake_dependency_warning util_setup_validate Dir.chdir @tempdir do - @a1.extensions = ['Rakefile'] - File.write File.join(@tempdir, 'Rakefile'), '' + @a1.extensions = ["Rakefile"] + File.write File.join(@tempdir, "Rakefile"), "" use_ui @ui do @a1.validate @@ -2687,9 +2687,9 @@ def test_validate_rake_extension_have_rake_dependency_no_warning util_setup_validate Dir.chdir @tempdir do - @a1.extensions = ['Rakefile'] - @a1.add_runtime_dependency 'rake' - File.write File.join(@tempdir, 'Rakefile'), '' + @a1.extensions = ["Rakefile"] + @a1.add_runtime_dependency "rake" + File.write File.join(@tempdir, "Rakefile"), "" use_ui @ui do @a1.validate @@ -2703,7 +2703,7 @@ def test_validate_description util_setup_validate Dir.chdir @tempdir do - @a1.description = '' + @a1.description = "" use_ui @ui do @a1.validate @@ -2793,7 +2793,7 @@ def test_validate_empty Gem::Specification.new.validate end - assert_equal 'missing value for attribute name', e.message + assert_equal "missing value for attribute name", e.message end def test_validate_error @@ -2803,15 +2803,15 @@ def test_validate_error end end - assert_match 'See https://guides.rubygems.org/specification-reference/ for help', @ui.error + assert_match "See https://guides.rubygems.org/specification-reference/ for help", @ui.error end def test_validate_executables util_setup_validate - FileUtils.mkdir_p File.join(@tempdir, 'bin') - File.write File.join(@tempdir, 'bin', 'exec'), '' - FileUtils.mkdir_p File.join(@tempdir, 'exec') + FileUtils.mkdir_p File.join(@tempdir, "bin") + File.write File.join(@tempdir, "bin", "exec"), "" + FileUtils.mkdir_p File.join(@tempdir, "exec") use_ui @ui do Dir.chdir @tempdir do @@ -2821,13 +2821,13 @@ def test_validate_executables assert_equal %w[exec], @a1.executables - assert_equal '', @ui.output, 'output' - assert_match "#{w}: bin/exec is missing #! line\n", @ui.error, 'error' + assert_equal "", @ui.output, "output" + assert_match "#{w}: bin/exec is missing #! line\n", @ui.error, "error" end def test_validate_empty_require_paths if win_platform? - pend 'test_validate_empty_require_paths skipped on MS Windows (symlink)' + pend "test_validate_empty_require_paths skipped on MS Windows (symlink)" else util_setup_validate @@ -2836,26 +2836,26 @@ def test_validate_empty_require_paths @a1.validate end - assert_equal 'specification must have at least one require_path', + assert_equal "specification must have at least one require_path", e.message end end def test_validate_files - pend 'test_validate_files skipped on MS Windows (symlink)' if win_platform? + pend "test_validate_files skipped on MS Windows (symlink)" if win_platform? util_setup_validate - @a1.files += ['lib', 'lib2'] - @a1.extensions << 'ext/a/extconf.rb' + @a1.files += ["lib", "lib2"] + @a1.extensions << "ext/a/extconf.rb" Dir.chdir @tempdir do - FileUtils.ln_s 'lib/code.rb', 'lib2' unless vc_windows? + FileUtils.ln_s "lib/code.rb", "lib2" unless vc_windows? use_ui @ui do @a1.validate end - assert_match 'WARNING: lib2 is a symlink, which is not supported on all platforms', @ui.error + assert_match "WARNING: lib2 is a symlink, which is not supported on all platforms", @ui.error end assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort, @@ -2961,19 +2961,19 @@ def test_validate_homepage @a1.validate end - assert_match "#{w}: no homepage specified\n", @ui.error, 'error' + assert_match "#{w}: no homepage specified\n", @ui.error, "error" @ui = Gem::MockGemUi.new - @a1.homepage = '' + @a1.homepage = "" use_ui @ui do @a1.validate end - assert_match "#{w}: no homepage specified\n", @ui.error, 'error' + assert_match "#{w}: no homepage specified\n", @ui.error, "error" - @a1.homepage = 'over at my cool site' + @a1.homepage = "over at my cool site" e = assert_raise Gem::InvalidSpecificationException do @a1.validate @@ -2981,7 +2981,7 @@ def test_validate_homepage assert_equal '"over at my cool site" is not a valid HTTP URI', e.message - @a1.homepage = 'ftp://rubygems.org' + @a1.homepage = "ftp://rubygems.org" e = assert_raise Gem::InvalidSpecificationException do @a1.validate @@ -2989,10 +2989,10 @@ def test_validate_homepage assert_equal '"ftp://rubygems.org" is not a valid HTTP URI', e.message - @a1.homepage = 'https://rubygems.org/' + @a1.homepage = "https://rubygems.org/" assert_equal true, @a1.validate - @a1.homepage = 'https://rubygems.org' + @a1.homepage = "https://rubygems.org" assert_equal true, @a1.validate end end @@ -3030,7 +3030,7 @@ def test_validate_removed_rubyforge_project util_setup_validate use_ui @ui do - @a1.rubyforge_project = 'invalid-attribute' + @a1.rubyforge_project = "invalid-attribute" @a1.validate end @@ -3041,7 +3041,7 @@ def test_validate_license_values util_setup_validate use_ui @ui do - @a1.licenses = ['BSD'] + @a1.licenses = ["BSD"] @a1.validate end @@ -3055,7 +3055,7 @@ def test_validate_license_ref util_setup_validate use_ui @ui do - @a1.licenses = ['LicenseRef-LICENSE.md'] + @a1.licenses = ["LicenseRef-LICENSE.md"] @a1.validate end @@ -3066,7 +3066,7 @@ def test_validate_license_values_plus util_setup_validate use_ui @ui do - @a1.licenses = ['GPL-2.0+'] + @a1.licenses = ["GPL-2.0+"] @a1.validate end @@ -3077,7 +3077,7 @@ def test_validate_license_values_or_later util_setup_validate use_ui @ui do - @a1.licenses = ['GPL-2.0-or-later'] + @a1.licenses = ["GPL-2.0-or-later"] @a1.validate end @@ -3088,7 +3088,7 @@ def test_validate_license_values_with util_setup_validate use_ui @ui do - @a1.licenses = ['GPL-2.0+ WITH Autoconf-exception-2.0'] + @a1.licenses = ["GPL-2.0+ WITH Autoconf-exception-2.0"] @a1.validate end @@ -3099,7 +3099,7 @@ def test_validate_license_with_nonsense_suffix util_setup_validate use_ui @ui do - @a1.licenses = ['GPL-2.0+ FOO', 'GPL-2.0 FOO'] + @a1.licenses = ["GPL-2.0+ FOO", "GPL-2.0 FOO"] @a1.validate end @@ -3117,7 +3117,7 @@ def test_validate_license_with_invalid_exception util_setup_validate use_ui @ui do - @a1.licenses = ['GPL-2.0+ WITH Autocofn-exception-2.0'] + @a1.licenses = ["GPL-2.0+ WITH Autocofn-exception-2.0"] @a1.validate end @@ -3131,7 +3131,7 @@ def test_validate_license_gives_suggestions util_setup_validate use_ui @ui do - @a1.licenses = ['ruby'] + @a1.licenses = ["ruby"] @a1.validate end @@ -3241,13 +3241,13 @@ def test_validate_non_nil end def test_validate_permissions - pend 'chmod not supported' if Gem.win_platform? + pend "chmod not supported" if Gem.win_platform? util_setup_validate Dir.chdir @tempdir do - File.chmod 0640, File.join('lib', 'code.rb') - File.chmod 0640, File.join('bin', 'exec') + File.chmod 0640, File.join("lib", "code.rb") + File.chmod 0640, File.join("bin", "exec") use_ui @ui do @a1.validate @@ -3260,12 +3260,12 @@ def test_validate_permissions end def test_validate_permissions_of_missing_file_non_packaging - pend 'chmod not supported' if Gem.win_platform? + pend "chmod not supported" if Gem.win_platform? util_setup_validate Dir.chdir @tempdir do - File.delete File.join('lib', 'code.rb') + File.delete File.join("lib", "code.rb") use_ui @ui do assert @a1.validate(false) @@ -3277,13 +3277,13 @@ def test_validate_platform_legacy util_setup_validate Dir.chdir @tempdir do - @a1.platform = 'mswin32' + @a1.platform = "mswin32" assert @a1.validate - @a1.platform = 'i586-linux' + @a1.platform = "i586-linux" assert @a1.validate - @a1.platform = 'powerpc-darwin' + @a1.platform = "powerpc-darwin" assert @a1.validate end end @@ -3304,7 +3304,7 @@ def test_validate_specification_version util_setup_validate Dir.chdir @tempdir do - @a1.specification_version = '1.0' + @a1.specification_version = "1.0" e = assert_raise Gem::InvalidSpecificationException do use_ui @ui do @@ -3312,7 +3312,7 @@ def test_validate_specification_version end end - err = 'specification_version must be an Integer (did you mean version?)' + err = "specification_version must be an Integer (did you mean version?)" assert_equal err, e.message end end @@ -3321,13 +3321,13 @@ def test_validate_summary util_setup_validate Dir.chdir @tempdir do - @a1.summary = '' + @a1.summary = "" use_ui @ui do @a1.validate end - assert_match "#{w}: no summary specified\n", @ui.error, 'error' + assert_match "#{w}: no summary specified\n", @ui.error, "error" @a1.summary = "#{f} (describe your package)" @@ -3355,11 +3355,11 @@ def test_validate_warning @a1.validate end - assert_match 'See https://guides.rubygems.org/specification-reference/ for help', @ui.error + assert_match "See https://guides.rubygems.org/specification-reference/ for help", @ui.error end def test_version - assert_equal Gem::Version.new('1'), @a1.version + assert_equal Gem::Version.new("1"), @a1.version end def test_version_change_reset_full_name @@ -3405,22 +3405,22 @@ def test_load_errors_contain_filename def test_latest_specs spec_fetcher do |fetcher| - fetcher.spec 'a', 1 do |s| - s.platform = Gem::Platform.new 'x86-my_platform1' + fetcher.spec "a", 1 do |s| + s.platform = Gem::Platform.new "x86-my_platform1" end - fetcher.spec 'a', 2 + fetcher.spec "a", 2 - fetcher.spec 'a', 2 do |s| - s.platform = Gem::Platform.new 'x86-my_platform1' + fetcher.spec "a", 2 do |s| + s.platform = Gem::Platform.new "x86-my_platform1" end - fetcher.spec 'a', 2 do |s| - s.platform = Gem::Platform.new 'x86-other_platform1' + fetcher.spec "a", 2 do |s| + s.platform = Gem::Platform.new "x86-other_platform1" end - fetcher.spec 'a', 3 do |s| - s.platform = Gem::Platform.new 'x86-other_platform1' + fetcher.spec "a", 3 do |s| + s.platform = Gem::Platform.new "x86-other_platform1" end end @@ -3437,7 +3437,7 @@ def test_metadata_validates_ok util_setup_validate Dir.chdir @tempdir do - @m1 = quick_gem 'm', '1' do |s| + @m1 = quick_gem "m", "1" do |s| s.files = %w[lib/code.rb] s.metadata = { "one" => "two", @@ -3457,7 +3457,7 @@ def test_metadata_key_type_validation_fails util_setup_validate Dir.chdir @tempdir do - @m2 = quick_gem 'm', '2' do |s| + @m2 = quick_gem "m", "2" do |s| s.files = %w[lib/code.rb] s.metadata = { 1 => "fail" } end @@ -3474,7 +3474,7 @@ def test_metadata_key_size_validation_fails util_setup_validate Dir.chdir @tempdir do - @m2 = quick_gem 'm', '2' do |s| + @m2 = quick_gem "m", "2" do |s| s.files = %w[lib/code.rb] s.metadata = { ("x" * 129) => "fail" } end @@ -3491,9 +3491,9 @@ def test_metadata_value_type_validation_fails util_setup_validate Dir.chdir @tempdir do - @m2 = quick_gem 'm', '2' do |s| + @m2 = quick_gem "m", "2" do |s| s.files = %w[lib/code.rb] - s.metadata = { 'fail' => [] } + s.metadata = { "fail" => [] } end e = assert_raise Gem::InvalidSpecificationException do @@ -3508,9 +3508,9 @@ def test_metadata_value_size_validation_fails util_setup_validate Dir.chdir @tempdir do - @m2 = quick_gem 'm', '2' do |s| + @m2 = quick_gem "m", "2" do |s| s.files = %w[lib/code.rb] - s.metadata = { 'fail' => ("x" * 1025) } + s.metadata = { "fail" => ("x" * 1025) } end e = assert_raise Gem::InvalidSpecificationException do @@ -3525,9 +3525,9 @@ def test_metadata_link_validation_fails util_setup_validate Dir.chdir @tempdir do - @m2 = quick_gem 'm', '2' do |s| + @m2 = quick_gem "m", "2" do |s| s.files = %w[lib/code.rb] - s.metadata = { 'homepage_uri' => 'http:/example.com' } + s.metadata = { "homepage_uri" => "http:/example.com" } end e = assert_raise Gem::InvalidSpecificationException do @@ -3539,9 +3539,9 @@ def test_metadata_link_validation_fails end def test_metadata_specs - @m1 = quick_gem 'm', '1' do |s| + @m1 = quick_gem "m", "1" do |s| s.files = %w[lib/code.rb] - s.metadata = { 'one' => "two", 'two' => "three" } + s.metadata = { "one" => "two", "two" => "three" } end valid_ruby_spec = <<-EOF @@ -3578,7 +3578,7 @@ def test_missing_extensions_eh extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -3594,8 +3594,8 @@ def test_missing_extensions_eh end def test_missing_extensions_eh_default_gem - spec = new_default_spec 'default', 1 - spec.extensions << 'extconf.rb' + spec = new_default_spec "default", 1 + spec.extensions << "extconf.rb" refute spec.missing_extensions? end @@ -3605,7 +3605,7 @@ def test_missing_extensions_eh_none end def test_find_all_by_full_name - pl = Gem::Platform.new 'i386-linux' + pl = Gem::Platform.new "i386-linux" a1 = util_spec "a", "1" a1_pre = util_spec "a", "1.0.0.pre.1" @@ -3672,9 +3672,9 @@ def test_find_by_path install_specs a - assert_equal a, Gem::Specification.find_by_path('foo') + assert_equal a, Gem::Specification.find_by_path("foo") a.activate - assert_equal a, Gem::Specification.find_by_path('foo') + assert_equal a, Gem::Specification.find_by_path("foo") end def test_find_inactive_by_path @@ -3682,9 +3682,9 @@ def test_find_inactive_by_path install_specs a - assert_equal a, Gem::Specification.find_inactive_by_path('foo') + assert_equal a, Gem::Specification.find_inactive_by_path("foo") a.activate - assert_nil Gem::Specification.find_inactive_by_path('foo') + assert_nil Gem::Specification.find_inactive_by_path("foo") end def test_load_default_gem diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb index 04de6dd36aa4..3dbc346271cc 100644 --- a/test/rubygems/test_gem_stream_ui.rb +++ b/test/rubygems/test_gem_stream_ui.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/user_interaction' -require 'timeout' +require_relative "helper" +require "rubygems/user_interaction" +require "timeout" class TestGemStreamUI < Gem::TestCase # increase timeout with MJIT for --jit-wait testing @@ -100,14 +100,14 @@ def test_choose_from_list @in.puts "1" @in.rewind - result = @sui.choose_from_list 'which one?', %w[foo bar] + result = @sui.choose_from_list "which one?", %w[foo bar] - assert_equal ['foo', 0], result + assert_equal ["foo", 0], result assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string end def test_choose_from_list_EOF - result = @sui.choose_from_list 'which one?', %w[foo bar] + result = @sui.choose_from_list "which one?", %w[foo bar] assert_equal [nil, nil], result assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string @@ -115,27 +115,27 @@ def test_choose_from_list_EOF def test_progress_reporter_silent_nil @cfg.verbose = nil - reporter = @sui.progress_reporter 10, 'hi' + reporter = @sui.progress_reporter 10, "hi" assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter end def test_progress_reporter_silent_false @cfg.verbose = false - reporter = @sui.progress_reporter 10, 'hi' + reporter = @sui.progress_reporter 10, "hi" assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter assert_equal "", @out.string end def test_progress_reporter_simple @cfg.verbose = true - reporter = @sui.progress_reporter 10, 'hi' + reporter = @sui.progress_reporter 10, "hi" assert_kind_of Gem::StreamUI::SimpleProgressReporter, reporter assert_equal "hi\n", @out.string end def test_progress_reporter_verbose @cfg.verbose = 0 - reporter = @sui.progress_reporter 10, 'hi' + reporter = @sui.progress_reporter 10, "hi" assert_kind_of Gem::StreamUI::VerboseProgressReporter, reporter assert_equal "hi\n", @out.string end @@ -143,7 +143,7 @@ def test_progress_reporter_verbose def test_download_reporter_silent_nil @cfg.verbose = nil reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter assert_equal "", @out.string end @@ -151,7 +151,7 @@ def test_download_reporter_silent_nil def test_download_reporter_silent_false @cfg.verbose = false reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter assert_equal "", @out.string end @@ -165,14 +165,14 @@ def test_download_reporter_anything def test_threaded_download_reporter @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 assert_equal "Fetching a.gem\n", @out.string end def test_verbose_download_reporter_progress @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 reporter.update 512 assert_equal "Fetching a.gem\n", @out.string end @@ -180,7 +180,7 @@ def test_verbose_download_reporter_progress def test_verbose_download_reporter_progress_once @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 reporter.update 510 reporter.update 512 assert_equal "Fetching a.gem\n", @out.string @@ -189,7 +189,7 @@ def test_verbose_download_reporter_progress_once def test_verbose_download_reporter_progress_complete @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 reporter.update 510 reporter.done assert_equal "Fetching a.gem\n", @out.string @@ -198,7 +198,7 @@ def test_verbose_download_reporter_progress_complete def test_verbose_download_reporter_progress_nil_length @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', nil + reporter.fetch "a.gem", nil reporter.update 1024 reporter.done assert_equal "Fetching a.gem\n", @out.string @@ -207,7 +207,7 @@ def test_verbose_download_reporter_progress_nil_length def test_verbose_download_reporter_progress_zero_length @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', 0 + reporter.fetch "a.gem", 0 reporter.update 1024 reporter.done assert_equal "Fetching a.gem\n", @out.string @@ -218,7 +218,7 @@ def test_verbose_download_reporter_no_tty @cfg.verbose = true reporter = @sui.download_reporter - reporter.fetch 'a.gem', 1024 + reporter.fetch "a.gem", 1024 assert_equal "", @out.string end end diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb index e01d5cad8c1f..22a0b6bb6f5e 100644 --- a/test/rubygems/test_gem_stub_specification.rb +++ b/test/rubygems/test_gem_stub_specification.rb @@ -10,7 +10,7 @@ def setup super @base_dir = __dir__ - @gems_dir = File.join __dir__, 'gem' + @gems_dir = File.join __dir__, "gem" @foo = Gem::StubSpecification.gemspec_stub FOO, @base_dir, @gems_dir end @@ -25,24 +25,24 @@ def test_initialize def test_initialize_extension stub = stub_with_extension - assert_equal 'stub_e', stub.name + assert_equal "stub_e", stub.name assert_equal v(2), stub.version assert_equal Gem::Platform::RUBY, stub.platform - assert_equal [stub.extension_dir, 'lib'], stub.require_paths + assert_equal [stub.extension_dir, "lib"], stub.require_paths assert_equal %w[ext/stub_e/extconf.rb], stub.extensions end def test_initialize_version stub = stub_with_version - assert_equal 'stub_v', stub.name + assert_equal "stub_v", stub.name assert_equal v(2), stub.version end def test_initialize_with_empty_version stub = stub_without_version - assert_equal 'stub_v', stub.name + assert_equal "stub_v", stub.name assert_equal v(0), stub.version end @@ -57,18 +57,18 @@ def test_initialize_missing_stubline def test_contains_requirable_file_eh stub = stub_without_extension - code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + code_rb = File.join stub.gem_dir, "lib", "code.rb" FileUtils.mkdir_p File.dirname code_rb FileUtils.touch code_rb - assert stub.contains_requirable_file? 'code' + assert stub.contains_requirable_file? "code" end def test_contains_requirable_file_eh_extension pend "I guess making the stub match the running platform should work" if Gem.java_platform? stub_with_extension do |stub| _, err = capture_output do - refute stub.contains_requirable_file? 'nonexistent' + refute stub.contains_requirable_file? "nonexistent" end expected = "Ignoring stub_e-2 because its extensions are not built. " + @@ -82,7 +82,7 @@ def test_full_require_paths stub = stub_with_extension expected = [ - File.join(stub.full_gem_path, 'lib'), + File.join(stub.full_gem_path, "lib"), stub.extension_dir, ] @@ -92,32 +92,32 @@ def test_full_require_paths def test_lib_dirs_glob stub = stub_without_extension - assert_equal File.join(stub.full_gem_path, 'lib'), stub.lib_dirs_glob + assert_equal File.join(stub.full_gem_path, "lib"), stub.lib_dirs_glob end def test_lib_dirs_glob_with_extension stub = stub_with_extension - assert_equal File.join(stub.full_gem_path, 'lib'), stub.lib_dirs_glob + assert_equal File.join(stub.full_gem_path, "lib"), stub.lib_dirs_glob end def test_matches_for_glob stub = stub_without_extension - code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + code_rb = File.join stub.gem_dir, "lib", "code.rb" FileUtils.mkdir_p File.dirname code_rb FileUtils.touch code_rb - assert_equal code_rb, stub.matches_for_glob('code*').first + assert_equal code_rb, stub.matches_for_glob("code*").first end def test_matches_for_glob_with_bundler_inline stub = stub_with_extension - code_rb = File.join stub.gem_dir, 'lib', 'code.rb' + code_rb = File.join stub.gem_dir, "lib", "code.rb" FileUtils.mkdir_p File.dirname code_rb FileUtils.touch code_rb stub.stub(:raw_require_paths, nil) do - assert_equal code_rb, stub.matches_for_glob('code*').first + assert_equal code_rb, stub.matches_for_glob("code*").first end end @@ -127,7 +127,7 @@ def test_missing_extensions_eh extconf_rb = File.join s.gem_dir, s.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - File.open extconf_rb, 'w' do |f| + File.open extconf_rb, "w" do |f| f.write <<-'RUBY' File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" @@ -146,10 +146,10 @@ def test_missing_extensions_eh end def test_missing_extensions_eh_default_gem - spec = new_default_spec 'default', 1 - spec.extensions << 'extconf.rb' + spec = new_default_spec "default", 1 + spec.extensions << "extconf.rb" - File.open spec.loaded_from, 'w' do |io| + File.open spec.loaded_from, "w" do |io| io.write spec.to_ruby_for_cache end @@ -167,7 +167,7 @@ def test_to_spec real_foo.activate assert_equal @foo.version, Gem.loaded_specs[@foo.name].version, - 'sanity check' + "sanity check" assert_same real_foo, @foo.to_spec end @@ -181,8 +181,8 @@ def test_to_spec_with_other_specs_loaded_does_not_warn end def stub_with_version - spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub_v 2 ruby lib @@ -195,7 +195,7 @@ def stub_with_version io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? @@ -204,8 +204,8 @@ def stub_with_version end def stub_without_version - spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub_v ruby lib @@ -218,7 +218,7 @@ def stub_without_version io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? @@ -227,8 +227,8 @@ def stub_without_version end def stub_with_extension - spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub_e 2 ruby lib @@ -244,7 +244,7 @@ def stub_with_extension io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? @@ -253,8 +253,8 @@ def stub_with_extension end def stub_without_extension - spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' - File.open spec, 'w' do |io| + spec = File.join @gemhome, "specifications", "stub-2.gemspec" + File.open spec, "w" do |io| io.write <<-STUB # -*- encoding: utf-8 -*- # stub: stub 2 ruby lib @@ -267,7 +267,7 @@ def stub_without_extension io.flush - stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, "gems") yield stub if block_given? diff --git a/test/rubygems/test_gem_text.rb b/test/rubygems/test_gem_text.rb index f170fbf399be..95cae1287cd5 100644 --- a/test/rubygems/test_gem_text.rb +++ b/test/rubygems/test_gem_text.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" require "rubygems/text" class TestGemText < Gem::TestCase diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 9e18972864d1..e81a9be0fff3 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'installer_test_case' -require 'rubygems/uninstaller' +require_relative "installer_test_case" +require "rubygems/uninstaller" class TestGemUninstaller < Gem::InstallerTestCase def setup @@ -23,14 +23,14 @@ def setup end def test_initialize_expand_path - FileUtils.mkdir_p 'foo/bar' - uninstaller = Gem::Uninstaller.new nil, :install_dir => 'foo//bar' + FileUtils.mkdir_p "foo/bar" + uninstaller = Gem::Uninstaller.new nil, :install_dir => "foo//bar" assert_match %r{foo/bar$}, uninstaller.instance_variable_get(:@gem_home) end def test_ask_if_ok - c = util_spec 'c' + c = util_spec "c" uninstaller = Gem::Uninstaller.new nil @@ -60,8 +60,8 @@ def test_remove_all def test_remove_executables_force_keep uninstaller = Gem::Uninstaller.new nil, :executables => false - executable = File.join Gem.bindir(@user_spec.base_dir), 'executable' - assert File.exist?(executable), 'executable not written' + executable = File.join Gem.bindir(@user_spec.base_dir), "executable" + assert File.exist?(executable), "executable not written" use_ui @ui do uninstaller.remove_executables @user_spec @@ -75,8 +75,8 @@ def test_remove_executables_force_keep def test_remove_executables_force_remove uninstaller = Gem::Uninstaller.new nil, :executables => true - executable = File.join Gem.bindir(@user_spec.base_dir), 'executable' - assert File.exist?(executable), 'executable not written' + executable = File.join Gem.bindir(@user_spec.base_dir), "executable" + assert File.exist?(executable), "executable not written" use_ui @ui do uninstaller.remove_executables @user_spec @@ -94,14 +94,14 @@ def test_remove_executables_user uninstaller.remove_executables @user_spec end - exec_path = File.join Gem.user_dir, 'bin', 'executable' - refute File.exist?(exec_path), 'exec still exists in user bin dir' + exec_path = File.join Gem.user_dir, "bin", "executable" + refute File.exist?(exec_path), "exec still exists in user bin dir" assert_equal "Removing executable\n", @ui.output end def test_remove_executables_user_format - Gem::Installer.exec_format = 'foo-%s-bar' + Gem::Installer.exec_format = "foo-%s-bar" uninstaller = Gem::Uninstaller.new nil, :executables => true, :format_executable => true @@ -109,8 +109,8 @@ def test_remove_executables_user_format uninstaller.remove_executables @user_spec end - exec_path = File.join Gem.user_dir, 'bin', 'foo-executable-bar' - assert_equal false, File.exist?(exec_path), 'removed exec from bin dir' + exec_path = File.join Gem.user_dir, "bin", "foo-executable-bar" + assert_equal false, File.exist?(exec_path), "removed exec from bin dir" assert_equal "Removing foo-executable-bar\n", @ui.output ensure @@ -118,7 +118,7 @@ def test_remove_executables_user_format end def test_remove_executables_user_format_disabled - Gem::Installer.exec_format = 'foo-%s-bar' + Gem::Installer.exec_format = "foo-%s-bar" uninstaller = Gem::Uninstaller.new nil, :executables => true @@ -126,8 +126,8 @@ def test_remove_executables_user_format_disabled uninstaller.remove_executables @user_spec end - exec_path = File.join Gem.user_dir, 'bin', 'executable' - refute File.exist?(exec_path), 'removed exec from bin dir' + exec_path = File.join Gem.user_dir, "bin", "executable" + refute File.exist?(exec_path), "removed exec from bin dir" assert_equal "Removing executable\n", @ui.output ensure @@ -171,7 +171,7 @@ def test_remove_symlinked_gem_home end def test_remove_plugins - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -179,16 +179,16 @@ def test_remove_plugins Gem::Installer.at(Gem::Package.build(@spec), :force => true).install - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' - assert File.exist?(plugin_path), 'plugin not written' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" + assert File.exist?(plugin_path), "plugin not written" Gem::Uninstaller.new(nil).remove_plugins @spec - refute File.exist?(plugin_path), 'plugin not removed' + refute File.exist?(plugin_path), "plugin not removed" end def test_remove_plugins_with_install_dir - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -196,17 +196,17 @@ def test_remove_plugins_with_install_dir Gem::Installer.at(Gem::Package.build(@spec), :force => true).install - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' - assert File.exist?(plugin_path), 'plugin not written' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" + assert File.exist?(plugin_path), "plugin not written" Dir.mkdir "#{@gemhome}2" Gem::Uninstaller.new(nil, :install_dir => "#{@gemhome}2").remove_plugins @spec - assert File.exist?(plugin_path), 'plugin unintentionally removed' + assert File.exist?(plugin_path), "plugin unintentionally removed" end def test_regenerate_plugins_for - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end @@ -214,13 +214,13 @@ def test_regenerate_plugins_for Gem::Installer.at(Gem::Package.build(@spec), :force => true).install - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' - assert File.exist?(plugin_path), 'plugin not written' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" + assert File.exist?(plugin_path), "plugin not written" FileUtils.rm plugin_path Gem::Uninstaller.new(nil).regenerate_plugins_for @spec, Gem.plugindir - assert File.exist?(plugin_path), 'plugin not regenerated' + assert File.exist?(plugin_path), "plugin not regenerated" end def test_path_ok_eh @@ -234,7 +234,7 @@ def test_path_ok_eh_legacy @spec.loaded_from = @spec.loaded_from.gsub @spec.full_name, '\&-legacy' @spec.internal_init # blow out cache. but why did ^^ depend on cache? - @spec.platform = 'legacy' + @spec.platform = "legacy" assert_equal true, uninstaller.path_ok?(@gemhome, @spec) end @@ -248,16 +248,16 @@ def test_path_ok_eh_user def test_uninstall uninstaller = Gem::Uninstaller.new @spec.name, :executables => true - gem_dir = File.join @gemhome, 'gems', @spec.full_name + gem_dir = File.join @gemhome, "gems", @spec.full_name Gem.pre_uninstall do sleep(0.1) if win_platform? - assert File.exist?(gem_dir), 'gem_dir should exist' + assert File.exist?(gem_dir), "gem_dir should exist" end Gem.post_uninstall do sleep(0.1) if win_platform? - refute File.exist?(gem_dir), 'gem_dir should not exist' + refute File.exist?(gem_dir), "gem_dir should not exist" end uninstaller.uninstall @@ -269,7 +269,7 @@ def test_uninstall end def test_uninstall_default_gem - spec = new_default_spec 'default', '2' + spec = new_default_spec "default", "2" install_default_gems spec @@ -281,14 +281,14 @@ def test_uninstall_default_gem lines = @ui.output.split("\n") - assert_equal 'Gem default-2 cannot be uninstalled because it is a default gem', lines.shift + assert_equal "Gem default-2 cannot be uninstalled because it is a default gem", lines.shift end def test_uninstall_default_gem_with_same_version - default_spec = new_default_spec 'default', '2' + default_spec = new_default_spec "default", "2" install_default_gems default_spec - spec = util_spec 'default', '2' + spec = util_spec "default", "2" install_gem spec Gem::Specification.reset @@ -308,8 +308,8 @@ def test_uninstall_default_gem_with_same_version end def test_uninstall_extension - @spec.extensions << 'extconf.rb' - write_file File.join(@tempdir, 'extconf.rb') do |io| + @spec.extensions << "extconf.rb" + write_file File.join(@tempdir, "extconf.rb") do |io| io.write <<-RUBY require 'mkmf' create_makefile '#{@spec.name}' @@ -325,7 +325,7 @@ def test_uninstall_extension installer.install end - assert_path_exist @spec.extension_dir, 'sanity check' + assert_path_exist @spec.extension_dir, "sanity check" uninstaller = Gem::Uninstaller.new @spec.name, :executables => true uninstaller.uninstall @@ -334,7 +334,7 @@ def test_uninstall_extension end def test_uninstall_nonexistent - uninstaller = Gem::Uninstaller.new 'bogus', :executables => true + uninstaller = Gem::Uninstaller.new "bogus", :executables => true e = assert_raise Gem::InstallError do uninstaller.uninstall @@ -344,17 +344,17 @@ def test_uninstall_nonexistent end def test_uninstall_not_ok - quick_gem 'z' do |s| + quick_gem "z" do |s| s.add_runtime_dependency @spec.name end uninstaller = Gem::Uninstaller.new @spec.name - gem_dir = File.join @gemhome, 'gems', @spec.full_name - executable = File.join @gemhome, 'bin', 'executable' + gem_dir = File.join @gemhome, "gems", @spec.full_name + executable = File.join @gemhome, "bin", "executable" - assert File.exist?(gem_dir), 'gem_dir must exist' - assert File.exist?(executable), 'executable must exist' + assert File.exist?(gem_dir), "gem_dir must exist" + assert File.exist?(executable), "executable must exist" ui = Gem::MockGemUi.new "n\n" @@ -364,12 +364,12 @@ def test_uninstall_not_ok end end - assert File.exist?(gem_dir), 'gem_dir must still exist' - assert File.exist?(executable), 'executable must still exist' + assert File.exist?(gem_dir), "gem_dir must still exist" + assert File.exist?(executable), "executable must still exist" end def test_uninstall_user_install - @user_spec = Gem::Specification.find_by_name 'b' + @user_spec = Gem::Specification.find_by_name "b" uninstaller = Gem::Uninstaller.new(@user_spec.name, :executables => true, @@ -414,9 +414,9 @@ def test_uninstall_wrong_repo def test_uninstall_selection util_make_gems - list = Gem::Specification.find_all_by_name 'a' + list = Gem::Specification.find_all_by_name "a" - uninstaller = Gem::Uninstaller.new 'a' + uninstaller = Gem::Uninstaller.new "a" ui = Gem::MockGemUi.new "1\ny\n" @@ -424,39 +424,39 @@ def test_uninstall_selection uninstaller.uninstall end - updated_list = Gem::Specification.find_all_by_name('a') + updated_list = Gem::Specification.find_all_by_name("a") assert_equal list.length - 1, updated_list.length - assert_match ' 1. a-1', ui.output - assert_match ' 2. a-2', ui.output - assert_match ' 3. a-3.a', ui.output - assert_match ' 4. All versions', ui.output - assert_match 'uninstalled a-1', ui.output + assert_match " 1. a-1", ui.output + assert_match " 2. a-2", ui.output + assert_match " 3. a-3.a", ui.output + assert_match " 4. All versions", ui.output + assert_match "uninstalled a-1", ui.output end def test_uninstall_selection_greater_than_one util_make_gems - list = Gem::Specification.find_all_by_name('a') + list = Gem::Specification.find_all_by_name("a") - uninstaller = Gem::Uninstaller.new('a') + uninstaller = Gem::Uninstaller.new("a") use_ui Gem::MockGemUi.new("2\ny\n") do uninstaller.uninstall end - updated_list = Gem::Specification.find_all_by_name('a') + updated_list = Gem::Specification.find_all_by_name("a") assert_equal list.length - 1, updated_list.length end def test_uninstall_prompts_about_broken_deps - quick_gem 'r', '1' do |s| - s.add_dependency 'q', '= 1' + quick_gem "r", "1" do |s| + s.add_dependency "q", "= 1" end - quick_gem 'q', '1' + quick_gem "q", "1" - un = Gem::Uninstaller.new('q') + un = Gem::Uninstaller.new("q") ui = Gem::MockGemUi.new("y\n") use_ui ui do @@ -475,18 +475,18 @@ def test_uninstall_prompts_about_broken_deps end def test_uninstall_only_lists_unsatisfied_deps - quick_gem 'r', '1' do |s| - s.add_dependency 'q', '~> 1.0' + quick_gem "r", "1" do |s| + s.add_dependency "q", "~> 1.0" end - quick_gem 'x', '1' do |s| - s.add_dependency 'q', '= 1.0' + quick_gem "x", "1" do |s| + s.add_dependency "q", "= 1.0" end - quick_gem 'q', '1.0' - quick_gem 'q', '1.1' + quick_gem "q", "1.0" + quick_gem "q", "1.1" - un = Gem::Uninstaller.new('q', :version => "1.0") + un = Gem::Uninstaller.new("q", :version => "1.0") ui = Gem::MockGemUi.new("y\n") use_ui ui do @@ -505,14 +505,14 @@ def test_uninstall_only_lists_unsatisfied_deps end def test_uninstall_doesnt_prompt_when_other_gem_satisfies_requirement - quick_gem 'r', '1' do |s| - s.add_dependency 'q', '~> 1.0' + quick_gem "r", "1" do |s| + s.add_dependency "q", "~> 1.0" end - quick_gem 'q', '1.0' - quick_gem 'q', '1.1' + quick_gem "q", "1.0" + quick_gem "q", "1.1" - un = Gem::Uninstaller.new('q', :version => "1.0") + un = Gem::Uninstaller.new("q", :version => "1.0") ui = Gem::MockGemUi.new("y\n") use_ui ui do @@ -525,13 +525,13 @@ def test_uninstall_doesnt_prompt_when_other_gem_satisfies_requirement end def test_uninstall_doesnt_prompt_when_removing_a_dev_dep - quick_gem 'r', '1' do |s| - s.add_development_dependency 'q', '= 1.0' + quick_gem "r", "1" do |s| + s.add_development_dependency "q", "= 1.0" end - quick_gem 'q', '1.0' + quick_gem "q", "1.0" - un = Gem::Uninstaller.new('q', :version => "1.0") + un = Gem::Uninstaller.new("q", :version => "1.0") ui = Gem::MockGemUi.new("y\n") use_ui ui do @@ -544,13 +544,13 @@ def test_uninstall_doesnt_prompt_when_removing_a_dev_dep end def test_uninstall_doesnt_prompt_and_raises_when_abort_on_dependent_set - quick_gem 'r', '1' do |s| - s.add_dependency 'q', '= 1' + quick_gem "r", "1" do |s| + s.add_dependency "q", "= 1" end - quick_gem 'q', '1' + quick_gem "q", "1" - un = Gem::Uninstaller.new('q', :abort_on_dependent => true) + un = Gem::Uninstaller.new("q", :abort_on_dependent => true) ui = Gem::MockGemUi.new("y\n") assert_raise Gem::DependencyRemovalException do @@ -561,13 +561,13 @@ def test_uninstall_doesnt_prompt_and_raises_when_abort_on_dependent_set end def test_uninstall_prompt_includes_dep_type - quick_gem 'r', '1' do |s| - s.add_development_dependency 'q', '= 1' + quick_gem "r", "1" do |s| + s.add_development_dependency "q", "= 1" end - quick_gem 'q', '1' + quick_gem "q", "1" - un = Gem::Uninstaller.new('q', :check_dev => true) + un = Gem::Uninstaller.new("q", :check_dev => true) ui = Gem::MockGemUi.new("y\n") use_ui ui do @@ -586,17 +586,17 @@ def test_uninstall_prompt_includes_dep_type end def test_uninstall_prompt_only_lists_the_dependents_that_prevented_uninstallation - quick_gem 'r', '1' do |s| - s.add_development_dependency 'q', '= 1' + quick_gem "r", "1" do |s| + s.add_development_dependency "q", "= 1" end - quick_gem 's', '1' do |s| - s.add_dependency 'q', '= 1' + quick_gem "s", "1" do |s| + s.add_dependency "q", "= 1" end - quick_gem 'q', '1' + quick_gem "q", "1" - un = Gem::Uninstaller.new('q', :check_dev => false) + un = Gem::Uninstaller.new("q", :check_dev => false) ui = Gem::MockGemUi.new("y\n") use_ui ui do @@ -633,42 +633,42 @@ def test_uninstall_no_permission end def test_uninstall_keeps_plugins_up_to_date - write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| + write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io| io.write "puts __FILE__" end - plugin_path = File.join Gem.plugindir, 'a_plugin.rb' + plugin_path = File.join Gem.plugindir, "a_plugin.rb" - @spec.version = '1' + @spec.version = "1" Gem::Installer.at(Gem::Package.build(@spec), :force => true).install - refute File.exist?(plugin_path), 'version without plugin installed, but plugin written' + refute File.exist?(plugin_path), "version without plugin installed, but plugin written" @spec.files += %w[lib/rubygems_plugin.rb] - @spec.version = '2' + @spec.version = "2" Gem::Installer.at(Gem::Package.build(@spec), :force => true).install - assert File.exist?(plugin_path), 'version with plugin installed, but plugin not written' - assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'written plugin has incorrect content' + assert File.exist?(plugin_path), "version with plugin installed, but plugin not written" + assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content" - @spec.version = '3' + @spec.version = "3" Gem::Installer.at(Gem::Package.build(@spec), :force => true).install - assert File.exist?(plugin_path), 'version with plugin installed, but plugin removed' - assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'old version installed, but plugin updated' + assert File.exist?(plugin_path), "version with plugin installed, but plugin removed" + assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), "old version installed, but plugin updated" - Gem::Uninstaller.new('a', :version => '1', :executables => true).uninstall + Gem::Uninstaller.new("a", :version => "1", :executables => true).uninstall - assert File.exist?(plugin_path), 'plugin removed when old version uninstalled' - assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'old version uninstalled, but plugin updated' + assert File.exist?(plugin_path), "plugin removed when old version uninstalled" + assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), "old version uninstalled, but plugin updated" - Gem::Uninstaller.new('a', version: '3', :executables => true).uninstall + Gem::Uninstaller.new("a", version: "3", :executables => true).uninstall - assert File.exist?(plugin_path), 'plugin removed when old version uninstalled and another version with plugin still present' - assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), 'latest version uninstalled, but plugin not updated to previous version' + assert File.exist?(plugin_path), "plugin removed when old version uninstalled and another version with plugin still present" + assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), "latest version uninstalled, but plugin not updated to previous version" - Gem::Uninstaller.new('a', version: '2', :executables => true).uninstall + Gem::Uninstaller.new("a", version: "2", :executables => true).uninstall - refute File.exist?(plugin_path), 'last version uninstalled, but plugin still present' + refute File.exist?(plugin_path), "last version uninstalled, but plugin still present" end end diff --git a/test/rubygems/test_gem_unsatisfiable_dependency_error.rb b/test/rubygems/test_gem_unsatisfiable_dependency_error.rb index f9d30123f05e..3ce98b3cdfce 100644 --- a/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +++ b/test/rubygems/test_gem_unsatisfiable_dependency_error.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestGemUnsatisfiableDependencyError < Gem::TestCase def setup super - @a_dep = dep 'a', '~> 1' + @a_dep = dep "a", "~> 1" @req = Gem::Resolver::DependencyRequest.new @a_dep, nil @@ -21,7 +21,7 @@ def test_errors end def test_name - assert_equal 'a', @e.name + assert_equal "a", @e.name end def test_version diff --git a/test/rubygems/test_gem_uri.rb b/test/rubygems/test_gem_uri.rb index 7fe572518b6b..bcd7b3b2f0f8 100644 --- a/test/rubygems/test_gem_uri.rb +++ b/test/rubygems/test_gem_uri.rb @@ -1,5 +1,5 @@ -require_relative 'helper' -require 'rubygems/uri' +require_relative "helper" +require "rubygems/uri" class TestUri < Gem::TestCase def test_to_s_not_string @@ -31,9 +31,9 @@ def test_redacted_with_invalid_uri end def test_redacted_does_not_modify_uri - url = 'https://user:password@example.com' + url = "https://user:password@example.com" uri = Gem::Uri.new(url) - assert_equal 'https://user:REDACTED@example.com', uri.redacted.to_s + assert_equal "https://user:REDACTED@example.com", uri.redacted.to_s assert_equal url, uri.to_s end end diff --git a/test/rubygems/test_gem_uri_formatter.rb b/test/rubygems/test_gem_uri_formatter.rb index a41c9238add6..bdc3f76a2594 100644 --- a/test/rubygems/test_gem_uri_formatter.rb +++ b/test/rubygems/test_gem_uri_formatter.rb @@ -1,26 +1,26 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/uri_formatter' +require_relative "helper" +require "rubygems/uri_formatter" class TestGemUriFormatter < Gem::TestCase def test_normalize_uri - assert_equal 'FILE://example/', - Gem::UriFormatter.new('FILE://example/').normalize - assert_equal 'FTP://example/', - Gem::UriFormatter.new('FTP://example/').normalize - assert_equal 'HTTP://example/', - Gem::UriFormatter.new('HTTP://example/').normalize - assert_equal 'HTTPS://example/', - Gem::UriFormatter.new('HTTPS://example/').normalize - assert_equal 'http://example/', - Gem::UriFormatter.new('example/').normalize + assert_equal "FILE://example/", + Gem::UriFormatter.new("FILE://example/").normalize + assert_equal "FTP://example/", + Gem::UriFormatter.new("FTP://example/").normalize + assert_equal "HTTP://example/", + Gem::UriFormatter.new("HTTP://example/").normalize + assert_equal "HTTPS://example/", + Gem::UriFormatter.new("HTTPS://example/").normalize + assert_equal "http://example/", + Gem::UriFormatter.new("example/").normalize end def test_escape - assert_equal 'a%40b%5Cc', Gem::UriFormatter.new('a@b\c').escape + assert_equal "a%40b%5Cc", Gem::UriFormatter.new('a@b\c').escape end def test_unescape - assert_equal 'a@b\c', Gem::UriFormatter.new('a%40b%5Cc').unescape + assert_equal 'a@b\c', Gem::UriFormatter.new("a%40b%5Cc").unescape end end diff --git a/test/rubygems/test_gem_util.rb b/test/rubygems/test_gem_util.rb index e0db5c283de2..04cb000f8dfc 100644 --- a/test/rubygems/test_gem_util.rb +++ b/test/rubygems/test_gem_util.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/util' +require_relative "helper" +require "rubygems/util" class TestGemUtil < Gem::TestCase def test_class_popen pend "popen with a block does not behave well on jruby" if Gem.java_platform? - assert_equal "0\n", Gem::Util.popen(*ruby_with_rubygems_in_load_path, '-e', 'p 0') + assert_equal "0\n", Gem::Util.popen(*ruby_with_rubygems_in_load_path, "-e", "p 0") assert_raise Errno::ECHILD do Process.wait(-1) @@ -16,7 +16,7 @@ def test_silent_system pend if Gem.java_platform? Gem::Deprecate.skip_during do out, err = capture_output do - Gem::Util.silent_system(*ruby_with_rubygems_in_load_path, '-e', 'puts "hello"; warn "hello"') + Gem::Util.silent_system(*ruby_with_rubygems_in_load_path, "-e", 'puts "hello"; warn "hello"') end assert_empty out assert_empty err @@ -24,35 +24,35 @@ def test_silent_system end def test_traverse_parents - FileUtils.mkdir_p 'a/b/c' + FileUtils.mkdir_p "a/b/c" - enum = Gem::Util.traverse_parents 'a/b/c' + enum = Gem::Util.traverse_parents "a/b/c" - assert_equal File.join(@tempdir, 'a/b/c'), enum.next - assert_equal File.join(@tempdir, 'a/b'), enum.next - assert_equal File.join(@tempdir, 'a'), enum.next + assert_equal File.join(@tempdir, "a/b/c"), enum.next + assert_equal File.join(@tempdir, "a/b"), enum.next + assert_equal File.join(@tempdir, "a"), enum.next loop { break if enum.next.nil? } # exhaust the enumerator end def test_traverse_parents_does_not_crash_on_permissions_error - pend 'skipped on MS Windows (chmod has no effect)' if win_platform? || java_platform? + pend "skipped on MS Windows (chmod has no effect)" if win_platform? || java_platform? - FileUtils.mkdir_p 'd/e/f' + FileUtils.mkdir_p "d/e/f" # remove 'execute' permission from "e" directory and make it # impossible to cd into it and its children - FileUtils.chmod(0666, 'd/e') + FileUtils.chmod(0666, "d/e") - pend 'skipped in root privilege' if Process.uid.zero? + pend "skipped in root privilege" if Process.uid.zero? - paths = Gem::Util.traverse_parents('d/e/f').to_a + paths = Gem::Util.traverse_parents("d/e/f").to_a - assert_equal File.join(@tempdir, 'd'), paths[0] + assert_equal File.join(@tempdir, "d"), paths[0] assert_equal @tempdir, paths[1] assert_equal File.realpath("..", @tempdir), paths[2] assert_equal File.realpath("../..", @tempdir), paths[3] ensure # restore default permissions, allow the directory to be removed - FileUtils.chmod(0775, 'd/e') unless win_platform? || java_platform? + FileUtils.chmod(0775, "d/e") unless win_platform? || java_platform? end def test_linked_list_find @@ -64,19 +64,19 @@ def test_linked_list_find end def test_glob_files_in_dir - FileUtils.mkdir_p 'g' - FileUtils.touch File.join('g', 'h.rb') - FileUtils.touch File.join('g', 'i.rb') + FileUtils.mkdir_p "g" + FileUtils.touch File.join("g", "h.rb") + FileUtils.touch File.join("g", "i.rb") expected_paths = [ - File.join(@tempdir, 'g/h.rb'), - File.join(@tempdir, 'g/i.rb'), + File.join(@tempdir, "g/h.rb"), + File.join(@tempdir, "g/i.rb"), ] - files_with_absolute_base = Gem::Util.glob_files_in_dir('*.rb', File.join(@tempdir, 'g')) + files_with_absolute_base = Gem::Util.glob_files_in_dir("*.rb", File.join(@tempdir, "g")) assert_equal expected_paths.sort, files_with_absolute_base.sort - files_with_relative_base = Gem::Util.glob_files_in_dir('*.rb', 'g') + files_with_relative_base = Gem::Util.glob_files_in_dir("*.rb", "g") assert_equal expected_paths.sort, files_with_relative_base.sort end diff --git a/test/rubygems/test_gem_validator.rb b/test/rubygems/test_gem_validator.rb index 8090776b4ab6..80109ab8ba9f 100644 --- a/test/rubygems/test_gem_validator.rb +++ b/test/rubygems/test_gem_validator.rb @@ -11,21 +11,21 @@ def setup end def test_alien - @spec = quick_gem 'a' do |s| + @spec = quick_gem "a" do |s| s.files = %w[lib/a.rb lib/b.rb] end util_build_gem @spec - FileUtils.rm File.join(@spec.gem_dir, 'lib/b.rb') - FileUtils.touch File.join(@spec.gem_dir, 'lib/c.rb') + FileUtils.rm File.join(@spec.gem_dir, "lib/b.rb") + FileUtils.touch File.join(@spec.gem_dir, "lib/c.rb") - alien = @validator.alien 'a' + alien = @validator.alien "a" expected = { @spec.file_name => [ - Gem::Validator::ErrorData.new('lib/b.rb', 'Missing file'), - Gem::Validator::ErrorData.new('lib/c.rb', 'Extra file'), + Gem::Validator::ErrorData.new("lib/b.rb", "Missing file"), + Gem::Validator::ErrorData.new("lib/c.rb", "Extra file"), ], } @@ -33,9 +33,9 @@ def test_alien end def test_alien_default - new_default_spec 'c', 1, nil, 'lib/c.rb' + new_default_spec "c", 1, nil, "lib/c.rb" - alien = @validator.alien 'c' + alien = @validator.alien "c" assert_empty alien end diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb index f8066ecbb8cd..e907eabb34d8 100644 --- a/test/rubygems/test_gem_version.rb +++ b/test/rubygems/test_gem_version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" require "rubygems/version" class TestGemVersion < Gem::TestCase @@ -36,8 +36,8 @@ def test_class_create assert_nil Gem::Version.create(nil) assert_equal v("5.1"), Gem::Version.create("5.1") - ver = '1.1'.freeze - assert_equal v('1.1'), Gem::Version.create(ver) + ver = "1.1".freeze + assert_equal v("1.1"), Gem::Version.create(ver) end def test_class_correct @@ -53,8 +53,8 @@ def test_class_correct end def test_class_new_subclass - v1 = Gem::Version.new '1' - v2 = V.new '1' + v1 = Gem::Version.new "1" + v2 = V.new "1" refute_same v1, v2 end @@ -120,10 +120,10 @@ def test_prerelease assert_prerelease "22.1.50.0.d" assert_prerelease "1.2.d.42" - assert_prerelease '1.A' + assert_prerelease "1.A" - assert_prerelease '1-1' - assert_prerelease '1-a' + assert_prerelease "1-1" + assert_prerelease "1-a" refute_prerelease "1.2.0" refute_prerelease "2.9" @@ -199,7 +199,7 @@ def test_semver # modifying the segments of a version should not affect the segments of the cached version object def test_segments - v('9.8.7').segments[2] += 1 + v("9.8.7").segments[2] += 1 refute_version_equal "9.8.8", "9.8.7" assert_equal [9,8,7], v("9.8.7").segments @@ -212,10 +212,10 @@ def test_canonical_segments end def test_frozen_version - v = v('1.freeze.test').freeze - assert_less_than v, v('1') - assert_version_equal v('1'), v.release - assert_version_equal v('2'), v.bump + v = v("1.freeze.test").freeze + assert_less_than v, v("1") + assert_version_equal v("1"), v.release + assert_version_equal v("2"), v.bump end # Asserts that +version+ is a prerelease. diff --git a/test/rubygems/test_gem_version_option.rb b/test/rubygems/test_gem_version_option.rb index 74d7979e3a09..92945e1b0812 100644 --- a/test/rubygems/test_gem_version_option.rb +++ b/test/rubygems/test_gem_version_option.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems/command' -require 'rubygems/version_option' +require_relative "helper" +require "rubygems/command" +require "rubygems/version_option" class TestGemVersionOption < Gem::TestCase def setup super - @cmd = Gem::Command.new 'dummy', 'dummy' + @cmd = Gem::Command.new "dummy", "dummy" @cmd.extend Gem::VersionOption end @@ -43,8 +43,8 @@ def test_platform_option expected = [ Gem::Platform::RUBY, - Gem::Platform.new('x86-freebsd6'), - Gem::Platform.new('x86-freebsd7'), + Gem::Platform.new("x86-freebsd6"), + Gem::Platform.new("x86-freebsd7"), ] assert_equal expected, Gem.platforms @@ -69,7 +69,7 @@ def test_platform_option_twice expected = [ Gem::Platform::RUBY, - Gem::Platform.new('x86-freebsd6'), + Gem::Platform.new("x86-freebsd6"), ] assert_equal expected, Gem.platforms @@ -84,7 +84,7 @@ def test_version_option :args => [], :explicit_prerelease => false, :prerelease => false, - :version => Gem::Requirement.new('> 1'), + :version => Gem::Requirement.new("> 1"), } assert_equal expected, @cmd.options @@ -93,13 +93,13 @@ def test_version_option def test_version_option_compound @cmd.add_version_option - @cmd.handle_options ['--version', '< 1, > 0.9'] + @cmd.handle_options ["--version", "< 1, > 0.9"] expected = { :args => [], :explicit_prerelease => false, :prerelease => false, - :version => Gem::Requirement.new('< 1', '> 0.9'), + :version => Gem::Requirement.new("< 1", "> 0.9"), } assert_equal expected, @cmd.options @@ -108,13 +108,13 @@ def test_version_option_compound def test_multiple_version_operator_option_compound @cmd.add_version_option - @cmd.handle_options ['--version', '< 1', '--version', '> 0.9'] + @cmd.handle_options ["--version", "< 1", "--version", "> 0.9"] expected = { :args => [], :explicit_prerelease => false, :prerelease => false, - :version => Gem::Requirement.new('< 1', '> 0.9'), + :version => Gem::Requirement.new("< 1", "> 0.9"), } assert_equal expected, @cmd.options @@ -130,7 +130,7 @@ def test_version_option_explicit_prerelease :args => [], :explicit_prerelease => true, :prerelease => true, - :version => Gem::Requirement.new('> 1'), + :version => Gem::Requirement.new("> 1"), } assert_equal expected, @cmd.options @@ -145,7 +145,7 @@ def test_version_option_twice :args => [], :explicit_prerelease => false, :prerelease => true, - :version => Gem::Requirement.new('> 1.a'), + :version => Gem::Requirement.new("> 1.a"), } assert_equal expected, @cmd.options @@ -156,7 +156,7 @@ def test_version_option_twice :args => [], :explicit_prerelease => false, :prerelease => false, - :version => Gem::Requirement.new('> 1'), + :version => Gem::Requirement.new("> 1"), } assert_equal expected, @cmd.options diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb index 4efa7e075dd2..cced65fa50d8 100644 --- a/test/rubygems/test_kernel.rb +++ b/test/rubygems/test_kernel.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestKernel < Gem::TestCase def setup @@ -19,76 +19,76 @@ def teardown end def test_gem - assert gem('a', '= 1'), "Should load" + assert gem("a", "= 1"), "Should load" assert $:.any? {|p| %r{a-1/lib} =~ p } end def test_gem_default - assert gem('a', '>= 0') + assert gem("a", ">= 0") - assert_equal @a2, Gem.loaded_specs['a'] + assert_equal @a2, Gem.loaded_specs["a"] end def test_gem_default_re_gem - assert gem('a', '=1') + assert gem("a", "=1") - refute gem('a', '>= 0') + refute gem("a", ">= 0") - assert_equal @a1, Gem.loaded_specs['a'] + assert_equal @a1, Gem.loaded_specs["a"] end def test_gem_re_gem_mismatch - assert gem('a', '=1') + assert gem("a", "=1") assert_raise Gem::LoadError do - gem('a', '= 2') + gem("a", "= 2") end - assert_equal @a1, Gem.loaded_specs['a'] + assert_equal @a1, Gem.loaded_specs["a"] end def test_gem_redundant - assert gem('a', '= 1'), "Should load" - refute gem('a', '= 1'), "Should not load" + assert gem("a", "= 1"), "Should load" + refute gem("a", "= 1"), "Should not load" assert_equal 1, $:.select {|p| %r{a-1/lib} =~ p }.size end def test_gem_overlapping - assert gem('a', '= 1'), "Should load" - refute gem('a', '>= 1'), "Should not load" + assert gem("a", "= 1"), "Should load" + refute gem("a", ">= 1"), "Should not load" assert_equal 1, $:.select {|p| %r{a-1/lib} =~ p }.size end def test_gem_prerelease - quick_gem 'd', '1.1.a' - refute gem('d', '>= 1'), 'release requirement must not load prerelease' - assert gem('d', '>= 1.a'), 'prerelease requirement may load prerelease' + quick_gem "d", "1.1.a" + refute gem("d", ">= 1"), "release requirement must not load prerelease" + assert gem("d", ">= 1.a"), "prerelease requirement may load prerelease" end def test_gem_env_req - ENV["GEM_REQUIREMENT_A"] = '~> 2.0' - assert_raise(Gem::MissingSpecVersionError) { gem('a', '= 1') } - assert gem('a', '> 1') - assert_equal @a2, Gem.loaded_specs['a'] + ENV["GEM_REQUIREMENT_A"] = "~> 2.0" + assert_raise(Gem::MissingSpecVersionError) { gem("a", "= 1") } + assert gem("a", "> 1") + assert_equal @a2, Gem.loaded_specs["a"] end def test_gem_conflicting - assert gem('a', '= 1'), "Should load" + assert gem("a", "= 1"), "Should load" ex = assert_raise Gem::LoadError do - gem 'a', '= 2' + gem "a", "= 2" end assert_equal "can't activate a-2, already activated a-1", ex.message assert_match(/activated a-1/, ex.message) - assert_equal 'a', ex.name + assert_equal "a", ex.name assert $:.any? {|p| %r{a-1/lib} =~ p } refute $:.any? {|p| %r{a-2/lib} =~ p } end def test_gem_not_adding_bin - assert gem('a', '= 1'), "Should load" + assert gem("a", "= 1"), "Should load" refute $:.any? {|p| %r{a-1/bin} =~ p } end @@ -110,19 +110,19 @@ def test_gem_failing_inside_require_doesnt_cause_double_exceptions end def test_gem_bundler - quick_gem 'bundler', '1' - quick_gem 'bundler', '2.a' + quick_gem "bundler", "1" + quick_gem "bundler", "2.a" - assert gem('bundler') + assert gem("bundler") assert $:.any? {|p| %r{bundler-1/lib} =~ p } end def test_gem_bundler_inferred_bundler_version Gem::BundlerVersionFinder.stub(:bundler_version, Gem::Version.new("1")) do - quick_gem 'bundler', '1' - quick_gem 'bundler', '2.a' + quick_gem "bundler", "1" + quick_gem "bundler", "2.a" - assert gem('bundler', '>= 0.a') + assert gem("bundler", ">= 0.a") assert $:.any? {|p| %r{bundler-1/lib} =~ p } end end diff --git a/test/rubygems/test_project_sanity.rb b/test/rubygems/test_project_sanity.rb index 27b1f11d62a3..aff7c66413ce 100644 --- a/test/rubygems/test_project_sanity.rb +++ b/test/rubygems/test_project_sanity.rb @@ -5,7 +5,7 @@ class TestProjectSanity < Gem::TestCase def test_manifest_is_up_to_date - pend unless File.exist?(File.expand_path('../../Rakefile', __dir__)) + pend unless File.exist?(File.expand_path("../../Rakefile", __dir__)) _, status = Open3.capture2e("rake check_manifest") diff --git a/test/rubygems/test_remote_fetch_error.rb b/test/rubygems/test_remote_fetch_error.rb index b9e58389d376..55c505d879ac 100644 --- a/test/rubygems/test_remote_fetch_error.rb +++ b/test/rubygems/test_remote_fetch_error.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require_relative 'helper' +require_relative "helper" class TestRemoteFetchError < Gem::TestCase def test_password_redacted - error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://user:secret@gemsource.org') + error = Gem::RemoteFetcher::FetchError.new("There was an error fetching", "https://user:secret@gemsource.org") refute_match %r{secret}, error.to_s end def test_invalid_url - error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://::gemsource.org') - assert_equal error.to_s, 'There was an error fetching (https://::gemsource.org)' + error = Gem::RemoteFetcher::FetchError.new("There was an error fetching", "https://::gemsource.org") + assert_equal error.to_s, "There was an error fetching (https://::gemsource.org)" end def test_to_s - error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://gemsource.org') - assert_equal error.to_s, 'There was an error fetching (https://gemsource.org)' + error = Gem::RemoteFetcher::FetchError.new("There was an error fetching", "https://gemsource.org") + assert_equal error.to_s, "There was an error fetching (https://gemsource.org)" end end diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index 3e393a4df33c..f933bbb5d5c0 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' -require 'rubygems' +require_relative "helper" +require "rubygems" class TestGemRequire < Gem::TestCase class Latch @@ -35,26 +35,26 @@ def refute_require(path) def test_respect_loaded_features_caching_like_standard_require dir = Dir.mktmpdir("test_require", @tempdir) - lp1 = File.join dir, 'foo1' - foo1 = File.join lp1, 'foo.rb' + lp1 = File.join dir, "foo1" + foo1 = File.join lp1, "foo.rb" FileUtils.mkdir_p lp1 - File.open(foo1, 'w') {|f| f.write "class Object; HELLO = 'foo1' end" } + File.open(foo1, "w") {|f| f.write "class Object; HELLO = 'foo1' end" } lp = $LOAD_PATH.dup $LOAD_PATH.unshift lp1 - assert_require 'foo' + assert_require "foo" assert_equal "foo1", ::Object::HELLO - lp2 = File.join dir, 'foo2' - foo2 = File.join lp2, 'foo.rb' + lp2 = File.join dir, "foo2" + foo2 = File.join lp2, "foo.rb" FileUtils.mkdir_p lp2 - File.open(foo2, 'w') {|f| f.write "class Object; HELLO = 'foo2' end" } + File.open(foo2, "w") {|f| f.write "class Object; HELLO = 'foo2' end" } $LOAD_PATH.unshift lp2 - refute_require 'foo' + refute_require "foo" assert_equal "foo1", ::Object::HELLO ensure $LOAD_PATH.replace lp @@ -71,18 +71,18 @@ def test_dash_i_beats_gems install_specs c1, c2, b1, a1 dir = Dir.mktmpdir("test_require", @tempdir) - dash_i_arg = File.join dir, 'lib' + dash_i_arg = File.join dir, "lib" - c_rb = File.join dash_i_arg, 'b', 'c.rb' + c_rb = File.join dash_i_arg, "b", "c.rb" FileUtils.mkdir_p File.dirname c_rb - File.open(c_rb, 'w') {|f| f.write "class Object; HELLO = 'world' end" } + File.open(c_rb, "w") {|f| f.write "class Object; HELLO = 'world' end" } # Pretend to provide a commandline argument that overrides a file in gem b $LOAD_PATH.unshift dash_i_arg - assert_require 'test_gem_require_a' - assert_require 'b/c' # this should be required from -I + assert_require "test_gem_require_a" + assert_require "b/c" # this should be required from -I assert_equal "world", ::Object::HELLO assert_equal %w[a-1 b-1], loaded_spec_names ensure @@ -110,20 +110,20 @@ def test_dash_i_beats_default_gems install_default_gems c1, c2, b1, a1 dir = Dir.mktmpdir("test_require", @tempdir) - dash_i_arg = File.join dir, 'lib' + dash_i_arg = File.join dir, "lib" - c_rb = File.join dash_i_arg, 'c', 'c.rb' + c_rb = File.join dash_i_arg, "c", "c.rb" FileUtils.mkdir_p File.dirname c_rb - File.open(c_rb, 'w') {|f| f.write "class Object; HELLO = 'world' end" } + File.open(c_rb, "w") {|f| f.write "class Object; HELLO = 'world' end" } - assert_require 'test_gem_require_a' + assert_require "test_gem_require_a" # Pretend to provide a commandline argument that overrides a file in gem b $LOAD_PATH.unshift dash_i_arg - assert_require 'b/c' - assert_require 'c/c' # this should be required from -I + assert_require "b/c" + assert_require "c/c" # this should be required from -I assert_equal "world", ::Object::HELLO assert_equal %w[a-1 b-1], loaded_spec_names ensure @@ -134,12 +134,12 @@ def test_dash_i_respects_default_library_extension_priority pend "extensions don't quite work on jruby" if Gem.java_platform? pend "not installed yet" unless RbConfig::TOPDIR - dash_i_ext_arg = util_install_extension_file('a') - dash_i_lib_arg = util_install_ruby_file('a') + dash_i_ext_arg = util_install_extension_file("a") + dash_i_lib_arg = util_install_ruby_file("a") $LOAD_PATH.unshift dash_i_lib_arg $LOAD_PATH.unshift dash_i_ext_arg - assert_require 'a' + assert_require "a" assert_match(/a\.rb$/, $LOADED_FEATURES.last) end @@ -175,7 +175,7 @@ def test_require_is_not_lazy_with_exact_req install_specs b1, b2, a1 - assert_require 'test_gem_require_a' + assert_require "test_gem_require_a" assert_equal %w[a-1 b-1], loaded_spec_names assert_equal unresolved_names, [] @@ -190,7 +190,7 @@ def test_require_is_lazy_with_inexact_req install_specs b1, b2, a1 - assert_require 'test_gem_require_a' + assert_require "test_gem_require_a" assert_equal %w[a-1], loaded_spec_names assert_equal unresolved_names, ["b (>= 1)"] @@ -204,7 +204,7 @@ def test_require_is_not_lazy_with_one_possible install_specs b1, a1 - assert_require 'test_gem_require_a' + assert_require "test_gem_require_a" assert_equal %w[a-1 b-1], loaded_spec_names assert_equal unresolved_names, [] @@ -217,7 +217,7 @@ def test_require_can_use_a_pathname_object install_specs a1 - assert_require Pathname.new 'test_gem_require_a' + assert_require Pathname.new "test_gem_require_a" assert_equal %w[a-1], loaded_spec_names assert_equal unresolved_names, [] end @@ -241,7 +241,7 @@ def test_activate_via_require_respects_loaded_files load_path_changed = true end - require 'benchmark' # the stdlib + require "benchmark" # the stdlib a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb" b1 = util_spec "b", "1", nil, "lib/benchmark.rb" @@ -250,7 +250,7 @@ def test_activate_via_require_respects_loaded_files install_specs b1, b2, a1 # Activates a-1, but not b-1 and b-2 - assert_require 'test_gem_require_a' + assert_require "test_gem_require_a" assert_equal %w[a-1], loaded_spec_names assert $LOAD_PATH.include? a1.load_paths[0] refute $LOAD_PATH.include? b1.load_paths[0] @@ -263,7 +263,7 @@ def test_activate_via_require_respects_loaded_files # though b-2 is earlier in $LOAD_PATH it already loaded a benchmark.rb file # and that still exists in $LOAD_PATH (further down), # and as a result #gem_original_require returns false. - refute require('benchmark'), "the benchmark stdlib should be recognized as already loaded" + refute require("benchmark"), "the benchmark stdlib should be recognized as already loaded" assert_includes $LOAD_PATH, b2.load_paths[0] assert_includes $LOAD_PATH, rubylibdir @@ -296,7 +296,7 @@ def test_activate_via_require_respects_loaded_default_from_default_gems install_specs a2 - refute_require 'a' + refute_require "a" assert_equal %w[a-1], loaded_spec_names end @@ -378,7 +378,7 @@ def test_require_works_after_cleanup # Load default ruby gems fresh as if we've just started a ruby script. Gem::Specification.reset - require 'rubygems' + require "rubygems" Gem::Specification.stubs # Remove an old default gem version directly from disk as if someone ran @@ -387,9 +387,9 @@ def test_require_works_after_cleanup FileUtils.rm_rf(File.join @gemhome, "specifications", "default", "#{b1.full_name}.gemspec") # Require gems that have not been removed. - assert_require 'a/b' + assert_require "a/b" assert_equal %w[a-1.0], loaded_spec_names - assert_require 'b/d' + assert_require "b/d" assert_equal %w[a-1.0 b-2.0], loaded_spec_names end @@ -471,7 +471,7 @@ def test_realworld_upgraded_default_gem RUBY File.write(path, code) - output = Gem::Util.popen({ 'GEM_HOME' => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip + output = Gem::Util.popen({ "GEM_HOME" => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip assert $?.success? refute_empty output assert_equal "999.99.9", output.lines[0].chomp @@ -542,11 +542,11 @@ def test_try_activate_error_unlocks_require_monitor silence_warnings do class << ::Gem alias old_try_activate try_activate - def try_activate(*); raise 'raised from try_activate'; end + def try_activate(*); raise "raised from try_activate"; end end end - require 'does_not_exist_for_try_activate_test' + require "does_not_exist_for_try_activate_test" rescue RuntimeError => e assert_match(/raised from try_activate/, e.message) assert Kernel::RUBYGEMS_ACTIVATION_MONITOR.try_enter, "require monitor was not unlocked when try_activate raised" @@ -585,13 +585,13 @@ def self.gem(*args) end def test_require_bundler - b1 = util_spec('bundler', '1', nil, "lib/bundler/setup.rb") - b2a = util_spec('bundler', '2.a', nil, "lib/bundler/setup.rb") + b1 = util_spec("bundler", "1", nil, "lib/bundler/setup.rb") + b2a = util_spec("bundler", "2.a", nil, "lib/bundler/setup.rb") install_specs b1, b2a require "rubygems/bundler_version_finder" $:.clear - assert_require 'bundler/setup' + assert_require "bundler/setup" assert_equal %w[bundler-2.a], loaded_spec_names assert_empty unresolved_names end @@ -712,7 +712,7 @@ def util_install_ruby_file(name) a_rb = File.join dash_i_lib_arg, "#{name}.rb" FileUtils.mkdir_p File.dirname a_rb - File.open(a_rb, 'w') {|f| f.write "# #{name}.rb" } + File.open(a_rb, "w") {|f| f.write "# #{name}.rb" } dash_i_lib_arg end diff --git a/test/rubygems/test_rubygems.rb b/test/rubygems/test_rubygems.rb index e5c0a22caf51..8bd116646fce 100644 --- a/test/rubygems/test_rubygems.rb +++ b/test/rubygems/test_rubygems.rb @@ -1,19 +1,19 @@ -require_relative 'helper' +require_relative "helper" class GemTest < Gem::TestCase def test_rubygems_normal_behaviour - _ = Gem::Util.popen(*ruby_with_rubygems_in_load_path, '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip + _ = Gem::Util.popen(*ruby_with_rubygems_in_load_path, "-e", "'require \"rubygems\"'", { :err => [:child, :out] }).strip assert $?.success? end def test_operating_system_other_exceptions - pend "does not apply to truffleruby" if RUBY_ENGINE == 'truffleruby' + pend "does not apply to truffleruby" if RUBY_ENGINE == "truffleruby" path = util_install_operating_system_rb <<-RUBY intentionally_not_implemented_method RUBY - output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip + output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), "-e", "'require \"rubygems\"'", { :err => [:child, :out] }).strip assert !$?.success? assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'" assert_includes output, "Loading the #{operating_system_rb_at(path)} file caused an error. " \ @@ -23,8 +23,8 @@ def test_operating_system_other_exceptions end def test_operating_system_customizing_default_dir - pend "does not apply to truffleruby" if RUBY_ENGINE == 'truffleruby' - pend "loads a custom defaults/jruby file that gets in the middle" if RUBY_ENGINE == 'jruby' + pend "does not apply to truffleruby" if RUBY_ENGINE == "truffleruby" + pend "loads a custom defaults/jruby file that gets in the middle" if RUBY_ENGINE == "jruby" # On a non existing default dir, there should be no gems @@ -38,7 +38,7 @@ def self.default_dir output = Gem::Util.popen( *ruby_with_rubygems_and_fake_operating_system_in_load_path(path), - '-e', + "-e", "require \"rubygems\"; puts Gem::Specification.stubs.map(&:full_name)", { :err => [:child, :out] } ).strip @@ -59,7 +59,7 @@ def util_install_operating_system_rb(content) FileUtils.mkdir_p File.dirname(operating_system_rb) - File.open(operating_system_rb, 'w') {|f| f.write content } + File.open(operating_system_rb, "w") {|f| f.write content } dir_lib_arg end diff --git a/test/rubygems/utilities.rb b/test/rubygems/utilities.rb index 613cf6c0ee37..5f8f763cb56b 100644 --- a/test/rubygems/utilities.rb +++ b/test/rubygems/utilities.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'tempfile' -require 'rubygems' -require 'rubygems/remote_fetcher' +require "tempfile" +require "rubygems" +require "rubygems/remote_fetcher" ## # A fake Gem::RemoteFetcher for use in tests or to avoid real live HTTP @@ -39,7 +39,7 @@ def initialize end def find_data(path) - return Gem.read_binary path.path if URI === path and 'file' == path.scheme + return Gem.read_binary path.path if URI === path and "file" == path.scheme if URI === path and "URI::#{path.scheme.upcase}" != path.class.name raise ArgumentError, @@ -48,7 +48,7 @@ def find_data(path) path = path.to_s @paths << path - raise ArgumentError, 'need full URI' unless path.start_with?("https://", "http://") + raise ArgumentError, "need full URI" unless path.start_with?("https://", "http://") unless @data.key? path raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path) @@ -76,7 +76,7 @@ def fetch_path(path, mtime = nil, head = false) def cache_update_path(uri, path = nil, update = true) if data = fetch_path(uri) - File.open(path, 'wb') {|io| io.write data } if path and update + File.open(path, "wb") {|io| io.write data } if path and update data else Gem.read_binary(path) if path @@ -108,9 +108,9 @@ def request(uri, request_class, last_modified = nil) end def pretty_print(q) # :nodoc: - q.group 2, '[FakeFetcher', ']' do + q.group 2, "[FakeFetcher", "]" do q.breakable - q.text 'URIs:' + q.text "URIs:" q.breakable q.pp @data.keys @@ -121,7 +121,7 @@ def fetch_size(path) path = path.to_s @paths << path - raise ArgumentError, 'need full URI' unless path =~ %r{^http://} + raise ArgumentError, "need full URI" unless path =~ %r{^http://} unless @data.key? path raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path) @@ -288,16 +288,16 @@ def download(name, version, dependencies = nil, &block) # Creates a legacy platform spec with the name 'pl' and version 1 def legacy_platform - spec 'pl', 1 do |s| - s.platform = Gem::Platform.new 'i386-linux' - s.instance_variable_set :@original_platform, 'i386-linux' + spec "pl", 1 do |s| + s.platform = Gem::Platform.new "i386-linux" + s.instance_variable_set :@original_platform, "i386-linux" end end def setup_fetcher # :nodoc: - require 'zlib' - require 'socket' - require 'rubygems/remote_fetcher' + require "zlib" + require "socket" + require "rubygems/remote_fetcher" unless @test.fetcher @test.fetcher = Gem::FakeFetcher.new @@ -338,7 +338,7 @@ def spec(name, version, dependencies = nil, &block) end def write_spec(spec) # :nodoc: - File.open spec.spec_file, 'w' do |io| + File.open spec.spec_file, "w" do |io| io.write spec.to_ruby_for_cache end end @@ -354,7 +354,7 @@ class TempIO < Tempfile ## # Creates a new TempIO that will be initialized to contain +string+. - def initialize(string = '') + def initialize(string = "") super "TempIO" binmode write string diff --git a/util/changelog.rb b/util/changelog.rb index 034ceec74a6a..2ce79b3f05fe 100644 --- a/util/changelog.rb +++ b/util/changelog.rb @@ -89,15 +89,15 @@ def release_notes_for_blog def change_types_for_blog types = release_notes .select {|line| change_types.include?(line) } - .map {|line| line.downcase.tr('^a-z ', '').strip } + .map {|line| line.downcase.tr("^a-z ", "").strip } .uniq last_change_type = types.pop if types.empty? - types = +'' + types = +"" else - types = types.join(', ') << ' and ' + types = types.join(", ") << " and " end types << last_change_type @@ -189,7 +189,7 @@ def wrap(text, length, indent) result << work unless work.empty? result = result.reduce(String.new) do |acc, elem| - acc << "\n" << ' ' * indent unless acc.empty? + acc << "\n" << " " * indent unless acc.empty? acc << elem end result diff --git a/util/create_certs.rb b/util/create_certs.rb index 86545fe3ead9..92fbc98bbcb8 100644 --- a/util/create_certs.rb +++ b/util/create_certs.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'openssl' +require "openssl" class CertificateBuilder attr_reader :start @@ -53,20 +53,20 @@ def create_certificate(key, subject, issuer_key, issuer_cert, ef = OpenSSL::X509::ExtensionFactory.new issuer_cert, cert cert.extensions = [ - ef.create_extension('subjectAltName', "email:#{subject}@example"), - ef.create_extension('subjectKeyIdentifier', 'hash'), + ef.create_extension("subjectAltName", "email:#{subject}@example"), + ef.create_extension("subjectKeyIdentifier", "hash"), ] if cert != issuer_cert # not self-signed cert - cert.add_extension ef.create_extension('authorityKeyIdentifier', 'keyid:always') + cert.add_extension ef.create_extension("authorityKeyIdentifier", "keyid:always") end if is_ca - cert.add_extension ef.create_extension('basicConstraints', 'CA:TRUE', true) - cert.add_extension ef.create_extension('keyUsage', 'keyCertSign', true) + cert.add_extension ef.create_extension("basicConstraints", "CA:TRUE", true) + cert.add_extension ef.create_extension("keyUsage", "keyCertSign", true) end - cert.sign issuer_key, 'SHA1' + cert.sign issuer_key, "SHA1" puts "created cert - subject: #{cert.subject}, issuer: #{cert.issuer}" cert @@ -120,39 +120,39 @@ def validity_for(time) certs = {} certs[:public] = - cb.create_certificates(keys[:private], 'nobody', + cb.create_certificates(keys[:private], "nobody", is_ca: true) certs[:child] = - cb.create_certificates(keys[:child], 'child', + cb.create_certificates(keys[:child], "child", keys[:private], certs[:public], is_ca: true) certs[:alternate] = - cb.create_certificates(keys[:alternate], 'alternate') + cb.create_certificates(keys[:alternate], "alternate") certs[:expired] = - cb.create_certificates(keys[:private], 'nobody', + cb.create_certificates(keys[:private], "nobody", not_before: Time.at(0), not_after: Time.at(0)) certs[:future] = - cb.create_certificates(keys[:private], 'nobody', + cb.create_certificates(keys[:private], "nobody", not_before: :end_of_time, not_after: :end_of_time) certs[:invalid_issuer] = - cb.create_certificates(keys[:invalid], 'invalid', + cb.create_certificates(keys[:invalid], "invalid", keys[:invalid], certs[:public], is_ca: true) certs[:grandchild] = - cb.create_certificates(keys[:grandchild], 'grandchild', + cb.create_certificates(keys[:grandchild], "grandchild", keys[:child], certs[:child]) certs[:invalid_signer] = - cb.create_certificates(keys[:invalid], 'invalid', + cb.create_certificates(keys[:invalid], "invalid", keys[:private], certs[:invalid]) certs[:invalidchild] = - cb.create_certificates(keys[:invalidchild], 'invalidchild', + cb.create_certificates(keys[:invalidchild], "invalidchild", keys[:invalid], certs[:child]) certs[:wrong_key] = - cb.create_certificates(keys[:alternate], 'nobody') + cb.create_certificates(keys[:alternate], "nobody") -base_dir = 'test/rubygems' +base_dir = "test/rubygems" keys.each do |name, key| dest = File.join base_dir, "#{name}_key.pem" diff --git a/util/create_encrypted_key.rb b/util/create_encrypted_key.rb index dd03ad185a0f..006330459e81 100644 --- a/util/create_encrypted_key.rb +++ b/util/create_encrypted_key.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require 'openssl' +require "openssl" -test_path = File.expand_path('../test/rubygems', __dir__) +test_path = File.expand_path("../test/rubygems", __dir__) private_key_path = "#{test_path}/private_key.pem" key = OpenSSL::PKey::RSA.new File.read private_key_path -cipher = OpenSSL::Cipher.new 'AES-256-CBC' +cipher = OpenSSL::Cipher.new "AES-256-CBC" encrypted_key_path = "#{test_path}/encrypted_private_key.pem" -File.open encrypted_key_path, 'w' do |io| - io.write key.to_pem cipher, 'Foo bar' +File.open encrypted_key_path, "w" do |io| + io.write key.to_pem cipher, "Foo bar" end diff --git a/util/generate_spdx_license_list.rb b/util/generate_spdx_license_list.rb index 183b4c27c17d..cc00565946e4 100644 --- a/util/generate_spdx_license_list.rb +++ b/util/generate_spdx_license_list.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require 'json' -require 'net/http' -require 'uri' +require "json" +require "net/http" +require "uri" -licenses_json = Net::HTTP.get(URI('https://spdx.org/licenses/licenses.json')) -licenses = JSON.parse(licenses_json)['licenses'].map do |licenseObject| - licenseObject['licenseId'] +licenses_json = Net::HTTP.get(URI("https://spdx.org/licenses/licenses.json")) +licenses = JSON.parse(licenses_json)["licenses"].map do |licenseObject| + licenseObject["licenseId"] end -exceptions_json = Net::HTTP.get(URI('https://spdx.org/licenses/exceptions.json')) -exceptions = JSON.parse(exceptions_json)['exceptions'].map do |exceptionObject| - exceptionObject['licenseExceptionId'] +exceptions_json = Net::HTTP.get(URI("https://spdx.org/licenses/exceptions.json")) +exceptions = JSON.parse(exceptions_json)["exceptions"].map do |exceptionObject| + exceptionObject["licenseExceptionId"] end -open 'lib/rubygems/util/licenses.rb', 'w' do |io| +open "lib/rubygems/util/licenses.rb", "w" do |io| io.write <<-RUBY # frozen_string_literal: true diff --git a/util/update_bundled_ca_certificates.rb b/util/update_bundled_ca_certificates.rb index deffcc231464..075c8b83a41b 100644 --- a/util/update_bundled_ca_certificates.rb +++ b/util/update_bundled_ca_certificates.rb @@ -1,29 +1,29 @@ # frozen_string_literal: true -require 'net/http' -require 'openssl' -require 'fileutils' +require "net/http" +require "openssl" +require "fileutils" URIS = [ - URI('https://rubygems.org'), - URI('https://www.rubygems.org'), - URI('https://index.rubygems.org'), - URI('https://staging.rubygems.org'), + URI("https://rubygems.org"), + URI("https://www.rubygems.org"), + URI("https://index.rubygems.org"), + URI("https://staging.rubygems.org"), ].freeze HOSTNAMES_TO_MAP = [ - 'rubygems.org', + "rubygems.org", ].freeze def connect_to(uri, store) # None of the URIs are IPv6, so URI::Generic#hostname(ruby 1.9.3+) isn't needed http = Net::HTTP.new uri.host, uri.port - http.use_ssl = uri.scheme.downcase == 'https' + http.use_ssl = uri.scheme.downcase == "https" http.ssl_version = :TLSv1_2 http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.cert_store = store - http.get '/' + http.get "/" true rescue OpenSSL::SSL::SSLError @@ -66,7 +66,7 @@ def test_certificates(certificates, uri) puts match.map {|certificate| certificate.subject } return else - print '.' + print "." end end puts @@ -99,15 +99,15 @@ def write_certificates(certificates) mapping = hostname_certificate_mapping(certificates) mapping.each do |hostname, certificate| subject = certificate.subject.to_a - name = (subject.assoc('CN') || subject.assoc('OU'))[1] - name = name.delete ' .-' + name = (subject.assoc("CN") || subject.assoc("OU"))[1] + name = name.delete " .-" FileUtils.mkdir_p("lib/rubygems/ssl_certs/#{hostname}") destination = "lib/rubygems/ssl_certs/#{hostname}/#{name}.pem" warn "overwriting certificate #{name}" if File.exist? destination - File.open destination, 'w' do |io| + File.open destination, "w" do |io| io.write certificate.to_pem end end