From 0b4c186cc98d993b647c98dd713a5b2df8963de5 Mon Sep 17 00:00:00 2001 From: John Mair Date: Tue, 14 Jun 2011 00:51:09 +1200 Subject: [PATCH] added tests for negative line number support in amend-line --- test/test_default_commands/test_input.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test_default_commands/test_input.rb b/test/test_default_commands/test_input.rb index 2ed78b7f..ba0dd23e 100644 --- a/test/test_default_commands/test_input.rb +++ b/test/test_default_commands/test_input.rb @@ -19,6 +19,28 @@ describe "Pry::DefaultCommands::Input" do str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/ end + it 'should correctly amend the specified line of input when line number given (negative number)' do + str_output = StringIO.new + redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -1 puts :bink", "show-input", "exit-all"), str_output) do + pry + end + str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts :bink/ + + str_output = StringIO.new + redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -2 puts :bink", "show-input", "exit-all"), str_output) do + pry + end + str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :bang/ + end + + it 'should correctly amend the specified range of lines of input when range of negative numbers given (negative number)' do + str_output = StringIO.new + redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boat", "amend-line -3..-2 puts :bink", "show-input", "exit-all"), str_output) do + pry + end + str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :boat/ + end + it 'should correctly amend the specified line with string interpolated text' do str_output = StringIO.new redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", 'amend-line puts "#{goodbye}"', "show-input", "exit-all"), str_output) do