pry 0.9.12.6-i386-mswin32 → 0.10.0-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +37 -31
- data/lib/pry.rb +38 -151
- data/lib/pry/cli.rb +35 -17
- data/lib/pry/code.rb +19 -63
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +2 -1
- data/lib/pry/code/loc.rb +2 -2
- data/lib/pry/code_object.rb +40 -21
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +12 -9
- data/lib/pry/command_set.rb +81 -38
- data/lib/pry/commands.rb +1 -1
- data/lib/pry/commands/amend_line.rb +2 -2
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +11 -2
- data/lib/pry/commands/cat/exception_formatter.rb +6 -7
- data/lib/pry/commands/cat/file_formatter.rb +15 -32
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cd.rb +14 -3
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +4 -4
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +10 -22
- data/lib/pry/commands/edit/exception_patcher.rb +2 -2
- data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
- data/lib/pry/commands/exit_program.rb +0 -1
- data/lib/pry/commands/find_method.rb +16 -22
- data/lib/pry/commands/gem_install.rb +5 -2
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gist.rb +10 -11
- data/lib/pry/commands/help.rb +14 -14
- data/lib/pry/commands/hist.rb +27 -8
- data/lib/pry/commands/install_command.rb +14 -12
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +72 -296
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/play.rb +44 -10
- data/lib/pry/commands/pry_backtrace.rb +1 -2
- data/lib/pry/commands/raise_up.rb +2 -2
- data/lib/pry/commands/reload_code.rb +16 -19
- data/lib/pry/commands/ri.rb +7 -3
- data/lib/pry/commands/shell_command.rb +18 -13
- data/lib/pry/commands/shell_mode.rb +2 -4
- data/lib/pry/commands/show_doc.rb +5 -0
- data/lib/pry/commands/show_info.rb +8 -13
- data/lib/pry/commands/show_source.rb +15 -3
- data/lib/pry/commands/simple_prompt.rb +1 -1
- data/lib/pry/commands/toggle_color.rb +8 -4
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +18 -10
- data/lib/pry/commands/wtf.rb +3 -3
- data/lib/pry/config.rb +20 -254
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +31 -21
- data/lib/pry/editor.rb +107 -103
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers/base_helpers.rb +22 -109
- data/lib/pry/helpers/command_helpers.rb +10 -8
- data/lib/pry/helpers/documentation_helpers.rb +1 -2
- data/lib/pry/helpers/text.rb +4 -5
- data/lib/pry/history.rb +46 -45
- data/lib/pry/history_array.rb +6 -1
- data/lib/pry/hooks.rb +9 -29
- data/lib/pry/indent.rb +6 -6
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +82 -87
- data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
- data/lib/pry/module_candidate.rb +4 -14
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +193 -48
- data/lib/pry/plugins.rb +1 -1
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +149 -230
- data/lib/pry/pry_instance.rb +302 -413
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +13 -5
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/test/helper.rb +26 -41
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +45 -59
- metadata +62 -225
- data/.document +0 -2
- data/.gitignore +0 -16
- data/.travis.yml +0 -25
- data/.yardopts +0 -1
- data/CHANGELOG +0 -534
- data/CONTRIBUTORS +0 -55
- data/Gemfile +0 -12
- data/Rakefile +0 -140
- data/TODO +0 -117
- data/lib/pry/completion.rb +0 -321
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -29
- data/spec/Procfile +0 -3
- data/spec/cli_spec.rb +0 -78
- data/spec/code_object_spec.rb +0 -277
- data/spec/code_spec.rb +0 -219
- data/spec/command_helpers_spec.rb +0 -29
- data/spec/command_integration_spec.rb +0 -644
- data/spec/command_set_spec.rb +0 -627
- data/spec/command_spec.rb +0 -821
- data/spec/commands/amend_line_spec.rb +0 -247
- data/spec/commands/bang_spec.rb +0 -19
- data/spec/commands/cat_spec.rb +0 -164
- data/spec/commands/cd_spec.rb +0 -250
- data/spec/commands/disable_pry_spec.rb +0 -25
- data/spec/commands/edit_spec.rb +0 -727
- data/spec/commands/exit_all_spec.rb +0 -34
- data/spec/commands/exit_program_spec.rb +0 -19
- data/spec/commands/exit_spec.rb +0 -34
- data/spec/commands/find_method_spec.rb +0 -70
- data/spec/commands/gem_list_spec.rb +0 -26
- data/spec/commands/gist_spec.rb +0 -79
- data/spec/commands/help_spec.rb +0 -56
- data/spec/commands/hist_spec.rb +0 -181
- data/spec/commands/jump_to_spec.rb +0 -15
- data/spec/commands/ls_spec.rb +0 -181
- data/spec/commands/play_spec.rb +0 -140
- data/spec/commands/raise_up_spec.rb +0 -56
- data/spec/commands/save_file_spec.rb +0 -177
- data/spec/commands/show_doc_spec.rb +0 -510
- data/spec/commands/show_input_spec.rb +0 -17
- data/spec/commands/show_source_spec.rb +0 -782
- data/spec/commands/whereami_spec.rb +0 -203
- data/spec/completion_spec.rb +0 -241
- data/spec/control_d_handler_spec.rb +0 -58
- data/spec/documentation_helper_spec.rb +0 -73
- data/spec/editor_spec.rb +0 -79
- data/spec/exception_whitelist_spec.rb +0 -21
- data/spec/fixtures/candidate_helper1.rb +0 -11
- data/spec/fixtures/candidate_helper2.rb +0 -8
- data/spec/fixtures/example.erb +0 -5
- data/spec/fixtures/example_nesting.rb +0 -33
- data/spec/fixtures/show_source_doc_examples.rb +0 -15
- data/spec/fixtures/testrc +0 -2
- data/spec/fixtures/testrcbad +0 -2
- data/spec/fixtures/whereami_helper.rb +0 -6
- data/spec/helper.rb +0 -34
- data/spec/helpers/bacon.rb +0 -86
- data/spec/helpers/mock_pry.rb +0 -43
- data/spec/helpers/table_spec.rb +0 -105
- data/spec/history_array_spec.rb +0 -67
- data/spec/hooks_spec.rb +0 -522
- data/spec/indent_spec.rb +0 -301
- data/spec/input_stack_spec.rb +0 -90
- data/spec/method_spec.rb +0 -482
- data/spec/prompt_spec.rb +0 -60
- data/spec/pry_defaults_spec.rb +0 -419
- data/spec/pry_history_spec.rb +0 -99
- data/spec/pry_output_spec.rb +0 -95
- data/spec/pry_spec.rb +0 -515
- data/spec/run_command_spec.rb +0 -25
- data/spec/sticky_locals_spec.rb +0 -157
- data/spec/syntax_checking_spec.rb +0 -81
- data/spec/wrapped_module_spec.rb +0 -261
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
@@ -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
|
data/spec/commands/ls_spec.rb
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe "ls" do
|
4
|
-
describe "below ceiling" do
|
5
|
-
it "should stop before Object by default" do
|
6
|
-
pry_eval("cd Class.new{ def goo; end }.new", "ls").should.not =~ /Object/
|
7
|
-
pry_eval("cd Class.new{ def goo; end }", "ls -M").should.not =~ /Object/
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should include object if -v is given" do
|
11
|
-
pry_eval("cd Class.new{ def goo; end }.new", "ls -m -v").should =~ /Object/
|
12
|
-
pry_eval("cd Class.new{ def goo; end }", "ls -vM").should =~ /Object/
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should include super-classes by default" do
|
16
|
-
pry_eval(
|
17
|
-
"cd Class.new(Class.new{ def goo; end; public :goo }).new",
|
18
|
-
"ls").should =~ /goo/
|
19
|
-
|
20
|
-
pry_eval(
|
21
|
-
"cd Class.new(Class.new{ def goo; end; public :goo })",
|
22
|
-
"ls -M").should =~ /goo/
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should not include super-classes when -q is given" do
|
26
|
-
pry_eval("cd Class.new(Class.new{ def goo; end }).new", "ls -q").should.not =~ /goo/
|
27
|
-
pry_eval("cd Class.new(Class.new{ def goo; end })", "ls -M -q").should.not =~ /goo/
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "help" do
|
32
|
-
it 'should show help with -h' do
|
33
|
-
pry_eval("ls -h").should =~ /Usage: ls/
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "methods" do
|
38
|
-
it "should show public methods by default" do
|
39
|
-
output = pry_eval("ls Class.new{ def goo; end; public :goo }.new")
|
40
|
-
output.should =~ /methods: goo/
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should not show protected/private by default" do
|
44
|
-
pry_eval("ls -M Class.new{ def goo; end; private :goo }").should.not =~ /goo/
|
45
|
-
pry_eval("ls Class.new{ def goo; end; protected :goo }.new").should.not =~ /goo/
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should show public methods with -p" do
|
49
|
-
pry_eval("ls -p Class.new{ def goo; end }.new").should =~ /methods: goo/
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should show protected/private methods with -p" do
|
53
|
-
pry_eval("ls -pM Class.new{ def goo; end; protected :goo }").should =~ /methods: goo/
|
54
|
-
pry_eval("ls -p Class.new{ def goo; end; private :goo }.new").should =~ /methods: goo/
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should work for objects with an overridden method method" do
|
58
|
-
require 'net/http'
|
59
|
-
# This doesn't actually touch the network, promise!
|
60
|
-
pry_eval("ls Net::HTTP::Get.new('localhost')").should =~ /Net::HTTPGenericRequest#methods/
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'with -l' do
|
65
|
-
it 'should find locals and sort by descending size' do
|
66
|
-
result = pry_eval("aa = 'asdf'; bb = 'xyz'", 'ls -l')
|
67
|
-
result.should.not =~ /=>/
|
68
|
-
result.should.not =~ /0x\d{5}/
|
69
|
-
result.should =~ /asdf.*xyz/m
|
70
|
-
end
|
71
|
-
it 'should not list pry noise' do
|
72
|
-
pry_eval('ls -l').should.not =~ /_(?:dir|file|ex|pry|out|in)_/
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "when inside Modules" do
|
77
|
-
it "should still work" do
|
78
|
-
pry_eval(
|
79
|
-
"cd Module.new{ def foobie; end; public :foobie }",
|
80
|
-
"ls -M").should =~ /foobie/
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should work for ivars" do
|
84
|
-
pry_eval(
|
85
|
-
"module StigmaT1sm; def foobie; @@gharble = 456; end; end",
|
86
|
-
"Object.new.tap{ |o| o.extend(StigmaT1sm) }.foobie",
|
87
|
-
"cd StigmaT1sm",
|
88
|
-
"ls -i").should =~ /@@gharble/
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should include instance methods by default" do
|
92
|
-
output = pry_eval(
|
93
|
-
"ls Module.new{ def shinanagarns; 4; end; public :shinanagarns }")
|
94
|
-
output.should =~ /shinanagarns/
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should behave normally when invoked on Module itself" do
|
98
|
-
pry_eval("ls Module").should.not =~ /Pry/
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "constants" do
|
103
|
-
it "should show constants defined on the current module" do
|
104
|
-
pry_eval("class TempFoo1; BARGHL = 1; end", "ls TempFoo1").should =~ /BARGHL/
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should not show constants defined on parent modules by default" do
|
108
|
-
pry_eval("class TempFoo2; LHGRAB = 1; end; class TempFoo3 < TempFoo2; BARGHL = 1; end", "ls TempFoo3").should.not =~ /LHGRAB/
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should show constants defined on ancestors with -v" do
|
112
|
-
pry_eval("class TempFoo4; LHGRAB = 1; end; class TempFoo5 < TempFoo4; BARGHL = 1; end", "ls -v TempFoo5").should =~ /LHGRAB/
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should not autoload constants!" do
|
116
|
-
autoload :McflurgleTheThird, "/tmp/this-file-d000esnat-exist.rb"
|
117
|
-
lambda{ pry_eval("ls -c") }.should.not.raise
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe "grep" do
|
122
|
-
it "should reduce the number of outputted things" do
|
123
|
-
pry_eval("ls -c").should =~ /ArgumentError/
|
124
|
-
pry_eval("ls -c --grep Run").should.not =~ /ArgumentError/
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should still output matching things" do
|
128
|
-
pry_eval("ls -c --grep Run").should =~ /RuntimeError/
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe "when no arguments given" do
|
133
|
-
describe "when at the top-level" do
|
134
|
-
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
|
135
|
-
unless Pry::Helpers::BaseHelpers.rbx?
|
136
|
-
it "should show local variables" do
|
137
|
-
pry_eval("ls").should =~ /_pry_/
|
138
|
-
pry_eval("arbitrar = 1", "ls").should =~ /arbitrar/
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "when in a class" do
|
144
|
-
it "should show constants" do
|
145
|
-
pry_eval("class GeFromulate1; FOOTIFICATE=1.3; end", "cd GeFromulate1", "ls").should =~ /FOOTIFICATE/
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should show class variables" do
|
149
|
-
pry_eval("class GeFromulate2; @@flurb=1.3; end", "cd GeFromulate2", "ls").should =~ /@@flurb/
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should show methods" do
|
153
|
-
pry_eval("class GeFromulate3; def self.mooflight; end ; end", "cd GeFromulate3", "ls").should =~ /mooflight/
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "when in an object" do
|
158
|
-
it "should show methods" do
|
159
|
-
pry_eval("cd Class.new{ def self.fooerise; end; self }", "ls").should =~ /fooerise/
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should show instance variables" do
|
163
|
-
pry_eval("cd Class.new", "@alphooent = 1", "ls").should =~ /@alphooent/
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
if Pry::Helpers::BaseHelpers.jruby?
|
169
|
-
describe 'on java objects' do
|
170
|
-
it 'should omit java-esque aliases by default' do
|
171
|
-
pry_eval('ls java.lang.Thread.current_thread').should =~ /\bthread_group\b/
|
172
|
-
pry_eval('ls java.lang.Thread.current_thread').should.not =~ /\bgetThreadGroup\b/
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should include java-esque aliases if requested' do
|
176
|
-
pry_eval('ls java.lang.Thread.current_thread -J').should =~ /\bthread_group\b/
|
177
|
-
pry_eval('ls java.lang.Thread.current_thread -J').should =~ /\bgetThreadGroup\b/
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
data/spec/commands/play_spec.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
# This command needs a TONNE more tests for it, but i can't figure out
|
2
|
-
# how to do them yet, and i really want to release. Sorry. Someone
|
3
|
-
# come along and do a better job.
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
|
7
|
-
describe "play" do
|
8
|
-
before do
|
9
|
-
@t = pry_tester
|
10
|
-
@eval_str = ''
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "with an argument" do
|
14
|
-
|
15
|
-
# can't think of a f*cking way to test this!!
|
16
|
-
describe "implied file" do
|
17
|
-
# it 'should play from the file associated with the current binding' do
|
18
|
-
# # require 'fixtures/play_helper'
|
19
|
-
# end
|
20
|
-
|
21
|
-
|
22
|
-
# describe "integer" do
|
23
|
-
# it "should process one line from _pry_.last_file" do
|
24
|
-
# @t.process_command 'play --lines 1', @eval_str
|
25
|
-
# @eval_str.should =~ /bing = :bing\n/
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
|
-
# describe "range" do
|
30
|
-
# it "should process multiple lines at once from _pry_.last_file" do
|
31
|
-
# @t.process_command 'play --lines 1..3', @eval_str
|
32
|
-
# [/bing = :bing\n/, /bang = :bang\n/, /bong = :bong\n/].each { |str|
|
33
|
-
# @eval_str.should =~ str
|
34
|
-
# }
|
35
|
-
# end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "whatever" do
|
40
|
-
before do
|
41
|
-
@o = Object.new
|
42
|
-
def @o.test_method
|
43
|
-
:test_method_content
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should play documentation with the -d switch' do
|
48
|
-
# @v = 10
|
49
|
-
# @y = 20
|
50
|
-
def @o.test_method
|
51
|
-
:test_method_content
|
52
|
-
end
|
53
|
-
|
54
|
-
pry_tester(@o).process_command 'play -d test_method', @eval_str
|
55
|
-
|
56
|
-
@eval_str.should == unindent(<<-STR)
|
57
|
-
@v = 10
|
58
|
-
@y = 20
|
59
|
-
STR
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should restrict -d switch with --lines' do
|
63
|
-
# @x = 0
|
64
|
-
# @v = 10
|
65
|
-
# @y = 20
|
66
|
-
# @z = 30
|
67
|
-
def @o.test_method
|
68
|
-
:test_method_content
|
69
|
-
end
|
70
|
-
|
71
|
-
pry_tester(@o).process_command 'play -d test_method --lines 2..3', @eval_str
|
72
|
-
|
73
|
-
@eval_str.should == unindent(<<-STR)
|
74
|
-
@v = 10
|
75
|
-
@y = 20
|
76
|
-
STR
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'has pretty error messages when -d cant find object' do
|
80
|
-
lambda { @t.process_command "play -d sdfsdf" }.should.raise(Pry::CommandError).message.should.match(/Cannot locate/)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should play a method (a single line)' do
|
84
|
-
pry_tester(@o).process_command 'play test_method --lines 2', @eval_str
|
85
|
-
@eval_str.should == ":test_method_content\n"
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should properly reindent lines' do
|
89
|
-
def @o.test_method
|
90
|
-
'hello world'
|
91
|
-
end
|
92
|
-
|
93
|
-
pry_tester(@o).process_command 'play test_method --lines 2', @eval_str
|
94
|
-
@eval_str.should == "'hello world'\n"
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should APPEND to the input buffer when playing a method line, not replace it' do
|
98
|
-
@eval_str = unindent(<<-STR)
|
99
|
-
def another_test_method
|
100
|
-
STR
|
101
|
-
|
102
|
-
pry_tester(@o).process_command 'play test_method --lines 2', @eval_str
|
103
|
-
|
104
|
-
@eval_str.should == unindent(<<-STR)
|
105
|
-
def another_test_method
|
106
|
-
:test_method_content
|
107
|
-
STR
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should play a method (multiple lines)' do
|
111
|
-
def @o.test_method
|
112
|
-
@var0 = 10
|
113
|
-
@var1 = 20
|
114
|
-
@var2 = 30
|
115
|
-
@var3 = 40
|
116
|
-
end
|
117
|
-
|
118
|
-
pry_tester(@o).process_command 'play test_method --lines 3..4', @eval_str
|
119
|
-
|
120
|
-
@eval_str.should == unindent(<<-STR, 0)
|
121
|
-
@var1 = 20
|
122
|
-
@var2 = 30
|
123
|
-
STR
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "play -i" do
|
127
|
-
it 'should play multi-ranged input expressions' do
|
128
|
-
a = b = c = d = e = 0
|
129
|
-
redirect_pry_io(InputTester.new('a += 1', 'b += 1',
|
130
|
-
'c += 1', 'd += 1', 'e += 1',
|
131
|
-
"play -i 1..3"), StringIO.new) do
|
132
|
-
binding.pry
|
133
|
-
end
|
134
|
-
|
135
|
-
[a, b, c].all? { |v| v.should == 2 }
|
136
|
-
d.should == 1
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe "raise-up" do
|
4
|
-
before do
|
5
|
-
@self = "Pad.self = self"
|
6
|
-
@inner = "Pad.inner = self"
|
7
|
-
@outer = "Pad.outer = self"
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
Pad.clear
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should raise the exception with raise-up" do
|
15
|
-
redirect_pry_io(InputTester.new("raise NoMethodError", "raise-up NoMethodError")) do
|
16
|
-
lambda { Pry.new.repl(0) }.should.raise NoMethodError
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should raise an unamed exception with raise-up" do
|
21
|
-
redirect_pry_io(InputTester.new("raise 'stop'","raise-up 'noreally'")) do
|
22
|
-
lambda { Pry.new.repl(0) }.should.raise RuntimeError, "noreally"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should eat the exception at the last new pry instance on raise-up" do
|
27
|
-
redirect_pry_io(InputTester.new(":inner.pry", "raise NoMethodError", @inner,
|
28
|
-
"raise-up NoMethodError", @outer, "exit-all")) do
|
29
|
-
Pry.start(:outer)
|
30
|
-
end
|
31
|
-
|
32
|
-
Pad.inner.should == :inner
|
33
|
-
Pad.outer.should == :outer
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should raise the most recently raised exception" do
|
37
|
-
lambda { mock_pry("raise NameError, 'homographery'","raise-up") }.should.raise NameError, 'homographery'
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should allow you to cd up and (eventually) out" do
|
41
|
-
redirect_pry_io(InputTester.new("cd :inner", "raise NoMethodError", @inner,
|
42
|
-
"deep = :deep", "cd deep","Pad.deep = self",
|
43
|
-
"raise-up NoMethodError", "raise-up", @outer,
|
44
|
-
"raise-up", "exit-all")) do
|
45
|
-
lambda { Pry.start(:outer) }.should.raise NoMethodError
|
46
|
-
end
|
47
|
-
|
48
|
-
Pad.deep.should == :deep
|
49
|
-
Pad.inner.should == :inner
|
50
|
-
Pad.outer.should == :outer
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should jump immediately out of nested contexts with !" do
|
54
|
-
lambda { mock_pry("cd 1", "cd 2", "cd 3", "raise-up! 'fancy that...'") }.should.raise RuntimeError, 'fancy that...'
|
55
|
-
end
|
56
|
-
end
|
@@ -1,177 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe "save-file" do
|
4
|
-
before do
|
5
|
-
@tf = Tempfile.new(["pry", ".py"])
|
6
|
-
@path = @tf.path
|
7
|
-
@t = pry_tester
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
@tf.close(true)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "-f" do
|
15
|
-
it 'should save a file to a file' do
|
16
|
-
temp_file do |f|
|
17
|
-
path = f.path
|
18
|
-
f.puts ":cute_horse"
|
19
|
-
f.flush
|
20
|
-
|
21
|
-
@t.eval("save-file '#{path}' --to '#{@path}'")
|
22
|
-
|
23
|
-
|
24
|
-
File.read(@path).should == File.read(path)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "-i" do
|
30
|
-
it 'should save input expressions to a file (single expression)' do
|
31
|
-
@t.eval ':horse_nostrils'
|
32
|
-
@t.eval "save-file -i 1 --to '#{@path}'"
|
33
|
-
File.read(@path).should == ":horse_nostrils\n"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should display a success message on save" do
|
37
|
-
@t.eval ':horse_nostrils'
|
38
|
-
@t.eval("save-file -i 1 --to '#{@path}'").should =~ /successfully saved/
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should save input expressions to a file (range)' do
|
42
|
-
@t.eval ':or_nostrils', ':sucking_up_all_the_oxygen', ':or_whatever'
|
43
|
-
@t.eval "save-file -i 1..2 --to '#{@path}'"
|
44
|
-
File.read(@path).should == ":or_nostrils\n:sucking_up_all_the_oxygen\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should save multi-ranged input expressions' do
|
48
|
-
@t.eval ':or_nostrils', ':sucking_up_all_the_oxygen', ':or_whatever',
|
49
|
-
':baby_ducks', ':cannot_escape'
|
50
|
-
@t.eval "save-file -i 1..2 -i 4..5 --to '#{@path}'"
|
51
|
-
File.read(@path).should == ":or_nostrils\n:sucking_up_all_the_oxygen\n:baby_ducks\n:cannot_escape\n"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "saving methods" do
|
56
|
-
before do
|
57
|
-
@o = Object.new
|
58
|
-
def @o.baby
|
59
|
-
:baby
|
60
|
-
end
|
61
|
-
def @o.bang
|
62
|
-
:bang
|
63
|
-
end
|
64
|
-
|
65
|
-
@t = pry_tester(@o)
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "single method" do
|
69
|
-
it 'should save a method to a file' do
|
70
|
-
@t.eval "save-file --to '#{@path}' baby"
|
71
|
-
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should display a success message on save" do
|
75
|
-
@t.eval("save-file --to '#{@path}' baby").should =~ /successfully saved/
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should save a method to a file truncated by --lines' do
|
79
|
-
@t.eval "save-file --to '#{@path}' baby --lines 2..4"
|
80
|
-
|
81
|
-
# must add 1 as first line of method is 1
|
82
|
-
File.read(@path).should ==
|
83
|
-
Pry::Method.from_obj(@o, :baby).source.lines.to_a[1..5].join
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# TODO: do we want to reintroduce this spec??
|
88
|
-
#
|
89
|
-
# describe "multiple method" do
|
90
|
-
# it 'should save multiple methods to a file' do
|
91
|
-
# @t.eval "save-file #{@path} -m baby -m bang"
|
92
|
-
|
93
|
-
# File.read(@path).should == Pry::Method.from_obj(@o, :baby).source +
|
94
|
-
# Pry::Method.from_obj(@o, :bang).source
|
95
|
-
# end
|
96
|
-
|
97
|
-
# it 'should save multiple methods to a file trucated by --lines' do
|
98
|
-
# @t.eval "save-file #{@path} -m baby -m bang --lines 2..-2"
|
99
|
-
|
100
|
-
# # must add 1 as first line of method is 1
|
101
|
-
# File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
102
|
-
# Pry::Method.from_obj(@o, :bang).source).lines.to_a[1..-2].join
|
103
|
-
# end
|
104
|
-
|
105
|
-
# it 'should save multiple methods to a file trucated by --lines 1 ' \
|
106
|
-
# '(single parameter, not range)' do
|
107
|
-
# @t.eval "save-file #{@path} -m baby -m bang --lines 1"
|
108
|
-
|
109
|
-
# # must add 1 as first line of method is 1
|
110
|
-
# File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
111
|
-
# Pry::Method.from_obj(@o, :bang).source).lines.to_a[0]
|
112
|
-
# end
|
113
|
-
# end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "overwrite by default (no --append)" do
|
117
|
-
it 'should overwrite specified file with new input' do
|
118
|
-
@t.eval ':horse_nostrils'
|
119
|
-
@t.eval "save-file -i 1 --to '#{@path}'"
|
120
|
-
|
121
|
-
@t.eval ':sucking_up_all_the_oxygen'
|
122
|
-
@t.eval "save-file -i 2 --to '#{@path}'"
|
123
|
-
|
124
|
-
File.read(@path).should == ":sucking_up_all_the_oxygen\n"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "--append" do
|
129
|
-
it 'should append to end of specified file' do
|
130
|
-
@t.eval ':horse_nostrils'
|
131
|
-
@t.eval "save-file -i 1 --to '#{@path}'"
|
132
|
-
|
133
|
-
@t.eval ':sucking_up_all_the_oxygen'
|
134
|
-
@t.eval "save-file -i 2 --to '#{@path}' -a"
|
135
|
-
|
136
|
-
File.read(@path).should ==
|
137
|
-
":horse_nostrils\n:sucking_up_all_the_oxygen\n"
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "saving commands" do
|
142
|
-
it 'should save a command to a file' do
|
143
|
-
@t.eval "save-file --to '#{@path}' show-source"
|
144
|
-
cmd_source = Pry.commands["show-source"].source
|
145
|
-
File.read(@path).should == cmd_source
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# TODO: reintroduce these specs at some point?
|
150
|
-
#
|
151
|
-
# describe "combined options" do
|
152
|
-
# before do
|
153
|
-
# @o = Object.new
|
154
|
-
# def @o.baby
|
155
|
-
# :baby
|
156
|
-
# end
|
157
|
-
|
158
|
-
# @t = pry_tester(@o)
|
159
|
-
# end
|
160
|
-
|
161
|
-
# it 'should save input cache and a method to a file (in that order)' do
|
162
|
-
# @t.eval ":horse_nostrils"
|
163
|
-
# @t.eval "save-file -i 1 -m baby #{@path}"
|
164
|
-
|
165
|
-
# File.read(@path).should == ":horse_nostrils\n" +
|
166
|
-
# Pry::Method.from_obj(@o, :baby).source
|
167
|
-
# end
|
168
|
-
|
169
|
-
# it 'should select a portion to save using --lines' do
|
170
|
-
# @t.eval ":horse_nostrils"
|
171
|
-
# @t.eval "save-file -i 1 -m baby #{@path} --lines 2..-2"
|
172
|
-
|
173
|
-
# str = ":horse_nostrils\n" + Pry::Method.from_obj(@o, :baby).source
|
174
|
-
# File.read(@path).should == str.lines.to_a[1..-2].join
|
175
|
-
# end
|
176
|
-
# end
|
177
|
-
end
|