aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_command.rb')
-rw-r--r--test/rubygems/test_gem_command.rb47
1 files changed, 38 insertions, 9 deletions
diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb
index d51371301e..230baa5356 100644
--- a/test/rubygems/test_gem_command.rb
+++ b/test/rubygems/test_gem_command.rb
@@ -197,9 +197,9 @@ class TestGemCommand < Gem::TestCase
assert_equal ['-h', 'command'], args
end
- def test_deprecate_option_long_name
+ def test_deprecate_option
deprecate_msg = <<-EXPECTED
-WARNING: The \"--test\" option has been deprecated and will be removed in Rubygems 3.1, its use is discouraged.
+WARNING: The \"--test\" option has been deprecated and will be removed in Rubygems 3.1.
EXPECTED
testCommand = Class.new(Gem::Command) do
@@ -210,7 +210,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in Rubyg
options[:test] = true
end
- deprecate_option(long_name: '--test', version: '3.1')
+ deprecate_option('--test', version: '3.1')
end
def execute
@@ -228,7 +228,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in Rubyg
def test_deprecate_option_no_version
deprecate_msg = <<-EXPECTED
-WARNING: The \"--test\" option has been deprecated and will be removed in future versions of Rubygems, its use is discouraged.
+WARNING: The \"--test\" option has been deprecated and will be removed in future versions of Rubygems.
EXPECTED
testCommand = Class.new(Gem::Command) do
@@ -239,7 +239,7 @@ WARNING: The \"--test\" option has been deprecated and will be removed in futur
options[:test] = true
end
- deprecate_option(long_name: '--test')
+ deprecate_option('--test')
end
def execute
@@ -255,9 +255,9 @@ WARNING: The \"--test\" option has been deprecated and will be removed in futur
end
end
- def test_deprecate_option_short_name
+ def test_deprecate_option_extra_message
deprecate_msg = <<-EXPECTED
-WARNING: The \"-t\" option has been deprecated and will be removed in Rubygems 3.5, its use is discouraged.
+WARNING: The \"--test\" option has been deprecated and will be removed in Rubygems 3.1. Whether you set `--test` mode or not, this dummy app always runs in test mode.
EXPECTED
testCommand = Class.new(Gem::Command) do
@@ -268,7 +268,7 @@ WARNING: The \"-t\" option has been deprecated and will be removed in Rubygems
options[:test] = true
end
- deprecate_option(short_name: '-t', version: '3.5')
+ 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
@@ -279,7 +279,36 @@ WARNING: The \"-t\" option has been deprecated and will be removed in Rubygems
cmd = testCommand.new
use_ui @ui do
- cmd.invoke("-t")
+ cmd.invoke("--test")
+ assert_equal deprecate_msg, @ui.error
+ end
+ end
+
+ def test_deprecate_option_extra_message_and_no_version
+ deprecate_msg = <<-EXPECTED
+WARNING: The \"--test\" option has been deprecated and will be removed in future versions of Rubygems. Whether you set `--test` mode or not, this dummy app always runs in test mode.
+ EXPECTED
+
+ testCommand = Class.new(Gem::Command) do
+ def initialize
+ super('test', 'Gem::Command instance for testing')
+
+ 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.')
+ end
+
+ def execute
+ true
+ end
+ end
+
+ cmd = testCommand.new
+
+ use_ui @ui do
+ cmd.invoke("--test")
assert_equal deprecate_msg, @ui.error
end
end