Permalink
Browse files

Rearrange command tests to match command file layout

  • Loading branch information...
1 parent 6d147a6 commit 735e057e1e4964d0e479b81647a67b5bccacc415 @rf- rf- committed Sep 15, 2012
Showing with 1,757 additions and 1,747 deletions.
  1. +2 −0 Guardfile
  2. 0 test/{test_default_commands → test_commands}/example.erb
  3. +248 −0 test/test_commands/test_amend_line.rb
  4. +19 −0 test/test_commands/test_bang.rb
  5. +155 −0 test/test_commands/test_cat.rb
  6. +1 −1 test/{test_default_commands → test_commands}/test_cd.rb
  7. +299 −0 test/test_commands/test_edit.rb
  8. +210 −0 test/test_commands/test_edit_method.rb
  9. +34 −0 test/test_commands/test_exit.rb
  10. +34 −0 test/test_commands/test_exit_all.rb
  11. +19 −0 test/test_commands/test_exit_program.rb
  12. 0 test/{test_default_commands → test_commands}/test_find_method.rb
  13. +26 −0 test/test_commands/test_gem_list.rb
  14. +1 −1 test/{test_default_commands → test_commands}/test_help.rb
  15. +181 −0 test/test_commands/test_hist.rb
  16. +15 −0 test/test_commands/test_jump_to.rb
  17. 0 test/{test_default_commands → test_commands}/test_ls.rb
  18. +113 −0 test/test_commands/test_play.rb
  19. +56 −0 test/test_commands/test_raise_up.rb
  20. +157 −0 test/test_commands/test_save_file.rb
  21. +40 −42 test/{test_default_commands/test_documentation.rb → test_commands/test_show_doc.rb}
  22. +17 −0 test/test_commands/test_show_input.rb
  23. +0 −1 test/{test_default_commands → test_commands}/test_show_source.rb
  24. +130 −0 test/test_commands/test_whereami.rb
  25. +0 −287 test/test_default_commands/test_context.rb
  26. +0 −30 test/test_default_commands/test_gems.rb
  27. +0 −563 test/test_default_commands/test_input.rb
  28. +0 −510 test/test_default_commands/test_introspection.rb
  29. +0 −312 test/test_default_commands/test_shell.rb
View
@@ -36,6 +36,8 @@ guard 'bacon' do
# Example of mapping a lib file to one or more test files
watch('lib/pry/indent.rb') { 'test/test_indent.rb' }
+ watch(%r{^lib/pry/commands/([^.]+)\.rb}) { |m| "test/test_commands/test_#{m[1]}.rb" }
+
# If no such mapping exists, just run all of them
watch(%r{^lib/}) { :all }
@@ -0,0 +1,248 @@
+require 'helper'
+
+describe "amend-line" do
+ before do
+ @t = pry_tester
+ end
+
+ it 'should amend the last line of input when no line number specified' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ STR
+
+ @t.process_command 'amend-line puts :blah', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :blah
+ STR
+ end
+
+ it 'should amend the specified line of input when line number given' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ STR
+
+ @t.process_command 'amend-line 1 def goodbye', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def goodbye
+ puts :bing
+ puts :bang
+ STR
+ end
+
+ it 'should amend the first line of input when 0 given as line number' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ STR
+
+ @t.process_command 'amend-line 0 def goodbye', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def goodbye
+ puts :bing
+ puts :bang
+ STR
+ end
+
+ it 'should amend a specified line when negative number given' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ STR
+
+ @t.process_command 'amend-line -1 puts :bink', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bink
+ STR
+
+ @t.process_command 'amend-line -2 puts :bink', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bink
+ puts :bink
+ STR
+ end
+
+ it 'should amend a range of lines of input when negative numbers given' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :boat
+ STR
+
+ @t.process_command 'amend-line -3..-2 puts :bink', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bink
+ puts :boat
+ STR
+ end
+
+ it 'should correctly amend the specified line with interpolated text' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ STR
+
+ @t.process_command 'amend-line puts "#{goodbye}"', eval_str
+
+ eval_str.should == unindent(<<-'STR')
+ def hello
+ puts :bing
+ puts "#{goodbye}"
+ STR
+ end
+
+ it 'should display error if nothing to amend' do
+ error = nil
+
+ begin
+ @t.process_command 'amend-line'
+ rescue Pry::CommandError => e
+ error = e
+ end
+
+ error.should.not.be.nil
+ error.message.should =~ /No input to amend/
+ end
+
+ it 'should correctly amend the specified range of lines' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :heart
+ STR
+
+ @t.process_command 'amend-line 2..3 puts :bong', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bong
+ puts :heart
+ STR
+ end
+
+ it 'should correctly delete a specific line using the ! for content' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :boast
+ puts :heart
+ STR
+
+ @t.process_command 'amend-line 3 !', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :boast
+ puts :heart
+ STR
+ end
+
+ it 'should correctly delete a range of lines using the ! for content' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :boast
+ puts :heart
+ STR
+
+ @t.process_command 'amend-line 2..4 !', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :heart
+ STR
+ end
+
+ it 'should correctly delete the previous line using the ! for content' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :boast
+ puts :heart
+ STR
+
+ @t.process_command 'amend-line !', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :boast
+ STR
+ end
+
+ it 'should amend the specified range of lines, with numbers < 0 in range' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ puts :boast
+ puts :heart
+ STR
+
+ @t.process_command 'amend-line 2..-2 puts :bong', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :bong
+ puts :heart
+ STR
+ end
+
+ it 'should correctly insert a line before a specified line using >' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ STR
+
+ @t.process_command 'amend-line 2 > puts :inserted', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :inserted
+ puts :bing
+ puts :bang
+ STR
+ end
+
+ it 'should ignore second value of range with > syntax' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ puts :bang
+ STR
+
+ @t.process_command 'amend-line 2..21 > puts :inserted', eval_str
+
+ eval_str.should == unindent(<<-STR)
+ def hello
+ puts :inserted
+ puts :bing
+ puts :bang
+ STR
+ end
+end
+
@@ -0,0 +1,19 @@
+require 'helper'
+
+describe "!" do
+ before do
+ @t = pry_tester
+ end
+
+ it 'should correctly clear the input buffer ' do
+ eval_str = unindent(<<-STR)
+ def hello
+ puts :bing
+ STR
+
+ @t.process_command '!', eval_str
+ @t.last_output.should =~ /Input buffer cleared!/
+
+ eval_str.should == ''
+ end
+end
Oops, something went wrong.

0 comments on commit 735e057

Please sign in to comment.