pry 0.9.10pre1-i386-mingw32 → 0.9.11-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -1
- data/CHANGELOG +63 -2
- data/CONTRIBUTORS +43 -25
- data/Gemfile +7 -0
- data/Guardfile +62 -0
- data/README.markdown +4 -4
- data/Rakefile +34 -35
- data/lib/pry.rb +107 -54
- data/lib/pry/cli.rb +34 -11
- data/lib/pry/code.rb +165 -182
- data/lib/pry/code/code_range.rb +70 -0
- data/lib/pry/code/loc.rb +92 -0
- data/lib/pry/code_object.rb +153 -0
- data/lib/pry/command.rb +160 -22
- data/lib/pry/command_set.rb +37 -26
- data/lib/pry/commands.rb +4 -27
- data/lib/pry/commands/amend_line.rb +99 -0
- data/lib/pry/commands/bang.rb +20 -0
- data/lib/pry/commands/bang_pry.rb +17 -0
- data/lib/pry/commands/cat.rb +53 -0
- data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/lib/pry/commands/cat/exception_formatter.rb +78 -0
- data/lib/pry/commands/cat/file_formatter.rb +84 -0
- data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/lib/pry/commands/cd.rb +30 -0
- data/lib/pry/commands/code_collector.rb +165 -0
- data/lib/pry/commands/deprecated_commands.rb +2 -0
- data/lib/pry/commands/disable_pry.rb +27 -0
- data/lib/pry/commands/easter_eggs.rb +112 -0
- data/lib/pry/commands/edit.rb +206 -0
- data/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/lib/pry/commands/edit/file_and_line_locator.rb +38 -0
- data/lib/pry/commands/edit/method_patcher.rb +122 -0
- data/lib/pry/commands/exit.rb +42 -0
- data/lib/pry/commands/exit_all.rb +29 -0
- data/lib/pry/commands/exit_program.rb +24 -0
- data/lib/pry/commands/find_method.rb +199 -0
- data/lib/pry/commands/fix_indent.rb +19 -0
- data/lib/pry/commands/gem_cd.rb +26 -0
- data/lib/pry/commands/gem_install.rb +29 -0
- data/lib/pry/commands/gem_list.rb +33 -0
- data/lib/pry/commands/gem_open.rb +29 -0
- data/lib/pry/commands/gist.rb +95 -0
- data/lib/pry/commands/help.rb +164 -0
- data/lib/pry/commands/hist.rb +161 -0
- data/lib/pry/commands/import_set.rb +22 -0
- data/lib/pry/commands/install_command.rb +51 -0
- data/lib/pry/commands/jump_to.rb +29 -0
- data/lib/pry/commands/ls.rb +339 -0
- data/lib/pry/commands/nesting.rb +25 -0
- data/lib/pry/commands/play.rb +69 -0
- data/lib/pry/commands/pry_backtrace.rb +26 -0
- data/lib/pry/commands/pry_version.rb +17 -0
- data/lib/pry/commands/raise_up.rb +32 -0
- data/lib/pry/commands/reload_code.rb +39 -0
- data/lib/pry/commands/reset.rb +18 -0
- data/lib/pry/commands/ri.rb +56 -0
- data/lib/pry/commands/save_file.rb +61 -0
- data/lib/pry/commands/shell_command.rb +43 -0
- data/lib/pry/commands/shell_mode.rb +27 -0
- data/lib/pry/commands/show_doc.rb +78 -0
- data/lib/pry/commands/show_info.rb +139 -0
- data/lib/pry/commands/show_input.rb +17 -0
- data/lib/pry/commands/show_source.rb +37 -0
- data/lib/pry/commands/simple_prompt.rb +22 -0
- data/lib/pry/commands/stat.rb +40 -0
- data/lib/pry/commands/switch_to.rb +23 -0
- data/lib/pry/commands/toggle_color.rb +20 -0
- data/lib/pry/commands/whereami.rb +114 -0
- data/lib/pry/commands/wtf.rb +57 -0
- data/lib/pry/completion.rb +120 -46
- data/lib/pry/config.rb +11 -0
- data/lib/pry/core_extensions.rb +30 -19
- data/lib/pry/editor.rb +129 -0
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +89 -119
- data/lib/pry/helpers/command_helpers.rb +7 -122
- data/lib/pry/helpers/table.rb +100 -0
- data/lib/pry/helpers/text.rb +4 -4
- data/lib/pry/history_array.rb +5 -0
- data/lib/pry/hooks.rb +1 -3
- data/lib/pry/indent.rb +104 -30
- data/lib/pry/method.rb +66 -22
- data/lib/pry/module_candidate.rb +26 -15
- data/lib/pry/pager.rb +70 -0
- data/lib/pry/plugins.rb +1 -2
- data/lib/pry/pry_class.rb +63 -22
- data/lib/pry/pry_instance.rb +58 -37
- data/lib/pry/rubygem.rb +74 -0
- data/lib/pry/terminal_info.rb +43 -0
- data/lib/pry/test/helper.rb +185 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +58 -24
- data/pry.gemspec +21 -37
- data/{test/test_cli.rb → spec/cli_spec.rb} +0 -0
- data/spec/code_object_spec.rb +277 -0
- data/{test/test_code.rb → spec/code_spec.rb} +19 -1
- data/{test/test_command_helpers.rb → spec/command_helpers_spec.rb} +0 -0
- data/{test/test_command_integration.rb → spec/command_integration_spec.rb} +38 -46
- data/{test/test_command_set.rb → spec/command_set_spec.rb} +18 -1
- data/{test/test_command.rb → spec/command_spec.rb} +250 -149
- data/spec/commands/amend_line_spec.rb +247 -0
- data/spec/commands/bang_spec.rb +19 -0
- data/spec/commands/cat_spec.rb +164 -0
- data/spec/commands/cd_spec.rb +250 -0
- data/spec/commands/disable_pry_spec.rb +25 -0
- data/spec/commands/edit_spec.rb +727 -0
- data/spec/commands/exit_all_spec.rb +34 -0
- data/spec/commands/exit_program_spec.rb +19 -0
- data/spec/commands/exit_spec.rb +34 -0
- data/{test/test_default_commands/test_find_method.rb → spec/commands/find_method_spec.rb} +27 -7
- data/spec/commands/gem_list_spec.rb +26 -0
- data/spec/commands/gist_spec.rb +75 -0
- data/{test/test_default_commands/test_help.rb → spec/commands/help_spec.rb} +8 -9
- data/spec/commands/hist_spec.rb +181 -0
- data/spec/commands/jump_to_spec.rb +15 -0
- data/spec/commands/ls_spec.rb +177 -0
- data/spec/commands/play_spec.rb +140 -0
- data/spec/commands/raise_up_spec.rb +56 -0
- data/spec/commands/save_file_spec.rb +177 -0
- data/spec/commands/show_doc_spec.rb +378 -0
- data/spec/commands/show_input_spec.rb +17 -0
- data/spec/commands/show_source_spec.rb +597 -0
- data/spec/commands/whereami_spec.rb +154 -0
- data/spec/completion_spec.rb +233 -0
- data/spec/control_d_handler_spec.rb +58 -0
- data/spec/editor_spec.rb +79 -0
- data/{test/test_exception_whitelist.rb → spec/exception_whitelist_spec.rb} +0 -0
- data/{test → spec/fixtures}/candidate_helper1.rb +0 -0
- data/{test → spec/fixtures}/candidate_helper2.rb +0 -0
- data/{test/test_default_commands → spec/fixtures}/example.erb +0 -0
- data/spec/fixtures/example_nesting.rb +33 -0
- data/spec/fixtures/show_source_doc_examples.rb +15 -0
- data/{test → spec/fixtures}/testrc +0 -0
- data/{test → spec/fixtures}/testrcbad +0 -0
- data/spec/helper.rb +34 -0
- data/spec/helpers/bacon.rb +86 -0
- data/spec/helpers/mock_pry.rb +43 -0
- data/spec/helpers/table_spec.rb +83 -0
- data/{test/test_history_array.rb → spec/history_array_spec.rb} +21 -19
- data/{test/test_hooks.rb → spec/hooks_spec.rb} +0 -0
- data/{test/test_indent.rb → spec/indent_spec.rb} +24 -0
- data/{test/test_input_stack.rb → spec/input_stack_spec.rb} +4 -0
- data/{test/test_method.rb → spec/method_spec.rb} +65 -1
- data/{test/test_prompt.rb → spec/prompt_spec.rb} +0 -0
- data/{test/test_pry_defaults.rb → spec/pry_defaults_spec.rb} +14 -14
- data/{test/test_pry_history.rb → spec/pry_history_spec.rb} +15 -0
- data/spec/pry_output_spec.rb +95 -0
- data/{test/test_pry.rb → spec/pry_spec.rb} +74 -32
- data/{test/test_sticky_locals.rb → spec/sticky_locals_spec.rb} +27 -25
- data/{test/test_syntax_checking.rb → spec/syntax_checking_spec.rb} +17 -1
- data/{test/test_wrapped_module.rb → spec/wrapped_module_spec.rb} +92 -5
- metadata +239 -115
- data/examples/example_basic.rb +0 -15
- data/examples/example_command_override.rb +0 -32
- data/examples/example_commands.rb +0 -36
- data/examples/example_hooks.rb +0 -9
- data/examples/example_image_edit.rb +0 -67
- data/examples/example_input.rb +0 -7
- data/examples/example_input2.rb +0 -29
- data/examples/example_output.rb +0 -11
- data/examples/example_print.rb +0 -6
- data/examples/example_prompt.rb +0 -9
- data/examples/helper.rb +0 -6
- data/lib/pry/default_commands/cd.rb +0 -81
- data/lib/pry/default_commands/commands.rb +0 -62
- data/lib/pry/default_commands/context.rb +0 -98
- data/lib/pry/default_commands/easter_eggs.rb +0 -95
- data/lib/pry/default_commands/editing.rb +0 -420
- data/lib/pry/default_commands/find_method.rb +0 -169
- data/lib/pry/default_commands/gems.rb +0 -84
- data/lib/pry/default_commands/gist.rb +0 -187
- data/lib/pry/default_commands/help.rb +0 -127
- data/lib/pry/default_commands/hist.rb +0 -120
- data/lib/pry/default_commands/input_and_output.rb +0 -306
- data/lib/pry/default_commands/introspection.rb +0 -410
- data/lib/pry/default_commands/ls.rb +0 -272
- data/lib/pry/default_commands/misc.rb +0 -38
- data/lib/pry/default_commands/navigating_pry.rb +0 -110
- data/lib/pry/default_commands/whereami.rb +0 -92
- data/lib/pry/extended_commands/experimental.rb +0 -7
- data/test/helper.rb +0 -223
- data/test/test_completion.rb +0 -62
- data/test/test_control_d_handler.rb +0 -45
- data/test/test_default_commands/test_cd.rb +0 -321
- data/test/test_default_commands/test_context.rb +0 -288
- data/test/test_default_commands/test_documentation.rb +0 -315
- data/test/test_default_commands/test_gems.rb +0 -18
- data/test/test_default_commands/test_input.rb +0 -428
- data/test/test_default_commands/test_introspection.rb +0 -511
- data/test/test_default_commands/test_ls.rb +0 -151
- data/test/test_default_commands/test_shell.rb +0 -343
- data/test/test_default_commands/test_show_source.rb +0 -432
- data/test/test_pry_output.rb +0 -41
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -0,0 +1,34 @@
|
|
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
|
@@ -4,7 +4,7 @@ require 'helper'
|
|
4
4
|
# for C methods actually runs the methods - and since it runs ALL
|
5
5
|
# methods (in an attempt to find a match) it runs 'exit' and aborts
|
6
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)
|
7
|
+
# blacklisting certain methods for 1.8 MRI (such as exit, fork, and so on)
|
8
8
|
unless Pry::Helpers::BaseHelpers.mri_18?
|
9
9
|
MyKlass = Class.new do
|
10
10
|
def hello
|
@@ -13,26 +13,36 @@ unless Pry::Helpers::BaseHelpers.mri_18?
|
|
13
13
|
def goodbye
|
14
14
|
"jenny"
|
15
15
|
end
|
16
|
+
def tea_tim?
|
17
|
+
"timothy"
|
18
|
+
end
|
19
|
+
def tea_time?
|
20
|
+
"polly"
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
|
-
describe "find-
|
24
|
+
describe "find-method" do
|
19
25
|
describe "find matching methods by name regex (-n option)" do
|
20
26
|
it "should find a method by regex" do
|
21
|
-
|
27
|
+
pry_eval("find-method hell MyKlass").should =~
|
28
|
+
/MyKlass.*?hello/m
|
22
29
|
end
|
23
30
|
|
24
31
|
it "should NOT match a method that does not match the regex" do
|
25
|
-
|
32
|
+
pry_eval("find-method hell MyKlass").should.not =~
|
33
|
+
/MyKlass.*?goodbye/m
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
29
37
|
describe "find matching methods by content regex (-c option)" do
|
30
38
|
it "should find a method by regex" do
|
31
|
-
|
39
|
+
pry_eval("find-method -c timothy MyKlass").should =~
|
40
|
+
/MyKlass.*?hello/m
|
32
41
|
end
|
33
42
|
|
34
43
|
it "should NOT match a method that does not match the regex" do
|
35
|
-
|
44
|
+
pry_eval("find-method timothy MyKlass").should.not =~
|
45
|
+
/MyKlass.*?goodbye/m
|
36
46
|
end
|
37
47
|
end
|
38
48
|
|
@@ -42,7 +52,17 @@ unless Pry::Helpers::BaseHelpers.mri_18?
|
|
42
52
|
raise "mooo"
|
43
53
|
end
|
44
54
|
|
45
|
-
|
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
|
46
66
|
end
|
47
67
|
end
|
48
68
|
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,75 @@
|
|
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
|
+
|
6
|
+
# require 'helper'
|
7
|
+
|
8
|
+
# describe 'gist' do
|
9
|
+
# before do
|
10
|
+
# Pad.jist_calls = {}
|
11
|
+
# end
|
12
|
+
|
13
|
+
# # In absence of normal mocking, just monkeysmash these with no undoing after.
|
14
|
+
# module Jist
|
15
|
+
# class << self
|
16
|
+
# def login!; Pad.jist_calls[:login!] = true end
|
17
|
+
# def gist(*args)
|
18
|
+
# Pad.jist_calls[:gist_args] = args
|
19
|
+
# {'html_url' => 'http://gist.blahblah'}
|
20
|
+
# end
|
21
|
+
# def copy(content); Pad.jist_calls[:copy_args] = content end
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
|
25
|
+
# module Pry::Gist
|
26
|
+
# # a) The actual require fails for jruby for some odd reason.
|
27
|
+
# # b) 100% of jist should be stubbed by the above, so this ensures that.
|
28
|
+
# def self.require_jist; 'nope' end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# it 'nominally logs in' do
|
32
|
+
# pry_eval 'gist --login'
|
33
|
+
# Pad.jist_calls[:login!].should.not.be.nil
|
34
|
+
# end
|
35
|
+
|
36
|
+
# EXAMPLE_REPL_METHOD = <<-EOT
|
37
|
+
# # docdoc
|
38
|
+
# def my_method
|
39
|
+
# # line 1
|
40
|
+
# 'line 2'
|
41
|
+
# line 3
|
42
|
+
# Line.four
|
43
|
+
# end
|
44
|
+
# EOT
|
45
|
+
|
46
|
+
# RANDOM_COUPLE_OF_LINES = %w(a=1 b=2)
|
47
|
+
# run_case = proc do |sym|
|
48
|
+
# actual_command = Pry::Gist.example_code(sym)
|
49
|
+
# pry_eval EXAMPLE_REPL_METHOD, RANDOM_COUPLE_OF_LINES, actual_command
|
50
|
+
# end
|
51
|
+
|
52
|
+
# it 'deduces filenames' do
|
53
|
+
# Pry::Gist::INVOCATIONS.keys.each do |e|
|
54
|
+
# run_case.call(e)
|
55
|
+
# if Pad.jist_calls[:gist_args]
|
56
|
+
# text, args = Pad.jist_calls[:gist_args]
|
57
|
+
# args[:filename].should.not == '(pry)'
|
58
|
+
# end
|
59
|
+
# Pad.jist_calls[:copy_args].should.not.be.nil
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
|
63
|
+
# it 'equates aliae' do
|
64
|
+
# run_case.call(:clipit).should == run_case.call(:cliponly)
|
65
|
+
# run_case.call(:jist).should == run_case.call(:class)
|
66
|
+
# end
|
67
|
+
|
68
|
+
# it 'has a reasonable --help' do
|
69
|
+
# help = pry_eval('gist --help')
|
70
|
+
# Pry::Gist::INVOCATIONS.keys.each do |e|
|
71
|
+
# help.should.include? Pry::Gist.example_code(e)
|
72
|
+
# help.should.include? Pry::Gist.example_description(e)
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
# end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "help" do
|
4
4
|
before do
|
5
5
|
@oldset = Pry.config.commands
|
6
6
|
@set = Pry.config.commands = Pry::CommandSet.new do
|
7
|
-
import Pry::
|
8
|
-
import Pry::DefaultCommands::Ls
|
7
|
+
import Pry::Commands
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
@@ -14,17 +13,17 @@ describe "'help' command" do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'should display help for a specific command' do
|
17
|
-
|
16
|
+
pry_eval('help ls').should =~ /Usage: ls/
|
18
17
|
end
|
19
18
|
|
20
19
|
it 'should display help for a regex command with a "listing"' do
|
21
20
|
@set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
|
22
|
-
|
21
|
+
pry_eval('help foo').should =~ /Test listing/
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'should display help for a command with a spaces in its name' do
|
26
|
-
@set.command "
|
27
|
-
|
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/
|
28
27
|
end
|
29
28
|
|
30
29
|
it 'should display help for all commands with a description' do
|
@@ -33,7 +32,7 @@ describe "'help' command" do
|
|
33
32
|
@set.command "c" do;end
|
34
33
|
@set.command "d", "" do;end
|
35
34
|
|
36
|
-
output =
|
35
|
+
output = pry_eval('help')
|
37
36
|
output.should =~ /Test listing/
|
38
37
|
output.should =~ /description for b/
|
39
38
|
output.should =~ /No description/
|
@@ -45,7 +44,7 @@ describe "'help' command" do
|
|
45
44
|
@set.command 'maa', "Mooerizes" do; end
|
46
45
|
@set.command 'baa', "Booerizes" do; end
|
47
46
|
|
48
|
-
doc =
|
47
|
+
doc = pry_eval('help')
|
49
48
|
|
50
49
|
order = [doc.index("baa"),
|
51
50
|
doc.index("faa"),
|
@@ -0,0 +1,181 @@
|
|
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
|