pry 0.9.12.2 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1141 -0
  3. data/LICENSE +2 -2
  4. data/README.md +466 -0
  5. data/bin/pry +4 -7
  6. data/lib/pry/basic_object.rb +10 -0
  7. data/lib/pry/block_command.rb +22 -0
  8. data/lib/pry/class_command.rb +194 -0
  9. data/lib/pry/cli.rb +97 -92
  10. data/lib/pry/code/code_file.rb +114 -0
  11. data/lib/pry/code/code_range.rb +7 -4
  12. data/lib/pry/code/loc.rb +27 -14
  13. data/lib/pry/code.rb +62 -90
  14. data/lib/pry/code_object.rb +83 -39
  15. data/lib/pry/color_printer.rb +66 -0
  16. data/lib/pry/command.rb +202 -371
  17. data/lib/pry/command_set.rb +151 -133
  18. data/lib/pry/command_state.rb +31 -0
  19. data/lib/pry/commands/amend_line.rb +86 -82
  20. data/lib/pry/commands/bang.rb +18 -14
  21. data/lib/pry/commands/bang_pry.rb +15 -11
  22. data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
  23. data/lib/pry/commands/cat/exception_formatter.rb +85 -73
  24. data/lib/pry/commands/cat/file_formatter.rb +56 -63
  25. data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
  26. data/lib/pry/commands/cat.rb +64 -47
  27. data/lib/pry/commands/cd.rb +42 -26
  28. data/lib/pry/commands/change_inspector.rb +34 -0
  29. data/lib/pry/commands/change_prompt.rb +51 -0
  30. data/lib/pry/commands/clear_screen.rb +20 -0
  31. data/lib/pry/commands/code_collector.rb +148 -131
  32. data/lib/pry/commands/disable_pry.rb +23 -19
  33. data/lib/pry/commands/easter_eggs.rb +23 -34
  34. data/lib/pry/commands/edit/exception_patcher.rb +21 -17
  35. data/lib/pry/commands/edit/file_and_line_locator.rb +33 -24
  36. data/lib/pry/commands/edit.rb +183 -167
  37. data/lib/pry/commands/exit.rb +40 -35
  38. data/lib/pry/commands/exit_all.rb +24 -20
  39. data/lib/pry/commands/exit_program.rb +20 -17
  40. data/lib/pry/commands/find_method.rb +167 -167
  41. data/lib/pry/commands/fix_indent.rb +16 -12
  42. data/lib/pry/commands/help.rb +140 -133
  43. data/lib/pry/commands/hist.rb +153 -132
  44. data/lib/pry/commands/import_set.rb +20 -15
  45. data/lib/pry/commands/jump_to.rb +25 -21
  46. data/lib/pry/commands/list_inspectors.rb +42 -0
  47. data/lib/pry/commands/ls/constants.rb +75 -0
  48. data/lib/pry/commands/ls/formatter.rb +55 -0
  49. data/lib/pry/commands/ls/globals.rb +50 -0
  50. data/lib/pry/commands/ls/grep.rb +23 -0
  51. data/lib/pry/commands/ls/instance_vars.rb +40 -0
  52. data/lib/pry/commands/ls/interrogatable.rb +24 -0
  53. data/lib/pry/commands/ls/jruby_hacks.rb +55 -0
  54. data/lib/pry/commands/ls/local_names.rb +37 -0
  55. data/lib/pry/commands/ls/local_vars.rb +47 -0
  56. data/lib/pry/commands/ls/ls_entity.rb +65 -0
  57. data/lib/pry/commands/ls/methods.rb +55 -0
  58. data/lib/pry/commands/ls/methods_helper.rb +50 -0
  59. data/lib/pry/commands/ls/self_methods.rb +34 -0
  60. data/lib/pry/commands/ls.rb +100 -303
  61. data/lib/pry/commands/nesting.rb +21 -17
  62. data/lib/pry/commands/play.rb +93 -49
  63. data/lib/pry/commands/pry_backtrace.rb +22 -18
  64. data/lib/pry/commands/pry_version.rb +15 -11
  65. data/lib/pry/commands/raise_up.rb +33 -27
  66. data/lib/pry/commands/reload_code.rb +57 -48
  67. data/lib/pry/commands/reset.rb +16 -12
  68. data/lib/pry/commands/ri.rb +57 -38
  69. data/lib/pry/commands/save_file.rb +45 -43
  70. data/lib/pry/commands/shell_command.rb +66 -34
  71. data/lib/pry/commands/shell_mode.rb +22 -20
  72. data/lib/pry/commands/show_doc.rb +80 -65
  73. data/lib/pry/commands/show_info.rb +193 -159
  74. data/lib/pry/commands/show_input.rb +16 -11
  75. data/lib/pry/commands/show_source.rb +113 -33
  76. data/lib/pry/commands/stat.rb +35 -31
  77. data/lib/pry/commands/switch_to.rb +21 -15
  78. data/lib/pry/commands/toggle_color.rb +21 -13
  79. data/lib/pry/commands/watch_expression/expression.rb +43 -0
  80. data/lib/pry/commands/watch_expression.rb +110 -0
  81. data/lib/pry/commands/whereami.rb +157 -134
  82. data/lib/pry/commands/wtf.rb +78 -40
  83. data/lib/pry/config/attributable.rb +22 -0
  84. data/lib/pry/config/lazy_value.rb +29 -0
  85. data/lib/pry/config/memoized_value.rb +34 -0
  86. data/lib/pry/config/value.rb +24 -0
  87. data/lib/pry/config.rb +290 -220
  88. data/lib/pry/control_d_handler.rb +28 -0
  89. data/lib/pry/core_extensions.rb +50 -27
  90. data/lib/pry/editor.rb +130 -102
  91. data/lib/pry/env.rb +18 -0
  92. data/lib/pry/exception_handler.rb +43 -0
  93. data/lib/pry/exceptions.rb +73 -0
  94. data/lib/pry/forwardable.rb +27 -0
  95. data/lib/pry/helpers/base_helpers.rb +22 -151
  96. data/lib/pry/helpers/command_helpers.rb +55 -63
  97. data/lib/pry/helpers/documentation_helpers.rb +21 -13
  98. data/lib/pry/helpers/options_helpers.rb +15 -8
  99. data/lib/pry/helpers/platform.rb +55 -0
  100. data/lib/pry/helpers/table.rb +44 -32
  101. data/lib/pry/helpers/text.rb +96 -86
  102. data/lib/pry/helpers.rb +3 -0
  103. data/lib/pry/history.rb +101 -70
  104. data/lib/pry/hooks.rb +67 -137
  105. data/lib/pry/indent.rb +79 -73
  106. data/lib/pry/input_completer.rb +283 -0
  107. data/lib/pry/input_lock.rb +129 -0
  108. data/lib/pry/inspector.rb +39 -0
  109. data/lib/pry/last_exception.rb +61 -0
  110. data/lib/pry/method/disowned.rb +19 -5
  111. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +51 -42
  112. data/lib/pry/method/weird_method_locator.rb +80 -44
  113. data/lib/pry/method.rb +225 -176
  114. data/lib/pry/object_path.rb +91 -0
  115. data/lib/pry/output.rb +136 -0
  116. data/lib/pry/pager.rb +227 -68
  117. data/lib/pry/prompt.rb +214 -0
  118. data/lib/pry/pry_class.rb +216 -289
  119. data/lib/pry/pry_instance.rb +438 -500
  120. data/lib/pry/repl.rb +256 -0
  121. data/lib/pry/repl_file_loader.rb +34 -35
  122. data/lib/pry/ring.rb +89 -0
  123. data/lib/pry/slop/LICENSE +20 -0
  124. data/lib/pry/slop/commands.rb +190 -0
  125. data/lib/pry/slop/option.rb +210 -0
  126. data/lib/pry/slop.rb +672 -0
  127. data/lib/pry/syntax_highlighter.rb +26 -0
  128. data/lib/pry/system_command_handler.rb +17 -0
  129. data/lib/pry/testable/evalable.rb +24 -0
  130. data/lib/pry/testable/mockable.rb +22 -0
  131. data/lib/pry/testable/pry_tester.rb +88 -0
  132. data/lib/pry/testable/utility.rb +34 -0
  133. data/lib/pry/testable/variables.rb +52 -0
  134. data/lib/pry/testable.rb +68 -0
  135. data/lib/pry/version.rb +3 -1
  136. data/lib/pry/warning.rb +20 -0
  137. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +36 -43
  138. data/lib/pry/wrapped_module.rb +102 -103
  139. data/lib/pry.rb +135 -261
  140. metadata +94 -283
  141. data/.document +0 -2
  142. data/.gitignore +0 -16
  143. data/.travis.yml +0 -21
  144. data/.yardopts +0 -1
  145. data/CHANGELOG +0 -534
  146. data/CONTRIBUTORS +0 -55
  147. data/Gemfile +0 -9
  148. data/Guardfile +0 -62
  149. data/README.markdown +0 -400
  150. data/Rakefile +0 -140
  151. data/TODO +0 -117
  152. data/lib/pry/commands/disabled_commands.rb +0 -2
  153. data/lib/pry/commands/gem_cd.rb +0 -26
  154. data/lib/pry/commands/gem_install.rb +0 -29
  155. data/lib/pry/commands/gem_list.rb +0 -33
  156. data/lib/pry/commands/gem_open.rb +0 -29
  157. data/lib/pry/commands/gist.rb +0 -102
  158. data/lib/pry/commands/install_command.rb +0 -51
  159. data/lib/pry/commands/simple_prompt.rb +0 -22
  160. data/lib/pry/commands.rb +0 -6
  161. data/lib/pry/completion.rb +0 -304
  162. data/lib/pry/custom_completions.rb +0 -6
  163. data/lib/pry/history_array.rb +0 -116
  164. data/lib/pry/plugins.rb +0 -103
  165. data/lib/pry/rbx_method.rb +0 -13
  166. data/lib/pry/rbx_path.rb +0 -22
  167. data/lib/pry/rubygem.rb +0 -74
  168. data/lib/pry/terminal.rb +0 -78
  169. data/lib/pry/test/helper.rb +0 -185
  170. data/man/pry.1 +0 -195
  171. data/man/pry.1.html +0 -204
  172. data/man/pry.1.ronn +0 -141
  173. data/pry.gemspec +0 -30
  174. data/spec/Procfile +0 -3
  175. data/spec/cli_spec.rb +0 -78
  176. data/spec/code_object_spec.rb +0 -277
  177. data/spec/code_spec.rb +0 -219
  178. data/spec/command_helpers_spec.rb +0 -29
  179. data/spec/command_integration_spec.rb +0 -644
  180. data/spec/command_set_spec.rb +0 -627
  181. data/spec/command_spec.rb +0 -821
  182. data/spec/commands/amend_line_spec.rb +0 -247
  183. data/spec/commands/bang_spec.rb +0 -19
  184. data/spec/commands/cat_spec.rb +0 -164
  185. data/spec/commands/cd_spec.rb +0 -250
  186. data/spec/commands/disable_pry_spec.rb +0 -25
  187. data/spec/commands/edit_spec.rb +0 -727
  188. data/spec/commands/exit_all_spec.rb +0 -34
  189. data/spec/commands/exit_program_spec.rb +0 -19
  190. data/spec/commands/exit_spec.rb +0 -34
  191. data/spec/commands/find_method_spec.rb +0 -70
  192. data/spec/commands/gem_list_spec.rb +0 -26
  193. data/spec/commands/gist_spec.rb +0 -79
  194. data/spec/commands/help_spec.rb +0 -56
  195. data/spec/commands/hist_spec.rb +0 -181
  196. data/spec/commands/jump_to_spec.rb +0 -15
  197. data/spec/commands/ls_spec.rb +0 -181
  198. data/spec/commands/play_spec.rb +0 -140
  199. data/spec/commands/raise_up_spec.rb +0 -56
  200. data/spec/commands/save_file_spec.rb +0 -177
  201. data/spec/commands/show_doc_spec.rb +0 -510
  202. data/spec/commands/show_input_spec.rb +0 -17
  203. data/spec/commands/show_source_spec.rb +0 -782
  204. data/spec/commands/whereami_spec.rb +0 -203
  205. data/spec/completion_spec.rb +0 -239
  206. data/spec/control_d_handler_spec.rb +0 -58
  207. data/spec/documentation_helper_spec.rb +0 -73
  208. data/spec/editor_spec.rb +0 -79
  209. data/spec/exception_whitelist_spec.rb +0 -21
  210. data/spec/fixtures/candidate_helper1.rb +0 -11
  211. data/spec/fixtures/candidate_helper2.rb +0 -8
  212. data/spec/fixtures/example.erb +0 -5
  213. data/spec/fixtures/example_nesting.rb +0 -33
  214. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  215. data/spec/fixtures/testrc +0 -2
  216. data/spec/fixtures/testrcbad +0 -2
  217. data/spec/fixtures/whereami_helper.rb +0 -6
  218. data/spec/helper.rb +0 -34
  219. data/spec/helpers/bacon.rb +0 -86
  220. data/spec/helpers/mock_pry.rb +0 -43
  221. data/spec/helpers/table_spec.rb +0 -105
  222. data/spec/history_array_spec.rb +0 -67
  223. data/spec/hooks_spec.rb +0 -522
  224. data/spec/indent_spec.rb +0 -301
  225. data/spec/input_stack_spec.rb +0 -90
  226. data/spec/method_spec.rb +0 -482
  227. data/spec/prompt_spec.rb +0 -60
  228. data/spec/pry_defaults_spec.rb +0 -419
  229. data/spec/pry_history_spec.rb +0 -99
  230. data/spec/pry_output_spec.rb +0 -95
  231. data/spec/pry_spec.rb +0 -504
  232. data/spec/run_command_spec.rb +0 -25
  233. data/spec/sticky_locals_spec.rb +0 -157
  234. data/spec/syntax_checking_spec.rb +0 -81
  235. data/spec/wrapped_module_spec.rb +0 -261
  236. data/wiki/Customizing-pry.md +0 -397
  237. data/wiki/Home.md +0 -4
