From 9a245adb04d9dcfb0d0475931e187b38f9bcf099 Mon Sep 17 00:00:00 2001 From: John Mair Date: Fri, 3 Jun 2011 21:55:23 +1200 Subject: [PATCH] added tests for show-input and \! commands --- 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 6831563e..3a20162b 100644 --- a/test/test_default_commands/test_input.rb +++ b/test/test_default_commands/test_input.rb @@ -20,6 +20,28 @@ describe "Pry::DefaultCommands::Input" do end end + describe "show-input" do + it 'should correctly show the current lines in the input buffer' do + str_output = StringIO.new + redirect_pry_io(InputTester.new("def hello", "puts :bing", "show-input", "exit-all"), str_output) do + pry + end + str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing/ + end + end + + describe "!" do + it 'should correctly clear the input buffer ' do + str_output = StringIO.new + redirect_pry_io(InputTester.new("def hello", "puts :bing", "!", "show-input", "exit-all"), str_output) do + pry + end + stripped_output = str_output.string.strip! + stripped_output.each_line.count.should == 1 + stripped_output.should =~ /Input buffer cleared!/ + end + end + describe "hist" do push_first_hist_line = lambda do |hist, line| hist.push line