Skip to content

Commit

Permalink
Print deprecation message for prompt_n methods
Browse files Browse the repository at this point in the history
They were removed in #685, but we should still keep them to avoid breaking
changes to tools like Chef.

https://github.com/chef/chef/blob/533ff089479763f29045e4e6ddf388b73fc99338/lib/chef/shell.rb#L138
  • Loading branch information
st0012 committed Aug 22, 2023
1 parent 2ce7593 commit 7eb3fe8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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

0 comments on commit 7eb3fe8

Please sign in to comment.