pry 0.9.12.6-i386-mingw32 → 0.10.0-i386-mingw32

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 (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +37 -31
  5. data/lib/pry.rb +38 -151
  6. data/lib/pry/cli.rb +35 -17
  7. data/lib/pry/code.rb +19 -63
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +2 -1
  10. data/lib/pry/code/loc.rb +2 -2
  11. data/lib/pry/code_object.rb +40 -21
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +12 -9
  14. data/lib/pry/command_set.rb +81 -38
  15. data/lib/pry/commands.rb +1 -1
  16. data/lib/pry/commands/amend_line.rb +2 -2
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat.rb +11 -2
  19. data/lib/pry/commands/cat/exception_formatter.rb +6 -7
  20. data/lib/pry/commands/cat/file_formatter.rb +15 -32
  21. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  22. data/lib/pry/commands/cd.rb +14 -3
  23. data/lib/pry/commands/change_inspector.rb +27 -0
  24. data/lib/pry/commands/change_prompt.rb +26 -0
  25. data/lib/pry/commands/code_collector.rb +4 -4
  26. data/lib/pry/commands/easter_eggs.rb +3 -3
  27. data/lib/pry/commands/edit.rb +10 -22
  28. data/lib/pry/commands/edit/exception_patcher.rb +2 -2
  29. data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
  30. data/lib/pry/commands/exit_program.rb +0 -1
  31. data/lib/pry/commands/find_method.rb +16 -22
  32. data/lib/pry/commands/gem_install.rb +5 -2
  33. data/lib/pry/commands/gem_open.rb +1 -1
  34. data/lib/pry/commands/gist.rb +10 -11
  35. data/lib/pry/commands/help.rb +14 -14
  36. data/lib/pry/commands/hist.rb +27 -8
  37. data/lib/pry/commands/install_command.rb +14 -12
  38. data/lib/pry/commands/list_inspectors.rb +35 -0
  39. data/lib/pry/commands/list_prompts.rb +35 -0
  40. data/lib/pry/commands/ls.rb +72 -296
  41. data/lib/pry/commands/ls/constants.rb +47 -0
  42. data/lib/pry/commands/ls/formatter.rb +49 -0
  43. data/lib/pry/commands/ls/globals.rb +48 -0
  44. data/lib/pry/commands/ls/grep.rb +21 -0
  45. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  46. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  47. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  48. data/lib/pry/commands/ls/local_names.rb +35 -0
  49. data/lib/pry/commands/ls/local_vars.rb +39 -0
  50. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  51. data/lib/pry/commands/ls/methods.rb +57 -0
  52. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  53. data/lib/pry/commands/ls/self_methods.rb +32 -0
  54. data/lib/pry/commands/play.rb +44 -10
  55. data/lib/pry/commands/pry_backtrace.rb +1 -2
  56. data/lib/pry/commands/raise_up.rb +2 -2
  57. data/lib/pry/commands/reload_code.rb +16 -19
  58. data/lib/pry/commands/ri.rb +7 -3
  59. data/lib/pry/commands/shell_command.rb +18 -13
  60. data/lib/pry/commands/shell_mode.rb +2 -4
  61. data/lib/pry/commands/show_doc.rb +5 -0
  62. data/lib/pry/commands/show_info.rb +8 -13
  63. data/lib/pry/commands/show_source.rb +15 -3
  64. data/lib/pry/commands/simple_prompt.rb +1 -1
  65. data/lib/pry/commands/toggle_color.rb +8 -4
  66. data/lib/pry/commands/watch_expression.rb +105 -0
  67. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  68. data/lib/pry/commands/whereami.rb +18 -10
  69. data/lib/pry/commands/wtf.rb +3 -3
  70. data/lib/pry/config.rb +20 -254
  71. data/lib/pry/config/behavior.rb +139 -0
  72. data/lib/pry/config/convenience.rb +26 -0
  73. data/lib/pry/config/default.rb +165 -0
  74. data/lib/pry/core_extensions.rb +31 -21
  75. data/lib/pry/editor.rb +107 -103
  76. data/lib/pry/exceptions.rb +77 -0
  77. data/lib/pry/helpers/base_helpers.rb +22 -109
  78. data/lib/pry/helpers/command_helpers.rb +10 -8
  79. data/lib/pry/helpers/documentation_helpers.rb +1 -2
  80. data/lib/pry/helpers/text.rb +4 -5
  81. data/lib/pry/history.rb +46 -45
  82. data/lib/pry/history_array.rb +6 -1
  83. data/lib/pry/hooks.rb +9 -29
  84. data/lib/pry/indent.rb +6 -6
  85. data/lib/pry/input_completer.rb +242 -0
  86. data/lib/pry/input_lock.rb +132 -0
  87. data/lib/pry/inspector.rb +27 -0
  88. data/lib/pry/last_exception.rb +61 -0
  89. data/lib/pry/method.rb +82 -87
  90. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
  91. data/lib/pry/module_candidate.rb +4 -14
  92. data/lib/pry/object_path.rb +82 -0
  93. data/lib/pry/output.rb +50 -0
  94. data/lib/pry/pager.rb +193 -48
  95. data/lib/pry/plugins.rb +1 -1
  96. data/lib/pry/prompt.rb +26 -0
  97. data/lib/pry/pry_class.rb +149 -230
  98. data/lib/pry/pry_instance.rb +302 -413
  99. data/lib/pry/rbx_path.rb +1 -1
  100. data/lib/pry/repl.rb +202 -0
  101. data/lib/pry/repl_file_loader.rb +20 -26
  102. data/lib/pry/rubygem.rb +13 -5
  103. data/lib/pry/terminal.rb +2 -1
  104. data/lib/pry/test/helper.rb +26 -41
  105. data/lib/pry/version.rb +1 -1
  106. data/lib/pry/wrapped_module.rb +45 -59
  107. metadata +62 -225
  108. data/.document +0 -2
  109. data/.gitignore +0 -16
  110. data/.travis.yml +0 -25
  111. data/.yardopts +0 -1
  112. data/CHANGELOG +0 -534
  113. data/CONTRIBUTORS +0 -55
  114. data/Gemfile +0 -12
  115. data/Rakefile +0 -140
  116. data/TODO +0 -117
  117. data/lib/pry/completion.rb +0 -321
  118. data/lib/pry/custom_completions.rb +0 -6
  119. data/lib/pry/rbx_method.rb +0 -13
  120. data/man/pry.1 +0 -195
  121. data/man/pry.1.html +0 -204
  122. data/man/pry.1.ronn +0 -141
  123. data/pry.gemspec +0 -29
  124. data/spec/Procfile +0 -3
  125. data/spec/cli_spec.rb +0 -78
  126. data/spec/code_object_spec.rb +0 -277
  127. data/spec/code_spec.rb +0 -219
  128. data/spec/command_helpers_spec.rb +0 -29
  129. data/spec/command_integration_spec.rb +0 -644
  130. data/spec/command_set_spec.rb +0 -627
  131. data/spec/command_spec.rb +0 -821
  132. data/spec/commands/amend_line_spec.rb +0 -247
  133. data/spec/commands/bang_spec.rb +0 -19
  134. data/spec/commands/cat_spec.rb +0 -164
  135. data/spec/commands/cd_spec.rb +0 -250
  136. data/spec/commands/disable_pry_spec.rb +0 -25
  137. data/spec/commands/edit_spec.rb +0 -727
  138. data/spec/commands/exit_all_spec.rb +0 -34
  139. data/spec/commands/exit_program_spec.rb +0 -19
  140. data/spec/commands/exit_spec.rb +0 -34
  141. data/spec/commands/find_method_spec.rb +0 -70
  142. data/spec/commands/gem_list_spec.rb +0 -26
  143. data/spec/commands/gist_spec.rb +0 -79
  144. data/spec/commands/help_spec.rb +0 -56
  145. data/spec/commands/hist_spec.rb +0 -181
  146. data/spec/commands/jump_to_spec.rb +0 -15
  147. data/spec/commands/ls_spec.rb +0 -181
  148. data/spec/commands/play_spec.rb +0 -140
  149. data/spec/commands/raise_up_spec.rb +0 -56
  150. data/spec/commands/save_file_spec.rb +0 -177
  151. data/spec/commands/show_doc_spec.rb +0 -510
  152. data/spec/commands/show_input_spec.rb +0 -17
  153. data/spec/commands/show_source_spec.rb +0 -782
  154. data/spec/commands/whereami_spec.rb +0 -203
  155. data/spec/completion_spec.rb +0 -241
  156. data/spec/control_d_handler_spec.rb +0 -58
  157. data/spec/documentation_helper_spec.rb +0 -73
  158. data/spec/editor_spec.rb +0 -79
  159. data/spec/exception_whitelist_spec.rb +0 -21
  160. data/spec/fixtures/candidate_helper1.rb +0 -11
  161. data/spec/fixtures/candidate_helper2.rb +0 -8
  162. data/spec/fixtures/example.erb +0 -5
  163. data/spec/fixtures/example_nesting.rb +0 -33
  164. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  165. data/spec/fixtures/testrc +0 -2
  166. data/spec/fixtures/testrcbad +0 -2
  167. data/spec/fixtures/whereami_helper.rb +0 -6
  168. data/spec/helper.rb +0 -34
  169. data/spec/helpers/bacon.rb +0 -86
  170. data/spec/helpers/mock_pry.rb +0 -43
  171. data/spec/helpers/table_spec.rb +0 -105
  172. data/spec/history_array_spec.rb +0 -67
  173. data/spec/hooks_spec.rb +0 -522
  174. data/spec/indent_spec.rb +0 -301
  175. data/spec/input_stack_spec.rb +0 -90
  176. data/spec/method_spec.rb +0 -482
  177. data/spec/prompt_spec.rb +0 -60
  178. data/spec/pry_defaults_spec.rb +0 -419
  179. data/spec/pry_history_spec.rb +0 -99
  180. data/spec/pry_output_spec.rb +0 -95
  181. data/spec/pry_spec.rb +0 -515
  182. data/spec/run_command_spec.rb +0 -25
  183. data/spec/sticky_locals_spec.rb +0 -157
  184. data/spec/syntax_checking_spec.rb +0 -81
  185. data/spec/wrapped_module_spec.rb +0 -261
  186. data/wiki/Customizing-pry.md +0 -397
  187. 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