diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2022-07-17 08:08:51 +0000 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-07-22 12:07:23 +0900 |
commit | d7ffd3fea402239b16833cc434404a7af82d44f3 (patch) | |
tree | 9794942135111c36e6b6bce69e070ca556b89028 /test/rubygems/test_gem_command.rb | |
parent | 388c4e1076ac5a58d5008abc8e0a8d017698875a (diff) | |
download | ruby-d7ffd3fea402239b16833cc434404a7af82d44f3.tar.gz |
RubyGems: Enable Style/StringLiterals cop
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
Diffstat (limited to 'test/rubygems/test_gem_command.rb')
-rw-r--r-- | test/rubygems/test_gem_command.rb | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb index 65b9b040b7..99fa89364d 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 @@ class TestGemCommand < Gem::TestCase @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 @@ class TestGemCommand < Gem::TestCase 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 @@ class TestGemCommand < Gem::TestCase 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 @@ class TestGemCommand < Gem::TestCase @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 @@ class TestGemCommand < Gem::TestCase 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 @@ class TestGemCommand < Gem::TestCase 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 @@ class TestGemCommand < Gem::TestCase end use_ui @ui do - @cmd.invoke '-h' + @cmd.invoke "-h" end assert_match %r{Usage: gem doit}, @ui.output @@ -191,40 +191,40 @@ class TestGemCommand < Gem::TestCase 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 @@ WARNING: The \"--test\" option has been deprecated and will be removed in Rubyg 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 @@ WARNING: The \"--test\" option has been deprecated and will be removed in futur 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 @@ WARNING: The \"--test\" option has been deprecated and will be removed in Rubyg 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 @@ WARNING: The \"--test\" option has been deprecated and will be removed in futur 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 @@ ERROR: Could not find a valid gem 'nonexistent_with_hint' (>= 0) in any reposit 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 |