[ruby/irb] Print deprecation message for prompt_n methods

(https://github.com/ruby/irb/pull/691)

They were removed in #685, but we should still keep them to avoid breaking
changes to tools like Chef.

533ff08947/lib/chef/shell.rb (L138)

https://github.com/ruby/irb/commit/b585e0c835
This commit is contained in:
Stan Lo 2023-08-23 16:37:16 +01:00 committed by Hiroshi SHIBATA
parent 0cd92819c9
commit 221c2d0e19
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
2 changed files with 25 additions and 0 deletions

View File

@ -229,6 +229,19 @@ module IRB
#
# See IRB@Customizing+the+IRB+Prompt for more information.
attr_accessor :prompt_c
# TODO: Remove this when developing v2.0
def prompt_n
warn "IRB::Context#prompt_n is deprecated and will be removed in the next major release."
""
end
# TODO: Remove this when developing v2.0
def prompt_n=(_)
warn "IRB::Context#prompt_n= is deprecated and will be removed in the next major release."
""
end
# Can be either the default <code>IRB.conf[:AUTO_INDENT]</code>, or the
# mode set by #prompt_mode=
#

View File

@ -90,6 +90,18 @@ module TestIRB
], out)
end
def test_prompt_n_deprecation
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new))
out, err = capture_output do
irb.context.prompt_n = "foo"
irb.context.prompt_n
end
assert_include err, "IRB::Context#prompt_n is deprecated"
assert_include err, "IRB::Context#prompt_n= is deprecated"
end
def test_output_to_pipe
require 'stringio'
input = TestInputMethod.new(["n=1"])