[rubygems/rubygems] util/rubocop -A --only Style/RegexpLiteral

https://github.com/rubygems/rubygems/commit/9264d83421
This commit is contained in:
Hiroshi SHIBATA 2023-04-05 17:06:01 +09:00 committed by git
parent 65d27d3c0a
commit e003784fc8
46 changed files with 221 additions and 222 deletions

View File

@ -94,7 +94,7 @@ prefix or only the files that are requireable.
gem_path = spec.full_gem_path
extra = "/{#{spec.require_paths.join ","}}" if options[:lib_only]
glob = "#{gem_path}#{extra}/**/*"
prefix_re = /#{Regexp.escape(gem_path)}\//
prefix_re = %r{#{Regexp.escape(gem_path)}/}
Dir[glob].map do |file|
[gem_path, file.sub(prefix_re, "")]
@ -104,7 +104,7 @@ prefix or only the files that are requireable.
def files_in_default_gem(spec)
spec.files.map do |file|
case file
when /\A#{spec.bindir}\//
when %r{\A#{spec.bindir}/}
# $' is POSTMATCH
[RbConfig::CONFIG["bindir"], $']
when /\.so\z/

View File

@ -7,8 +7,8 @@ require_relative "../command"
# RubyGems checkout or tarball.
class Gem::Commands::SetupCommand < Gem::Command
HISTORY_HEADER = /^#\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
VERSION_MATCHER = /^#\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
HISTORY_HEADER = %r{^#\s*[\d.a-zA-Z]+\s*/\s*\d{4}-\d{2}-\d{2}\s*$}.freeze
VERSION_MATCHER = %r{^#\s*([\d.a-zA-Z]+)\s*/\s*\d{4}-\d{2}-\d{2}\s*$}.freeze
ENV_PATHS = %w[/usr/bin/env /bin/env].freeze

View File

@ -309,7 +309,7 @@ class Gem::Indexer
end
files = files.map do |path|
path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK?
path.sub(%r{^#{Regexp.escape @directory}/?}, "") # HACK?
end
files.each do |file|
@ -390,7 +390,7 @@ class Gem::Indexer
files << "#{@prerelease_specs_index}.gz"
files = files.map do |path|
path.sub(/^#{Regexp.escape @directory}\/?/, "") # HACK?
path.sub(%r{^#{Regexp.escape @directory}/?}, "") # HACK?
end
files.each do |file|

View File

@ -239,14 +239,14 @@ class Gem::Installer
next unless io.gets.to_s.include?("This file was generated by RubyGems")
ruby_executable = true
existing = io.read.slice(%r{
existing = io.read.slice(/
^\s*(
gem \s |
load \s Gem\.bin_path\( |
load \s Gem\.activate_bin_path\(
)
(['"])(.*?)(\2),
}x, 3)
/x, 3)
end
return if spec.name == existing

View File

@ -136,7 +136,7 @@ class Gem::S3URISigner
end
def base64_uri_escape(str)
str.gsub(/[\+\/=\n]/, BASE64_URI_TRANSLATE)
str.gsub(%r{[\+/=\n]}, BASE64_URI_TRANSLATE)
end
def ec2_metadata_credentials_json

View File

@ -100,7 +100,7 @@ class Gem::Source
def cache_dir(uri)
# Correct for windows paths
escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/')
escaped_path = uri.path.sub(%r{^/([a-z]):/}i, '/\\1-/')
escaped_path.tap(&Gem::UNTAINT)
File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path)
@ -231,7 +231,7 @@ class Gem::Source
private
def enforce_trailing_slash(uri)
uri.merge(uri.path.gsub(/\/+$/, "") + "/")
uri.merge(uri.path.gsub(%r{/+$}, "") + "/")
end
end

View File

@ -565,7 +565,7 @@ class Gem::Licenses
x11vnc-openssl-exception
].freeze
REGEXP = %r{
REGEXP = /
\A
(?:
#{Regexp.union(LICENSE_IDENTIFIERS)}
@ -575,7 +575,7 @@ class Gem::Licenses
| #{LICENSE_REF}
)
\Z
}ox.freeze
/ox.freeze
def self.match?(license)
!REGEXP.match(license).nil?

View File

@ -25,7 +25,7 @@ class Gem::Validator
installed_files = []
Find.find gem_directory do |file_name|
fn = file_name[gem_directory.size..file_name.size - 1].sub(/^\//, "")
fn = file_name[gem_directory.size..file_name.size - 1].sub(%r{^/}, "")
installed_files << fn unless
fn.empty? || fn.include?("CVS") || File.directory?(file_name)
end

View File

@ -16,13 +16,13 @@ class TestGemConfig < Gem::TestCase
path = Gem::TestCase.class_variable_get(:@@good_rake)
ruby, rake = path.shellsplit
assert_equal(Gem.ruby, ruby)
assert_match(/\/good_rake.rb\z/, rake)
assert_match(%r{/good_rake.rb\z}, rake)
end
def test_bad_rake_path_is_escaped
path = Gem::TestCase.class_variable_get(:@@bad_rake)
ruby, rake = path.shellsplit
assert_equal(Gem.ruby, ruby)
assert_match(/\/bad_rake.rb\z/, rake)
assert_match(%r{/bad_rake.rb\z}, rake)
end
end

View File

@ -1254,8 +1254,8 @@ class TestGem < Gem::TestCase
Gem.try_activate "a_file"
end
assert_match %r{Could not find 'b' }, e.message
assert_match %r{at: #{a.spec_file}}, e.message
assert_match(/Could not find 'b' /, e.message)
assert_match(/at: #{a.spec_file}/, e.message)
end
def test_self_try_activate_missing_prerelease
@ -1275,7 +1275,7 @@ class TestGem < Gem::TestCase
Gem.try_activate "a_file"
end
assert_match %r{Could not find 'b' \(= 1.0rc1\)}, e.message
assert_match(/Could not find 'b' \(= 1.0rc1\)/, e.message)
end
def test_self_try_activate_missing_extensions

View File

@ -102,7 +102,7 @@ class TestGemCommand < Gem::TestCase
@cmd.invoke
end
assert_match %r{Usage: gem doit}, @ui.output
assert_match(/Usage: gem doit/, @ui.output)
end
def test_invoke
@ -188,7 +188,7 @@ class TestGemCommand < Gem::TestCase
@cmd.invoke "-h"
end
assert_match %r{Usage: gem doit}, @ui.output
assert_match(/Usage: gem doit/, @ui.output)
end
def test_add_option

View File

@ -231,7 +231,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{^Skipped default gems: b-2}, @ui.output
assert_match(/^Skipped default gems: b-2/, @ui.output)
assert_empty @ui.error
end

View File

@ -28,7 +28,7 @@ class TestGemCommandsContentsCommand < Gem::TestCase
end
assert_match %r{lib/foo\.rb}, @ui.output
assert_match %r{Rakefile}, @ui.output
assert_match(/Rakefile/, @ui.output)
assert_equal "", @ui.error
end
@ -44,7 +44,7 @@ class TestGemCommandsContentsCommand < Gem::TestCase
assert_match %r{lib/foo\.rb}, @ui.output
assert_match %r{lib/bar\.rb}, @ui.output
assert_match %r{Rakefile}, @ui.output
assert_match(/Rakefile/, @ui.output)
assert_equal "", @ui.error
end
@ -57,8 +57,8 @@ class TestGemCommandsContentsCommand < Gem::TestCase
end
end
assert_match %r{Unable to find gem 'foo' in default gem paths}, @ui.output
assert_match %r{Directories searched:}, @ui.output
assert_match(/Unable to find gem 'foo' in default gem paths/, @ui.output)
assert_match(/Directories searched:/, @ui.output)
assert_equal "", @ui.error
end
@ -72,7 +72,7 @@ class TestGemCommandsContentsCommand < Gem::TestCase
end
assert_match %r{lib/foo\.rb}, @ui.output
assert_match %r{Rakefile}, @ui.output
assert_match(/Rakefile/, @ui.output)
assert_equal "", @ui.error
end
@ -87,7 +87,7 @@ class TestGemCommandsContentsCommand < Gem::TestCase
end
assert_match %r{lib/foo\.rb}, @ui.output
refute_match %r{Rakefile}, @ui.output
refute_match(/Rakefile/, @ui.output)
assert_equal "", @ui.error
end
@ -148,7 +148,7 @@ class TestGemCommandsContentsCommand < Gem::TestCase
assert_match %r{lib/foo\.rb}, @ui.output
assert_match %r{lib/bar\.rb}, @ui.output
assert_match %r{Rakefile}, @ui.output
assert_match(/Rakefile/, @ui.output)
assert_equal "", @ui.error
end

View File

@ -23,28 +23,28 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{RUBYGEMS VERSION: (\d\.)+\d}, @ui.output
assert_match %r{RUBY VERSION: \d+\.\d+\.\d+ \(.*\) \[.*\]}, @ui.output
assert_match %r{INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}},
@ui.output
assert_match %r{USER INSTALLATION DIRECTORY: #{Regexp.escape Gem.user_dir}},
@ui.output
assert_match %r{RUBYGEMS PREFIX: }, @ui.output
assert_match %r{RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}},
@ui.output
assert_match %r{GIT EXECUTABLE: #{@cmd.send(:git_path)}}, @ui.output
assert_match %r{SYSTEM CONFIGURATION DIRECTORY:}, @ui.output
assert_match %r{EXECUTABLE DIRECTORY:}, @ui.output
assert_match %r{RUBYGEMS PLATFORMS:}, @ui.output
assert_match %r{- #{Gem::Platform.local}}, @ui.output
assert_match %r{GEM PATHS:}, @ui.output
assert_match %r{- #{Regexp.escape @gemhome}}, @ui.output
assert_match %r{GEM CONFIGURATION:}, @ui.output
assert_match %r{"gemcutter_key" => "\*\*\*\*"}, @ui.output
assert_match %r{:verbose => }, @ui.output
assert_match %r{REMOTE SOURCES:}, @ui.output
assert_match(/RUBYGEMS VERSION: (\d\.)+\d/, @ui.output)
assert_match(/RUBY VERSION: \d+\.\d+\.\d+ \(.*\) \[.*\]/, @ui.output)
assert_match(/INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}/,
@ui.output)
assert_match(/USER INSTALLATION DIRECTORY: #{Regexp.escape Gem.user_dir}/,
@ui.output)
assert_match(/RUBYGEMS PREFIX: /, @ui.output)
assert_match(/RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}/,
@ui.output)
assert_match(/GIT EXECUTABLE: #{@cmd.send(:git_path)}/, @ui.output)
assert_match(/SYSTEM CONFIGURATION DIRECTORY:/, @ui.output)
assert_match(/EXECUTABLE DIRECTORY:/, @ui.output)
assert_match(/RUBYGEMS PLATFORMS:/, @ui.output)
assert_match(/- #{Gem::Platform.local}/, @ui.output)
assert_match(/GEM PATHS:/, @ui.output)
assert_match(/- #{Regexp.escape @gemhome}/, @ui.output)
assert_match(/GEM CONFIGURATION:/, @ui.output)
assert_match(/"gemcutter_key" => "\*\*\*\*"/, @ui.output)
assert_match(/:verbose => /, @ui.output)
assert_match(/REMOTE SOURCES:/, @ui.output)
assert_match %r{- SHELL PATH:}, @ui.output
assert_match(/- SHELL PATH:/, @ui.output)
assert_match %r{- /usr/local/bin$}, @ui.output
assert_match %r{- /usr/bin$}, @ui.output
assert_match %r{- /bin$}, @ui.output

View File

@ -56,7 +56,7 @@ class TestGemCommandsHelpCommand < Gem::TestCase
if Gem::HAVE_OPENSSL
assert_empty err
refute_match %r{No command found for }, out
refute_match(/No command found for /, out)
end
end
end

View File

@ -34,11 +34,11 @@ class TestGemCommandsInfoCommand < Gem::TestCase
end
assert_match %r{#{@gem.name} \(#{@gem.version}\)\n}, @ui.output
assert_match %r{Authors: #{@gem.authors.join(', ')}\n}, @ui.output
assert_match %r{Homepage: #{@gem.homepage}\n}, @ui.output
assert_match %r{License: #{@gem.license}\n}, @ui.output
assert_match %r{Installed at: #{@gem.base_dir}\n}, @ui.output
assert_match %r{#{@gem.summary}\n}, @ui.output
assert_match(/Authors: #{@gem.authors.join(', ')}\n/, @ui.output)
assert_match(/Homepage: #{@gem.homepage}\n/, @ui.output)
assert_match(/License: #{@gem.license}\n/, @ui.output)
assert_match(/Installed at: #{@gem.base_dir}\n/, @ui.output)
assert_match(/#{@gem.summary}\n/, @ui.output)
assert_match "", @ui.error
end

View File

@ -1067,7 +1067,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end
assert_equal 2, e.exit_code
assert_match %r{Could not find a valid gem 'a' \(= 10.0\)}, @ui.error
assert_match(/Could not find a valid gem 'a' \(= 10.0\)/, @ui.error)
end
def test_show_errors_on_failure

View File

@ -15,6 +15,6 @@ class TestGemCommandsMirrorCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Install the rubygems-mirror}i, @ui.error
assert_match(/Install the rubygems-mirror/i, @ui.error)
end
end

View File

@ -50,7 +50,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
end
end
assert_match %r{Unable to find gem 'foo'}, @ui.output
assert_match(/Unable to find gem 'foo'/, @ui.output)
assert_equal "", @ui.error
end
@ -63,7 +63,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
end
end
assert_match %r{Unable to find gem 'foo'}, @ui.output
assert_match(/Unable to find gem 'foo'/, @ui.output)
assert_equal "", @ui.error
end
@ -92,7 +92,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
end
end
assert_match %r{'foo' is a default gem and can't be opened\.}, @ui.output
assert_match(/'foo' is a default gem and can't be opened\./, @ui.output)
assert_equal "", @ui.error
end
end

View File

@ -46,11 +46,11 @@ EOF
assert_equal Net::HTTP::Get, @stub_fetcher.last_request.class
assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"]
assert_match %r{Owners for gem: freewill}, @stub_ui.output
assert_match %r{- user1@example.com}, @stub_ui.output
assert_match %r{- user2@example.com}, @stub_ui.output
assert_match %r{- user3}, @stub_ui.output
assert_match %r{- 4}, @stub_ui.output
assert_match(/Owners for gem: freewill/, @stub_ui.output)
assert_match(/- user1@example.com/, @stub_ui.output)
assert_match(/- user2@example.com/, @stub_ui.output)
assert_match(/- user3/, @stub_ui.output)
assert_match(/- 4/, @stub_ui.output)
end
def test_show_owners_dont_load_objects
@ -87,8 +87,8 @@ EOF
@cmd.show_owners("freewill")
end
assert_match %r{Owners for gem: freewill}, @stub_ui.output
assert_match %r{- user1@example.com}, @stub_ui.output
assert_match(/Owners for gem: freewill/, @stub_ui.output)
assert_match(/- user1@example.com/, @stub_ui.output)
end
def test_show_owners_setting_up_host
@ -102,8 +102,8 @@ EOF
@cmd.show_owners("freewill")
end
assert_match %r{Owners for gem: freewill}, @stub_ui.output
assert_match %r{- user1@example.com}, @stub_ui.output
assert_match(/Owners for gem: freewill/, @stub_ui.output)
assert_match(/- user1@example.com/, @stub_ui.output)
end
def test_show_owners_denied
@ -217,8 +217,8 @@ EOF
end
assert_match add_owner_response, @stub_ui.output
assert_match %r{Owners for gem: freewill}, @stub_ui.output
assert_match %r{- user1@example.com}, @stub_ui.output
assert_match(/Owners for gem: freewill/, @stub_ui.output)
assert_match(/- user1@example.com/, @stub_ui.output)
end
def test_add_owners_key

View File

@ -162,7 +162,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
bin_env = Gem.win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " "
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_exec)
assert_match(/\A#!\s*#{bin_env}#{ruby_exec}/, File.read(gem_exec))
end
def test_execute_extensions_explicit
@ -504,7 +504,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
end
end
assert_match %r{at least one gem name}, e.message
assert_match(/at least one gem name/, e.message)
end
def test_execute_only_executables

View File

@ -56,7 +56,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
@cmd.send_gem(@path)
end
assert_match %r{Pushing gem to #{@host}...}, @ui.output
assert_match(/Pushing gem to #{@host}.../, @ui.output)
assert_equal Net::HTTP::Post, @fetcher.last_request.class
assert_equal Gem.read_binary(@path), @fetcher.last_request.body
@ -315,7 +315,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
# do not set @host
use_ui(@ui) { @cmd.send_gem(@path) }
assert_match %r{Pushing gem to #{host}...}, @ui.output
assert_match(/Pushing gem to #{host}.../, @ui.output)
assert_equal Net::HTTP::Post, @fetcher.last_request.class
assert_equal Gem.read_binary(@path), @fetcher.last_request.body

View File

@ -552,8 +552,8 @@ pl (1 i386-linux)
@cmd.execute
end
assert_match %r{^a }, @stub_ui.output
assert_match %r{^pl }, @stub_ui.output
assert_match(/^a /, @stub_ui.output)
assert_match(/^pl /, @stub_ui.output)
assert_equal "", @stub_ui.error
end
@ -565,8 +565,8 @@ pl (1 i386-linux)
@cmd.send :show_gems, /a/i
end
assert_match %r{^a }, @stub_ui.output
refute_match %r{^pl }, @stub_ui.output
assert_match(/^a /, @stub_ui.output)
refute_match(/^pl /, @stub_ui.output)
assert_empty @stub_ui.error
end

View File

@ -15,6 +15,6 @@ class TestGemCommandsServerCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Install the rubygems-server}i, @ui.error
assert_match(/Install the rubygems-server/i, @ui.error)
end
end

View File

@ -69,7 +69,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.execute
assert_match %r{\A#!}, File.read(gem_bin_path)
assert_match(/\A#!/, File.read(gem_bin_path))
end
def test_execute_no_regenerate_binstubs
@ -92,7 +92,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.execute
assert_match %r{\Arequire}, File.read(gem_plugin_path)
assert_match(/\Arequire/, File.read(gem_plugin_path))
end
def test_execute_no_regenerate_plugins
@ -115,7 +115,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@cmd.execute
assert_match %r{\Arequire}, File.read(gem_plugin_path)
assert_match(/\Arequire/, File.read(gem_plugin_path))
end
def test_execute_informs_about_installed_executables
@ -143,10 +143,10 @@ class TestGemCommandsSetupCommand < Gem::TestCase
ruby_exec = sprintf Gem.default_exec_format, "ruby"
bin_env = Gem.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)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundle_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundler_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path)
assert_match(/\A#!\s*#{bin_env}#{ruby_exec}/, File.read(default_gem_bin_path))
assert_match(/\A#!\s*#{bin_env}#{ruby_exec}/, File.read(default_bundle_bin_path))
assert_match(/\A#!\s*#{bin_env}#{ruby_exec}/, File.read(default_bundler_bin_path))
assert_match(/\A#!\s*#{bin_env}#{ruby_exec}/, File.read(gem_bin_path))
end
def test_destdir_flag_does_not_try_to_write_to_the_default_gem_home

View File

@ -24,14 +24,14 @@ class TestGemCommandsSigninCommand < Gem::TestCase
def test_execute_when_not_already_signed_in
sign_in_ui = util_capture { @cmd.execute }
assert_match %r{Signed in.}, sign_in_ui.output
assert_match(/Signed in./, sign_in_ui.output)
end
def test_execute_when_not_already_signed_in_and_not_preexisting_credentials_folder
FileUtils.rm Gem.configuration.credentials_path
sign_in_ui = util_capture { @cmd.execute }
assert_match %r{Signed in.}, sign_in_ui.output
assert_match(/Signed in./, sign_in_ui.output)
end
def test_execute_when_already_signed_in_with_same_host
@ -64,8 +64,8 @@ class TestGemCommandsSigninCommand < Gem::TestCase
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
assert_match(/Enter your #{host} credentials./, sign_in_ui.output)
assert_match(/Signed in./, sign_in_ui.output)
api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
credentials = load_yaml_file Gem.configuration.credentials_path

View File

@ -17,7 +17,7 @@ class TestGemCommandsSignoutCommand < Gem::TestCase
@sign_out_ui = Gem::MockGemUi.new
use_ui(@sign_out_ui) { @cmd.execute }
assert_match %r{You have successfully signed out}, @sign_out_ui.output
assert_match(/You have successfully signed out/, @sign_out_ui.output)
assert_equal false, File.exist?(Gem.configuration.credentials_path)
end
@ -25,6 +25,6 @@ class TestGemCommandsSignoutCommand < Gem::TestCase
@sign_out_ui = Gem::MockGemUi.new
use_ui(@sign_out_ui) { @cmd.execute }
assert_match %r{You are not currently signed in}, @sign_out_ui.error
assert_match(/You are not currently signed in/, @sign_out_ui.error)
end
end

View File

@ -21,8 +21,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Gem::Specification}, @ui.output
assert_match %r{name: foo}, @ui.output
assert_match(/Gem::Specification/, @ui.output)
assert_match(/name: foo/, @ui.output)
assert_equal "", @ui.error
end
@ -37,10 +37,10 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Gem::Specification}, @ui.output
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_match(/Gem::Specification/, @ui.output)
assert_match(/name: foo/, @ui.output)
assert_match(/version: 0.0.1/, @ui.output)
assert_match(/version: 0.0.2/, @ui.output)
assert_equal "", @ui.error
end
@ -99,8 +99,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Gem::Specification}, @ui.output
assert_match %r{name: foo}, @ui.output
assert_match(/Gem::Specification/, @ui.output)
assert_match(/name: foo/, @ui.output)
assert_equal "", @ui.error
end
@ -131,8 +131,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Gem::Specification}, @ui.output
assert_match %r{name: foo}, @ui.output
assert_match(/Gem::Specification/, @ui.output)
assert_match(/name: foo/, @ui.output)
assert_equal "", @ui.error
end
@ -165,7 +165,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
end
assert_match %r{\A--- !ruby/object:Gem::Specification}, @ui.output
assert_match %r{name: foo}, @ui.output
assert_match(/name: foo/, @ui.output)
end
def test_execute_remote_with_version
@ -229,7 +229,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
end
assert_match %r{\A--- !ruby/object:Gem::Specification}, @ui.output
assert_match %r{name: foo}, @ui.output
assert_match(/name: foo/, @ui.output)
spec = load_yaml @ui.output
@ -251,7 +251,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
end
assert_match %r{\A--- !ruby/object:Gem::Specification}, @ui.output
assert_match %r{name: foo}, @ui.output
assert_match(/name: foo/, @ui.output)
spec = load_yaml @ui.output
@ -270,8 +270,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
@cmd.execute
end
assert_match %r{Gem::Specification.new}, @ui.output
assert_match %r{s.name = "foo"}, @ui.output
assert_match(/Gem::Specification.new/, @ui.output)
assert_match(/s.name = "foo"/, @ui.output)
assert_equal "", @ui.error
end
end

View File

@ -496,7 +496,7 @@ WARNING: Use your OS package manager to uninstall vendor gems
end
assert_empty @ui.output
assert_match %r{Error: unable to successfully uninstall '#{@spec.name}'}, @ui.error
assert_match(/Error: unable to successfully uninstall '#{@spec.name}'/, @ui.error)
end
private

View File

@ -33,8 +33,8 @@ class TestGemCommandsWhichCommand < Gem::TestCase
end
assert_equal "", @ui.output
assert_match %r{Can.t find Ruby library file or shared library directory\n},
@ui.error
assert_match(/Can.t find Ruby library file or shared library directory\n/,
@ui.error)
end
def test_execute_one_missing
@ -51,8 +51,8 @@ class TestGemCommandsWhichCommand < Gem::TestCase
end
assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
assert_match %r{Can.t find Ruby library file or shared library missinglib\n},
@ui.error
assert_match(/Can.t find Ruby library file or shared library missinglib\n/,
@ui.error)
end
def test_execute_missing
@ -65,8 +65,8 @@ class TestGemCommandsWhichCommand < Gem::TestCase
end
assert_equal "", @ui.output
assert_match %r{Can.t find Ruby library file or shared library missinglib\n},
@ui.error
assert_match(/Can.t find Ruby library file or shared library missinglib\n/,
@ui.error)
end
def util_foo_bar

View File

@ -55,7 +55,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
end
assert_match %r{Yanking gem from http://example}, @ui.output
assert_match %r{Successfully yanked}, @ui.output
assert_match(/Successfully yanked/, @ui.output)
platform = Gem.platforms[1]
body = @fetcher.last_request.body.split("&").sort
@ -86,7 +86,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
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_match(/Successfully yanked/, @otp_ui.output)
assert_equal "111111", @fetcher.last_request["OTP"]
end
@ -141,7 +141,7 @@ class TestGemCommandsYankCommand < Gem::TestCase
end
assert_match %r{Yanking gem from https://other.example}, @ui.output
assert_match %r{Successfully yanked}, @ui.output
assert_match(/Successfully yanked/, @ui.output)
body = @fetcher.last_request.body.split("&").sort
assert_equal %w[gem_name=a version=1.0], body

View File

@ -587,8 +587,8 @@ class TestGemDependencyInstaller < Gem::TestCase
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"))
assert_match(/\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n/,
File.read(File.join(@gemhome, "bin", "a_bin")))
end
def test_install_force
@ -904,7 +904,7 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new :wrappers => false, :format_executable => false
inst.install "a"
refute_match(%r{This file was generated by RubyGems.},
refute_match(/This file was generated by RubyGems./,
File.read(File.join(@gemhome, "bin", "a_bin")))
end
end

View File

@ -21,7 +21,7 @@ class TestGemDependencyResolutionError < Gem::TestCase
end
def test_message
assert_match %r{^conflicting dependencies a \(= 1\) and a \(= 2\)$},
@error.message
assert_match(/^conflicting dependencies a \(= 1\) and a \(= 2\)$/,
@error.message)
end
end

View File

@ -48,14 +48,14 @@ install:
results = results.join("\n").b
assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} clean$}, results
assert_match %r{DESTDIR\\=#{ENV['DESTDIR']}$}, results
assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} install$}, results
assert_match(/DESTDIR\\=#{ENV['DESTDIR']} clean$/, results)
assert_match(/DESTDIR\\=#{ENV['DESTDIR']}$/, results)
assert_match(/DESTDIR\\=#{ENV['DESTDIR']} install$/, results)
unless /nmake/.match?(results)
assert_match %r{^clean: destination$}, results
assert_match %r{^all: destination$}, results
assert_match %r{^install: destination$}, results
assert_match(/^clean: destination$/, results)
assert_match(/^all: destination$/, results)
assert_match(/^install: destination$/, results)
end
end
@ -77,9 +77,9 @@ install:
results = results.join("\n").b
assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} clean$}, results
assert_match %r{DESTDIR\\=#{ENV['DESTDIR']}$}, results
assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} install$}, results
assert_match(/DESTDIR\\=#{ENV['DESTDIR']} clean$/, results)
assert_match(/DESTDIR\\=#{ENV['DESTDIR']}$/, results)
assert_match(/DESTDIR\\=#{ENV['DESTDIR']} install$/, results)
end
def test_custom_make_with_options
@ -99,9 +99,9 @@ install:
end
Gem::Ext::Builder.make @dest_path, results, @ext
results = results.join("\n").b
assert_match %r{clean: OK}, results
assert_match %r{all: OK}, results
assert_match %r{install: OK}, results
assert_match(/clean: OK/, results)
assert_match(/all: OK/, results)
assert_match(/install: OK/, results)
end
def test_build_extensions
@ -251,7 +251,7 @@ install:
cmd_make_out = File.read(gem_make_out)
assert_match %r{#{Regexp.escape Gem.ruby} .* extconf\.rb}, cmd_make_out
assert_match %r{: No such file}, cmd_make_out
assert_match(/: No such file/, cmd_make_out)
assert_path_not_exist @spec.gem_build_complete_path

View File

@ -43,11 +43,11 @@ install (FILES test.txt DESTINATION bin)
output = output.join "\n"
assert_match %r{^cmake \. -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output
assert_match %r{#{Regexp.escape @ext}}, output
assert_match(/^cmake \. -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}/, output)
assert_match(/#{Regexp.escape @ext}/, output)
assert_contains_make_command "", output
assert_contains_make_command "install", output
assert_match %r{test\.txt}, output
assert_match(/test\.txt/, output)
end
def test_self_build_fail
@ -59,12 +59,12 @@ install (FILES test.txt DESTINATION bin)
output = output.join "\n"
shell_error_msg = %r{(CMake Error: .*)}
shell_error_msg = /(CMake Error: .*)/
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
assert_match(/^cmake . -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}/, output)
assert_match(/#{shell_error_msg}/, output)
end
def test_self_build_has_makefile

View File

@ -57,7 +57,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase
assert_match(/^current directory:/, output.shift)
assert_equal "#{sh_prefix_configure}#{@dest_path}", output.shift
assert_match %r{#{shell_error_msg}}, output.shift
assert_match(/#{shell_error_msg}/, output.shift)
assert_equal true, output.empty?
end

View File

@ -23,9 +23,9 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = output.join "\n"
refute_match %r{^rake failed:}, output
assert_match %r{^#{Regexp.escape Gem.ruby} mkrf_conf\.rb}, output
assert_match %r{^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path}}, output
refute_match(/^rake failed:/, output)
assert_match(/^#{Regexp.escape Gem.ruby} mkrf_conf\.rb/, output)
assert_match(/^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path}/, output)
end
end
@ -42,9 +42,9 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = output.join "\n"
refute_match %r{^rake failed:}, output
assert_match %r{^#{Regexp.escape Gem.ruby} mkrf_conf\.rb}, output
assert_match %r{^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path}}, output
refute_match(/^rake failed:/, output)
assert_match(/^#{Regexp.escape Gem.ruby} mkrf_conf\.rb/, output)
assert_match(/^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path}/, output)
end
end
@ -72,7 +72,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = output.join "\n"
assert_match "OpenSSL", output
assert_match %r{^#{Regexp.escape Gem.ruby} mkrf_conf\.rb}, output
assert_match(/^#{Regexp.escape Gem.ruby} mkrf_conf\.rb/, output)
end
def test_class_build_no_mkrf_passes_args
@ -83,8 +83,8 @@ class TestGemExtRakeBuilder < Gem::TestCase
output = output.join "\n"
refute_match %r{^rake failed:}, output
assert_match %r{^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path} test1 test2}, output
refute_match(/^rake failed:/, output)
assert_match(/^#{Regexp.escape rake} RUBYARCHDIR\\=#{Regexp.escape @dest_path} RUBYLIBDIR\\=#{Regexp.escape @dest_path} test1 test2/, output)
end
end
@ -97,7 +97,7 @@ class TestGemExtRakeBuilder < Gem::TestCase
Gem::Ext::RakeBuilder.build "mkrf_conf.rb", @dest_path, output, [], nil, @ext
end
assert_match %r{^rake failed}, error.message
assert_match(/^rake failed/, error.message)
end
end

View File

@ -96,9 +96,9 @@ class TestGemGemcutterUtilities < Gem::TestCase
api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
assert_match(/Enter your RubyGems.org credentials./, @sign_in_ui.output)
assert @fetcher.last_request["authorization"]
assert_match %r{Signed in.}, @sign_in_ui.output
assert_match(/Signed in./, @sign_in_ui.output)
credentials = load_yaml_file Gem.configuration.credentials_path
assert_equal api_key, credentials[:rubygems_api_key]
@ -112,7 +112,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match "Enter your http://example.com credentials.",
@sign_in_ui.output
assert @fetcher.last_request["authorization"]
assert_match %r{Signed in.}, @sign_in_ui.output
assert_match(/Signed in./, @sign_in_ui.output)
credentials = load_yaml_file Gem.configuration.credentials_path
assert_equal api_key, credentials["http://example.com"]
@ -126,7 +126,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match "Enter your RubyGems.org credentials.",
@sign_in_ui.output
assert @fetcher.last_request["authorization"]
assert_match %r{Signed in.}, @sign_in_ui.output
assert_match(/Signed in./, @sign_in_ui.output)
credentials = load_yaml_file Gem.configuration.credentials_path
assert_equal api_key, credentials[:rubygems_api_key]
@ -139,7 +139,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match "Enter your http://example.com credentials.",
@sign_in_ui.output
assert @fetcher.last_request["authorization"]
assert_match %r{Signed in.}, @sign_in_ui.output
assert_match(/Signed in./, @sign_in_ui.output)
credentials = load_yaml_file Gem.configuration.credentials_path
assert_equal api_key, credentials["http://example.com"]
@ -172,8 +172,8 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
util_sign_in HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
assert_match %r{Signed in.}, @sign_in_ui.output
assert_match(/Enter your RubyGems.org credentials./, @sign_in_ui.output)
assert_match(/Signed in./, @sign_in_ui.output)
credentials = load_yaml_file Gem.configuration.credentials_path
assert_equal api_key, credentials[:rubygems_api_key]
@ -185,8 +185,8 @@ class TestGemGemcutterUtilities < Gem::TestCase
util_sign_in HTTPResponseFactory.create(body: "Access Denied.", code: 403, msg: "Forbidden")
end
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
assert_match %r{Access Denied.}, @sign_in_ui.output
assert_match(/Enter your RubyGems.org credentials./, @sign_in_ui.output)
assert_match(/Access Denied./, @sign_in_ui.output)
end
def test_signin_with_env_otp_code

View File

@ -49,7 +49,7 @@ class TestGemIndexer < Gem::TestCase
def test_initialize
assert_equal @indexerdir, @indexer.dest_directory
Dir.mktmpdir("gem_generate_index") do |tmpdir|
assert_match %r{#{tmpdir.match(/.*-/)}}, @indexer.directory
assert_match(%r{#{tmpdir.match(/.*-/)}}, @indexer.directory) # rubocop:disable Style/RegexpLiteral
end
with_indexer(@indexerdir) do |indexer|
@ -206,15 +206,14 @@ class TestGemIndexer < Gem::TestCase
@indexer.generate_index
end
assert_match %r{^\.\.\.\.\.\.\.\.\.\.\.\.$}, @ui.output
assert_match %r{^Generating Marshal quick index gemspecs for 12 gems$},
@ui.output
assert_match %r{^Complete$}, @ui.output
assert_match %r{^Generating specs index$}, @ui.output
assert_match %r{^Generating latest specs index$}, @ui.output
assert_match %r{^Generating prerelease specs index$}, @ui.output
assert_match %r{^Complete$}, @ui.output
assert_match %r{^Compressing indices$}, @ui.output
assert_match(/^\.\.\.\.\.\.\.\.\.\.\.\.$/, @ui.output)
assert_match(/^Generating Marshal quick index gemspecs for 12 gems$/, @ui.output)
assert_match(/^Complete$/, @ui.output)
assert_match(/^Generating specs index$/, @ui.output)
assert_match(/^Generating latest specs index$/, @ui.output)
assert_match(/^Generating prerelease specs index$/, @ui.output)
assert_match(/^Complete$/, @ui.output)
assert_match(/^Compressing indices$/, @ui.output)
assert_equal "", @ui.error
end

View File

@ -84,7 +84,7 @@ end
assert_path_exist installed_exec
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end
def test_check_executable_overwrite_default_bin_dir
@ -100,8 +100,8 @@ end
end
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
assert_match(/\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z/,
e.message)
end
end
end
@ -142,7 +142,7 @@ gem 'other', version
assert_path_exist installed_exec
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
ensure
Gem::Installer.exec_format = nil
end
@ -177,7 +177,7 @@ gem 'other', version
assert_path_exist installed_exec
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end
def test_check_executable_overwrite_other_non_gem
@ -192,7 +192,7 @@ gem 'other', version
assert_path_exist installed_exec
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end unless Gem.win_platform?
def test_check_that_user_bin_dir_is_in_path
@ -338,7 +338,7 @@ gem 'other', version
assert_equal mask, File.stat(installed_exec).mode unless Gem.win_platform?
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end
def test_generate_bin_bindir_with_user_install_warning
@ -383,7 +383,7 @@ gem 'other', version
assert_equal mask, File.stat(installed_exec).mode unless Gem.win_platform?
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end
def test_generate_bin_script_format
@ -442,7 +442,7 @@ gem 'other', version
assert_equal mask, File.stat(installed_exec).mode unless Gem.win_platform?
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end
def test_generate_bin_script_no_execs
@ -499,7 +499,7 @@ gem 'other', version
assert_equal mask, File.stat(installed_exec).mode unless Gem.win_platform?
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
# HACK: some gems don't have #! in their executables, restore 2008/06
# assert_no_match %r|generated by RubyGems|, wrapper
end
@ -525,10 +525,10 @@ gem 'other', version
assert_path_exist installed_exec
assert_equal mask, File.stat(installed_exec).mode unless Gem.win_platform?
assert_match %r{generated by RubyGems}, File.read(installed_exec)
assert_match(/generated by RubyGems/, File.read(installed_exec))
refute_match %r{generated by RubyGems}, File.read(real_exec),
"real executable overwritten"
refute_match(/generated by RubyGems/, File.read(real_exec),
"real executable overwritten")
end
def test_generate_bin_symlink
@ -1338,7 +1338,7 @@ gem 'other', version
installer.install
end
assert_match %r{I am a shiny gem!}, @ui.output
assert_match(/I am a shiny gem!/, @ui.output)
end
def test_install_with_skipped_message
@ -1352,7 +1352,7 @@ gem 'other', version
installer.install
end
refute_match %r{I am a shiny gem!}, @ui.output
refute_match(/I am a shiny gem!/, @ui.output)
end
def test_install_extension_dir
@ -2342,10 +2342,10 @@ gem 'other', version
wrapper = File.read installed_exec
if symlink_supported?
refute_match %r{generated by RubyGems}, wrapper
refute_match(/generated by RubyGems/, wrapper)
else # when symlink not supported, it warns and fallbacks back to installing wrapper
assert_match %r{Unable to use symlinks, installing wrapper}, @ui.error
assert_match %r{generated by RubyGems}, wrapper
assert_match(/Unable to use symlinks, installing wrapper/, @ui.error)
assert_match(/generated by RubyGems/, wrapper)
end
end
@ -2366,7 +2366,7 @@ gem 'other', version
assert_path_exist installed_exec
wrapper = File.read installed_exec
assert_match %r{generated by RubyGems}, wrapper
assert_match(/generated by RubyGems/, wrapper)
end
def test_default_gem_with_exe_as_bindir

View File

@ -965,8 +965,8 @@ class TestGemPackage < Gem::Package::TarTestCase
package.verify
end
assert_match %r{^No such file or directory}, e.message
assert_match %r{nonexistent.gem$}, e.message
assert_match(/^No such file or directory/, e.message)
assert_match(/nonexistent.gem$/, e.message)
end
def test_verify_duplicate_file

View File

@ -538,8 +538,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
fetcher.fetch_path url
end
assert_match %r{ECONNREFUSED:.*connect\(2\) \(#{Regexp.escape url}\)\z},
e.message
assert_match(/ECONNREFUSED:.*connect\(2\) \(#{Regexp.escape url}\)\z/,
e.message)
assert_equal url, e.uri
end
@ -557,8 +557,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
fetcher.fetch_path url
end
assert_match %r{Timeout::Error: timed out \(#{Regexp.escape url}\)\z},
e.message
assert_match(/Timeout::Error: timed out \(#{Regexp.escape url}\)\z/,
e.message)
assert_equal url, e.uri
end
@ -576,8 +576,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
fetcher.fetch_path url
end
assert_match %r{SocketError: getaddrinfo: nodename nor servname provided \(#{Regexp.escape url}\)\z},
e.message
assert_match(/SocketError: getaddrinfo: nodename nor servname provided \(#{Regexp.escape url}\)\z/,
e.message)
assert_equal url, e.uri
end

View File

@ -281,7 +281,7 @@ class TestGemRequest < Gem::TestCase
assert_match %r{RubyGems/#{Regexp.escape Gem::VERSION}}, ua
assert_match %r{ #{Regexp.escape Gem::Platform.local.to_s} }, ua
assert_match %r{Ruby/#{Regexp.escape RUBY_VERSION}}, ua
assert_match %r{\(#{Regexp.escape RUBY_RELEASE_DATE} }, ua
assert_match(/\(#{Regexp.escape RUBY_RELEASE_DATE} /, ua)
end
def test_user_agent_engine
@ -292,7 +292,7 @@ class TestGemRequest < Gem::TestCase
ua = make_request(@uri, nil, nil, nil).user_agent
assert_match %r{\) vroom}, ua
assert_match(/\) vroom/, ua)
ensure
util_restore_version
end
@ -305,7 +305,7 @@ class TestGemRequest < Gem::TestCase
ua = make_request(@uri, nil, nil, nil).user_agent
assert_match %r{\)}, ua
assert_match(/\)/, ua)
ensure
util_restore_version
end

View File

@ -1840,7 +1840,7 @@ dependencies: []
end
def test_full_gem_path_double_slash
gemhome = @gemhome.to_s.sub(/\w\//, '\&/')
gemhome = @gemhome.to_s.sub(%r{\w/}, '\&/')
@a1.loaded_from = File.join gemhome, "specifications", @a1.spec_name
expected = File.join @gemhome, "gems", @a1.full_name
@ -2445,7 +2445,7 @@ end
ruby = @a2.to_ruby
assert_match %r%^ s\.metadata = \{ "%, ruby
assert_match(/^ s\.metadata = \{ "/, ruby)
end
def test_to_ruby_platform
@ -2462,7 +2462,7 @@ end
def test_to_yaml
yaml_str = @a1.to_yaml
refute_match %r{!!null}, yaml_str
refute_match(/!!null/, yaml_str)
same_spec = Gem::Specification.from_yaml(yaml_str)
@ -2483,7 +2483,7 @@ end
def test_to_yaml_platform_empty_string
@a1.instance_variable_set :@original_platform, ""
assert_match %r{^platform: ruby$}, @a1.to_yaml
assert_match(/^platform: ruby$/, @a1.to_yaml)
end
def test_to_yaml_platform_legacy
@ -2501,7 +2501,7 @@ end
def test_to_yaml_platform_nil
@a1.instance_variable_set :@original_platform, nil
assert_match %r{^platform: ruby$}, @a1.to_yaml
assert_match(/^platform: ruby$/, @a1.to_yaml)
end
def test_validate
@ -3306,7 +3306,7 @@ Did you mean 'Ruby'?
spec.validate
end
assert_match %r{^#{name}}, e.message
assert_match(/^#{name}/, e.message)
end
end
end

View File

@ -467,12 +467,12 @@ create_makefile '#{@spec.name}'
lines = ui.output.split("\n")
lines.shift
assert_match %r{You have requested to uninstall the gem:}, lines.shift
assert_match(/You have requested to uninstall the gem:/, lines.shift)
lines.shift
lines.shift
assert_match %r{r-1 depends on q \(= 1\)}, lines.shift
assert_match %r{Successfully uninstalled q-1}, lines.last
assert_match(/r-1 depends on q \(= 1\)/, lines.shift)
assert_match(/Successfully uninstalled q-1/, lines.last)
end
def test_uninstall_only_lists_unsatisfied_deps
@ -497,12 +497,12 @@ create_makefile '#{@spec.name}'
lines = ui.output.split("\n")
lines.shift
assert_match %r{You have requested to uninstall the gem:}, lines.shift
assert_match(/You have requested to uninstall the gem:/, lines.shift)
lines.shift
lines.shift
assert_match %r{x-1 depends on q \(= 1.0\)}, lines.shift
assert_match %r{Successfully uninstalled q-1.0}, lines.last
assert_match(/x-1 depends on q \(= 1.0\)/, lines.shift)
assert_match(/Successfully uninstalled q-1.0/, lines.last)
end
def test_uninstall_doesnt_prompt_when_other_gem_satisfies_requirement
@ -578,12 +578,12 @@ create_makefile '#{@spec.name}'
lines = ui.output.split("\n")
lines.shift
assert_match %r{You have requested to uninstall the gem:}, lines.shift
assert_match(/You have requested to uninstall the gem:/, lines.shift)
lines.shift
lines.shift
assert_match %r{r-1 depends on q \(= 1, development\)}, lines.shift
assert_match %r{Successfully uninstalled q-1}, lines.last
assert_match(/r-1 depends on q \(= 1, development\)/, lines.shift)
assert_match(/Successfully uninstalled q-1/, lines.last)
end
def test_uninstall_prompt_only_lists_the_dependents_that_prevented_uninstallation
@ -607,12 +607,12 @@ create_makefile '#{@spec.name}'
lines = ui.output.split("\n")
lines.shift
assert_match %r{You have requested to uninstall the gem:}, lines.shift
assert_match(/You have requested to uninstall the gem:/, lines.shift)
lines.shift
lines.shift
assert_match %r{s-1 depends on q \(= 1\)}, lines.shift
assert_match %r{Successfully uninstalled q-1}, lines.last
assert_match(/s-1 depends on q \(= 1\)/, lines.shift)
assert_match(/Successfully uninstalled q-1/, lines.last)
end
def test_uninstall_no_permission

View File

@ -5,7 +5,7 @@ require_relative "helper"
class TestGemRemoteFetchError < Gem::TestCase
def test_password_redacted
error = Gem::RemoteFetcher::FetchError.new("There was an error fetching", "https://user:secret@gemsource.org")
refute_match %r{secret}, error.to_s
refute_match(/secret/, error.to_s)
end
def test_invalid_url