Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print deprecation message for prompt_n methods #691

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,19 @@ def main
#
# 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=
#
Expand Down
12 changes: 12 additions & 0 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ def test_eval_input_raise2x
], 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"])
Expand Down