@@ -1,34 +0,0 @@
1
- require 'helper'
2
-
3
- describe "exit-all" do
4
- it 'should break out of the repl loop of Pry instance and return nil' do
5
- pry_tester(0).simulate_repl do |t|
6
- t.eval 'exit-all'
7
- end.should == nil
8
- end
9
-
10
- it 'should break out of the repl loop of Pry instance wth a user specified value' do
11
- pry_tester(0).simulate_repl do |t|
12
- t.eval "exit-all 'message'"
13
- end.should == 'message'
14
- end
15
-
16
- it 'should break of the repl loop even if multiple bindings still on stack' do
17
- pry_tester(0).simulate_repl do |t|
18
- t.eval 'cd 1', 'cd 2', "exit-all 'message'"
19
- end.should == 'message'
20
- end
21
-
22
- it 'binding_stack should be empty after breaking out of the repl loop' do
23
- t = pry_tester(0) do
24
- def binding_stack
25
- @pry.binding_stack
26
- end
27
- end
28
-
29
- t.simulate_repl do |t|
30
- t.eval 'cd 1', 'cd 2', 'exit-all'
31
- end
32
- t.binding_stack.empty?.should == true
33
- end
34
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- describe "exit-program" do
4
- it 'should raise SystemExit' do
5
- proc {
6
- pry_eval('exit-program')
7
- }.should.raise SystemExit
8
- end
9
-
10
- it 'should exit the program with the provided value' do
11
- begin
12
- pry_eval 'exit-program 66'
13
- rescue SystemExit => e
14
- e.status.should == 66
15
- else
16
- raise "Failed to raise SystemExit"
17
- end
18
- end
19
- end
@@ -1,34 +0,0 @@
1
- require 'helper'
2
-
3
- describe "exit" do
4
- it 'should pop a binding with exit' do
5
- pry_tester(:outer).simulate_repl do |t|
6
- t.eval 'cd :inner'
7
- t.eval('self').should == :inner
8
- t.eval 'exit'
9
- t.eval('self').should == :outer
10
- t.eval 'exit-all'
11
- end
12
- end
13
-
14
- it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with exit' do
15
- pry_tester(0).simulate_repl do |t|
16
- t.eval 'exit'
17
- end.should == nil
18
- end
19
-
20
- it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with exit, and return user-given value' do
21
- pry_tester(0).simulate_repl do |t|
22
- t.eval 'exit :john'
23
- end.should == :john
24
- end
25
-
26
- it 'should break out the repl loop of Pry instance even after an exception in user-given value' do
27
- pry_tester(0).simulate_repl do |t|
28
- proc {
29
- t.eval 'exit = 42'
30
- }.should.raise(SyntaxError)
31
- t.eval 'exit'
32
- end.should == nil
33
- end
34
- end
@@ -1,70 +0,0 @@
1
- require 'helper'
2
-
3
- # we turn off the test for MRI 1.8 because our source_location hack
4
- # for C methods actually runs the methods - and since it runs ALL
5
- # methods (in an attempt to find a match) it runs 'exit' and aborts
6
- # the test, causing a failure. We should fix this in the future by
7
- # blacklisting certain methods for 1.8 MRI (such as exit, fork, and so on)
8
- unless Pry::Helpers::BaseHelpers.mri_18?
9
- MyKlass = Class.new do
10
- def hello
11
- "timothy"
12
- end
13
- def goodbye
14
- "jenny"
15
- end
16
- def tea_tim?
17
- "timothy"
18
- end
19
- def tea_time?
20
- "polly"
21
- end
22
- end
23
-
24
- describe "find-method" do
25
- describe "find matching methods by name regex (-n option)" do
26
- it "should find a method by regex" do
27
- pry_eval("find-method hell MyKlass").should =~
28
- /MyKlass.*?hello/m
29
- end
30
-
31
- it "should NOT match a method that does not match the regex" do
32
- pry_eval("find-method hell MyKlass").should.not =~
33
- /MyKlass.*?goodbye/m
34
- end
35
- end
36
-
37
- describe "find matching methods by content regex (-c option)" do
38
- it "should find a method by regex" do
39
- pry_eval("find-method -c timothy MyKlass").should =~
40
- /MyKlass.*?hello/m
41
- end
42
-
43
- it "should NOT match a method that does not match the regex" do
44
- pry_eval("find-method timothy MyKlass").should.not =~
45
- /MyKlass.*?goodbye/m
46
- end
47
- end
48
-
49
- it "should work with badly behaved constants" do
50
- MyKlass::X = Object.new
51
- def (MyKlass::X).hash
52
- raise "mooo"
53
- end
54
-
55
- pry_eval("find-method -c timothy MyKlass").should =~
56
- /MyKlass.*?hello/m
57
- end
58
-
59
- it "should escape regexes correctly" do
60
- good = /tea_time\?/
61
- bad = /tea_tim\?/
62
- pry_eval('find-method tea_time? MyKlass').should =~ good
63
- pry_eval('find-method tea_time? MyKlass').should =~ good
64
- pry_eval('find-method tea_time\? MyKlass').should.not =~ bad
65
- pry_eval('find-method tea_time\? MyKlass').should =~ good
66
- end
67
- end
68
-
69
- Object.remove_const(:MyKlass)
70
- end
@@ -1,26 +0,0 @@
1
- require 'helper'
2
-
3
- describe "gem-list" do
4
- # fixing bug for 1.8 compat
5
- it 'should not raise when invoked' do
6
- proc {
7
- pry_eval(self, 'gem-list')
8
- }.should.not.raise
9
- end
10
-
11
- it 'should work arglessly' do
12
- list = pry_eval('gem-list')
13
- list.should =~ /slop \(/
14
- list.should =~ /bacon \(/
15
- end
16
-
17
- it 'should find arg' do
18
- prylist = pry_eval('gem-list slop')
19
- prylist.should =~ /slop \(/
20
- prylist.should.not =~ /bacon/
21
- end
22
-
23
- it 'should return non-results as silence' do
24
- pry_eval('gem-list aoeuoueouaou').should.empty?
25
- end
26
- end
@@ -1,79 +0,0 @@
1
- # These tests are out of date.
2
- # THey need to be updated for the new 'gist' API, but im too sleepy to
3
- # do that now.
4
-
5
- require 'helper'
6
-
7
- describe 'gist' do
8
- it 'has a dependency on the jist gem' do
9
- Pry::Command::Gist.command_options[:requires_gem].should == "jist"
10
- end
11
- end
12
-
13
- # before do
14
- # Pad.jist_calls = {}
15
- # end
16
-
17
- # # In absence of normal mocking, just monkeysmash these with no undoing after.
18
- # module Jist
19
- # class << self
20
- # def login!; Pad.jist_calls[:login!] = true end
21
- # def gist(*args)
22
- # Pad.jist_calls[:gist_args] = args
23
- # {'html_url' => 'http://gist.blahblah'}
24
- # end
25
- # def copy(content); Pad.jist_calls[:copy_args] = content end
26
- # end
27
- # end
28
-
29
- # module Pry::Gist
30
- # # a) The actual require fails for jruby for some odd reason.
31
- # # b) 100% of jist should be stubbed by the above, so this ensures that.
32
- # def self.require_jist; 'nope' end
33
- # end
34
-
35
- # it 'nominally logs in' do
36
- # pry_eval 'gist --login'
37
- # Pad.jist_calls[:login!].should.not.be.nil
38
- # end
39
-
40
- # EXAMPLE_REPL_METHOD = <<-EOT
41
- # # docdoc
42
- # def my_method
43
- # # line 1
44
- # 'line 2'
45
- # line 3
46
- # Line.four
47
- # end
48
- # EOT
49
-
50
- # RANDOM_COUPLE_OF_LINES = %w(a=1 b=2)
51
- # run_case = proc do |sym|
52
- # actual_command = Pry::Gist.example_code(sym)
53
- # pry_eval EXAMPLE_REPL_METHOD, RANDOM_COUPLE_OF_LINES, actual_command
54
- # end
55
-
56
- # it 'deduces filenames' do
57
- # Pry::Gist::INVOCATIONS.keys.each do |e|
58
- # run_case.call(e)
59
- # if Pad.jist_calls[:gist_args]
60
- # text, args = Pad.jist_calls[:gist_args]
61
- # args[:filename].should.not == '(pry)'
62
- # end
63
- # Pad.jist_calls[:copy_args].should.not.be.nil
64
- # end
65
- # end
66
-
67
- # it 'equates aliae' do
68
- # run_case.call(:clipit).should == run_case.call(:cliponly)
69
- # run_case.call(:jist).should == run_case.call(:class)
70
- # end
71
-
72
- # it 'has a reasonable --help' do
73
- # help = pry_eval('gist --help')
74
- # Pry::Gist::INVOCATIONS.keys.each do |e|
75
- # help.should.include? Pry::Gist.example_code(e)
76
- # help.should.include? Pry::Gist.example_description(e)
77
- # end
78
- # end
79
- # end
@@ -1,56 +0,0 @@
1
- require 'helper'
2
-
3
- describe "help" do
4
- before do
5
- @oldset = Pry.config.commands
6
- @set = Pry.config.commands = Pry::CommandSet.new do
7
- import Pry::Commands
8
- end
9
- end
10
-
11
- after do
12
- Pry.config.commands = @oldset
13
- end
14
-
15
- it 'should display help for a specific command' do
16
- pry_eval('help ls').should =~ /Usage: ls/
17
- end
18
-
19
- it 'should display help for a regex command with a "listing"' do
20
- @set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
21
- pry_eval('help foo').should =~ /Test listing/
22
- end
23
-
24
- it 'should display help for a command with a spaces in its name' do
25
- @set.command "cmd with spaces", "desc of a cmd with spaces" do; end
26
- pry_eval('help "cmd with spaces"').should =~ /desc of a cmd with spaces/
27
- end
28
-
29
- it 'should display help for all commands with a description' do
30
- @set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
31
- @set.command "b", "description for b", :listing => "foo" do; end
32
- @set.command "c" do;end
33
- @set.command "d", "" do;end
34
-
35
- output = pry_eval('help')
36
- output.should =~ /Test listing/
37
- output.should =~ /description for b/
38
- output.should =~ /No description/
39
- end
40
-
41
- it "should sort the output of the 'help' command" do
42
- @set.command 'faa', "Fooerizes" do; end
43
- @set.command 'gaa', "Gooerizes" do; end
44
- @set.command 'maa', "Mooerizes" do; end
45
- @set.command 'baa', "Booerizes" do; end
46
-
47
- doc = pry_eval('help')
48
-
49
- order = [doc.index("baa"),
50
- doc.index("faa"),
51
- doc.index("gaa"),
52
- doc.index("maa")]
53
-
54
- order.should == order.sort
55
- end
56
- end
@@ -1,181 +0,0 @@
1
- require 'helper'
2
-
3
- describe "hist" do
4
- before do
5
- Pry.history.clear
6
- @hist = Pry.history
7
-
8
- @str_output = StringIO.new
9
- @t = pry_tester do
10
- # For looking at what hist pushes into the input stack. The
11
- # implementation of this helper will definitely have to change at some
12
- # point.
13
- def next_input
14
- @pry.input.string
15
- end
16
- end
17
- end
18
-
19
- it 'should display the correct history' do
20
- @hist.push "hello"
21
- @hist.push "world"
22
-
23
- @t.eval('hist').should =~ /hello\n.*world/
24
- end
25
-
26
- it 'should replay history correctly (single item)' do
27
- o = Object.new
28
- @hist.push "@x = 10"
29
- @hist.push "@y = 20"
30
- @hist.push "@z = 30"
31
-
32
- @t.context = o
33
- @t.eval 'hist --replay -1'
34
-
35
- @t.next_input.should == "@z = 30\n"
36
- end
37
-
38
- it 'should replay a range of history correctly (range of items)' do
39
- o = Object.new
40
- @hist.push "@x = 10"
41
- @hist.push "@y = 20"
42
-
43
- @t.context = o
44
- @t.eval 'hist --replay 0..2'
45
-
46
- @t.next_input.should == "@x = 10\n@y = 20\n"
47
- end
48
-
49
- # this is to prevent a regression where input redirection is
50
- # replaced by just appending to `eval_string`
51
- it 'should replay a range of history correctly (range of commands)' do
52
- o = Object.new
53
- @hist.push "cd 1"
54
- @hist.push "cd 2"
55
- redirect_pry_io(InputTester.new("hist --replay 0..2", "Pad.stack = _pry_.binding_stack.dup", "exit-all")) do
56
- o.pry
57
- end
58
- o = Pad.stack[-2..-1].map { |v| v.eval('self') }
59
- o.should == [1, 2]
60
- Pad.clear
61
- end
62
-
63
- it 'should grep for correct lines in history' do
64
- @hist.push "abby"
65
- @hist.push "box"
66
- @hist.push "button"
67
- @hist.push "pepper"
68
- @hist.push "orange"
69
- @hist.push "grape"
70
- @hist.push "def blah 1"
71
- @hist.push "def boink 2"
72
- @hist.push "place holder"
73
-
74
- @t.eval('hist --grep o').should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
75
-
76
- # test more than one word in a regex match (def blah)
77
- @t.eval('hist --grep def blah').should =~ /def blah 1/
78
-
79
- # test more than one word with leading white space in a regex match (def boink)
80
- @t.eval('hist --grep def boink').should =~ /def boink 2/
81
- end
82
-
83
- it 'should return last N lines in history with --tail switch' do
84
- ("a".."z").each do |v|
85
- @hist.push v
86
- end
87
-
88
- out = @t.eval 'hist --tail 3'
89
- out.each_line.count.should == 3
90
- out.should =~ /x\n\d+:.*y\n\d+:.*z/
91
- end
92
-
93
- it 'should apply --tail after --grep' do
94
- @hist.push "print 1"
95
- @hist.push "print 2"
96
- @hist.push "puts 3"
97
- @hist.push "print 4"
98
- @hist.push "puts 5"
99
-
100
- out = @t.eval 'hist --tail 2 --grep print'
101
- out.each_line.count.should == 2
102
- out.should =~ /\d:.*?print 2\n\d:.*?print 4/
103
- end
104
-
105
- it 'should apply --head after --grep' do
106
- @hist.push "puts 1"
107
- @hist.push "print 2"
108
- @hist.push "puts 3"
109
- @hist.push "print 4"
110
- @hist.push "print 5"
111
-
112
- out = @t.eval 'hist --head 2 --grep print'
113
- out.each_line.count.should == 2
114
- out.should =~ /\d:.*?print 2\n\d:.*?print 4/
115
- end
116
-
117
- # strangeness in this test is due to bug in Readline::HISTORY not
118
- # always registering first line of input
119
- it 'should return first N lines in history with --head switch' do
120
- ("a".."z").each do |v|
121
- @hist.push v
122
- end
123
-
124
- out = @t.eval 'hist --head 4'
125
- out.each_line.count.should == 4
126
- out.should =~ /a\n\d+:.*b\n\d+:.*c/
127
- end
128
-
129
- # strangeness in this test is due to bug in Readline::HISTORY not
130
- # always registering first line of input
131
- it 'should show lines between lines A and B with the --show switch' do
132
- ("a".."z").each do |v|
133
- @hist.push v
134
- end
135
-
136
- out = @t.eval 'hist --show 1..4'
137
- out.each_line.count.should == 4
138
- out.should =~ /b\n\d+:.*c\n\d+:.*d/
139
- end
140
-
141
- it "should store a call with `--replay` flag" do
142
- redirect_pry_io(InputTester.new(":banzai", "hist --replay 1",
143
- "hist", "exit-all"), @str_output) do
144
- Pry.start
145
- end
146
-
147
- @str_output.string.should =~ /hist --replay 1/
148
- end
149
-
150
- it "should not contain lines produced by `--replay` flag" do
151
- redirect_pry_io(InputTester.new(":banzai", ":geronimo", ":huzzah",
152
- "hist --replay 1..3", "hist",
153
- "exit-all"), @str_output) do
154
- Pry.start
155
- end
156
-
157
- @str_output.string.each_line.to_a.reject { |line| line.start_with?("=>") }.size.should == 4
158
- @str_output.string.each_line.to_a.last.should =~ /hist --replay 1\.\.3/
159
- @str_output.string.each_line.to_a[-2].should =~ /:huzzah/
160
- end
161
-
162
- it "should raise CommandError when index of `--replay` points out to another `hist --replay`" do
163
- redirect_pry_io(InputTester.new(":banzai", "hist --replay 1",
164
- "hist --replay 2", "exit-all"), @str_output) do
165
- Pry.start
166
- end
167
-
168
- @str_output.string.should =~ /Replay index 2 points out to another replay call: `hist --replay 1`/
169
- end
170
-
171
- it "should disallow execution of `--replay <i>` when CommandError raised" do
172
- redirect_pry_io(InputTester.new("a = 0", "a += 1", "hist --replay 2",
173
- "hist --replay 3", "'a is ' + a.to_s",
174
- "hist", "exit-all"), @str_output) do
175
- Pry.start
176
- end
177
-
178
- @str_output.string.each_line.to_a.reject { |line| line !~ /\A\d/ }.size.should == 5
179
- @str_output.string.should =~ /a is 2/
180
- end
181
- end
@@ -1,15 +0,0 @@
1
- require 'helper'
2
-
3
- describe "jump-to" do
4
- it 'should jump to the proper binding index in the stack' do
5
- pry_eval('cd 1', 'cd 2', 'jump-to 1', 'self').should == 1
6
- end
7
-
8
- it 'should print error when trying to jump to a non-existent binding index' do
9
- pry_eval("cd 1", "cd 2", "jump-to 100").should =~ /Invalid nest level/
10
- end
11
-
12
- it 'should print error when trying to jump to the same binding index' do
13
- pry_eval("cd 1", "cd 2", "jump-to 2").should =~ /Already/
14
- end
15
- end