pry 0.9.7.4-i386-mswin32 → 0.9.8-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -3
- data/CHANGELOG +43 -0
- data/README.markdown +3 -1
- data/Rakefile +51 -32
- data/bin/pry +2 -80
- data/lib/pry.rb +33 -26
- data/lib/pry/cli.rb +152 -0
- data/lib/pry/code.rb +351 -0
- data/lib/pry/command.rb +422 -0
- data/lib/pry/command_set.rb +259 -129
- data/lib/pry/commands.rb +0 -1
- data/lib/pry/config.rb +43 -9
- data/lib/pry/default_commands/context.rb +109 -92
- data/lib/pry/default_commands/documentation.rb +174 -63
- data/lib/pry/default_commands/easter_eggs.rb +26 -2
- data/lib/pry/default_commands/gems.rb +65 -37
- data/lib/pry/default_commands/input.rb +175 -243
- data/lib/pry/default_commands/introspection.rb +173 -112
- data/lib/pry/default_commands/ls.rb +96 -114
- data/lib/pry/default_commands/shell.rb +175 -70
- data/lib/pry/helpers/base_helpers.rb +7 -2
- data/lib/pry/helpers/command_helpers.rb +71 -77
- data/lib/pry/helpers/options_helpers.rb +10 -41
- data/lib/pry/helpers/text.rb +24 -4
- data/lib/pry/history.rb +55 -17
- data/lib/pry/history_array.rb +2 -0
- data/lib/pry/hooks.rb +252 -0
- data/lib/pry/indent.rb +9 -5
- data/lib/pry/method.rb +149 -50
- data/lib/pry/plugins.rb +12 -4
- data/lib/pry/pry_class.rb +69 -26
- data/lib/pry/pry_instance.rb +187 -115
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +73 -0
- data/man/pry.1 +195 -0
- data/man/pry.1.html +204 -0
- data/man/pry.1.ronn +141 -0
- data/pry.gemspec +29 -32
- data/test/helper.rb +32 -36
- data/test/test_cli.rb +78 -0
- data/test/test_code.rb +201 -0
- data/test/test_command.rb +327 -0
- data/test/test_command_integration.rb +512 -0
- data/test/test_command_set.rb +338 -12
- data/test/test_completion.rb +1 -1
- data/test/test_default_commands.rb +1 -2
- data/test/test_default_commands/test_context.rb +27 -5
- data/test/test_default_commands/test_documentation.rb +20 -8
- data/test/test_default_commands/test_input.rb +84 -45
- data/test/test_default_commands/test_introspection.rb +74 -17
- data/test/test_default_commands/test_ls.rb +9 -36
- data/test/test_default_commands/test_shell.rb +240 -13
- data/test/test_hooks.rb +490 -0
- data/test/test_indent.rb +2 -0
- data/test/test_method.rb +60 -0
- data/test/test_pry.rb +29 -904
- data/test/test_pry_defaults.rb +380 -0
- data/test/test_pry_history.rb +24 -24
- data/test/test_syntax_checking.rb +63 -0
- data/test/test_wrapped_module.rb +71 -0
- metadata +50 -39
- data/lib/pry/command_context.rb +0 -53
- data/lib/pry/command_processor.rb +0 -181
- data/lib/pry/extended_commands/user_command_api.rb +0 -65
- data/test/test_command_processor.rb +0 -176
@@ -3,29 +3,41 @@ require 'helper'
|
|
3
3
|
describe "Pry::DefaultCommands::Documentation" do
|
4
4
|
describe "show-doc" do
|
5
5
|
it 'should output a method\'s documentation' do
|
6
|
-
str_output
|
7
|
-
redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output) do
|
6
|
+
redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output=StringIO.new) do
|
8
7
|
pry
|
9
8
|
end
|
10
9
|
|
11
10
|
str_output.string.should =~ /sample doc/
|
12
11
|
end
|
13
12
|
|
14
|
-
it 'should output a method\'s documentation
|
15
|
-
|
13
|
+
it 'should output a method\'s documentation with line numbers' do
|
14
|
+
redirect_pry_io(InputTester.new("show-doc sample_method -l", "exit-all"), str_output=StringIO.new) do
|
15
|
+
pry
|
16
|
+
end
|
17
|
+
|
18
|
+
str_output.string.should =~ /\d: sample doc/
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should output a method\'s documentation with line numbers (base one)' do
|
22
|
+
redirect_pry_io(InputTester.new("show-doc sample_method -b", "exit-all"), str_output=StringIO.new) do
|
23
|
+
pry
|
24
|
+
end
|
25
|
+
|
26
|
+
str_output.string.should =~ /1: sample doc/
|
27
|
+
end
|
16
28
|
|
29
|
+
it 'should output a method\'s documentation if inside method without needing to use method name' do
|
17
30
|
o = Object.new
|
18
31
|
|
19
32
|
# sample comment
|
20
33
|
def o.sample
|
21
|
-
redirect_pry_io(InputTester.new("show-doc", "exit-all"), $
|
34
|
+
redirect_pry_io(InputTester.new("show-doc", "exit-all"), $out=StringIO.new) do
|
22
35
|
binding.pry
|
23
36
|
end
|
24
37
|
end
|
25
38
|
o.sample
|
26
|
-
|
27
|
-
$
|
28
|
-
$str_output = nil
|
39
|
+
$out.string.should =~ /sample comment/
|
40
|
+
$out = nil
|
29
41
|
end
|
30
42
|
|
31
43
|
it "should be able to find super methods" do
|
@@ -154,7 +154,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
154
154
|
b = binding
|
155
155
|
b.eval('x = "\"hello\""')
|
156
156
|
redirect_pry_io(InputTester.new("play x", "exit-all"), str_output = StringIO.new) do
|
157
|
-
Pry.start b, :hooks =>
|
157
|
+
Pry.start b, :hooks => Pry::Hooks.new
|
158
158
|
end
|
159
159
|
str_output.string.should =~ /hello/
|
160
160
|
end
|
@@ -163,66 +163,100 @@ describe "Pry::DefaultCommands::Input" do
|
|
163
163
|
b = binding
|
164
164
|
b.eval('x = "\"hello\"\n\"goodbye\"\n\"love\""')
|
165
165
|
redirect_pry_io(InputTester.new("play x --lines 1", "exit-all"), str_output = StringIO.new) do
|
166
|
-
Pry.start b, :hooks =>
|
166
|
+
Pry.start b, :hooks => Pry::Hooks.new
|
167
167
|
end
|
168
168
|
str_output.string.should =~ /hello/
|
169
169
|
str_output.string.should.not =~ /love/
|
170
170
|
str_output.string.should.not =~ /goodbye/
|
171
171
|
end
|
172
172
|
|
173
|
+
it 'should play documentation with the -d switch' do
|
174
|
+
o = Object.new
|
175
|
+
|
176
|
+
# @v = 10
|
177
|
+
# @y = 20
|
178
|
+
def o.test_method
|
179
|
+
:test_method_content
|
180
|
+
end
|
181
|
+
|
182
|
+
redirect_pry_io(InputTester.new('play -d test_method', "exit-all"), str_output = StringIO.new) do
|
183
|
+
o.pry
|
184
|
+
end
|
185
|
+
|
186
|
+
o.instance_variable_get(:@v).should == 10
|
187
|
+
o.instance_variable_get(:@y).should == 20
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should play documentation with the -d switch (restricted by --lines)' do
|
191
|
+
o = Object.new
|
192
|
+
|
193
|
+
# @x = 0
|
194
|
+
# @v = 10
|
195
|
+
# @y = 20
|
196
|
+
# @z = 30
|
197
|
+
def o.test_method
|
198
|
+
:test_method_content
|
199
|
+
end
|
200
|
+
|
201
|
+
redirect_pry_io(InputTester.new('play -d test_method --lines 2..3', "exit-all"), str_output = StringIO.new) do
|
202
|
+
o.pry
|
203
|
+
end
|
204
|
+
|
205
|
+
o.instance_variable_get(:@x).should == nil
|
206
|
+
o.instance_variable_get(:@z).should == nil
|
207
|
+
o.instance_variable_get(:@v).should == 10
|
208
|
+
o.instance_variable_get(:@y).should == 20
|
209
|
+
end
|
210
|
+
|
211
|
+
|
173
212
|
it 'should play a method with the -m switch (a single line)' do
|
174
|
-
|
175
|
-
def
|
213
|
+
o = Object.new
|
214
|
+
def o.test_method
|
176
215
|
:test_method_content
|
177
216
|
end
|
178
217
|
|
179
|
-
redirect_pry_io(InputTester.new('play -m
|
180
|
-
pry
|
218
|
+
redirect_pry_io(InputTester.new('play -m test_method --lines 2', "exit-all"), str_output = StringIO.new) do
|
219
|
+
o.pry
|
181
220
|
end
|
182
221
|
|
183
222
|
str_output.string.should =~ /:test_method_content/
|
184
|
-
$o = nil
|
185
223
|
end
|
186
224
|
|
187
225
|
it 'should APPEND to the input buffer when playing a line with play -m, not replace it' do
|
188
|
-
|
189
|
-
def
|
226
|
+
o = Object.new
|
227
|
+
def o.test_method
|
190
228
|
:test_method_content
|
191
229
|
end
|
192
230
|
|
193
|
-
redirect_pry_io(InputTester.new('def another_test_method', 'play -m
|
194
|
-
pry
|
231
|
+
redirect_pry_io(InputTester.new('def another_test_method', 'play -m test_method --lines 2', 'show-input', 'exit-all'), str_output = StringIO.new) do
|
232
|
+
o.pry
|
195
233
|
end
|
196
234
|
str_output.string.should =~ /def another_test_method/
|
197
235
|
str_output.string.should =~ /:test_method_content/
|
198
|
-
$o = nil
|
199
236
|
end
|
200
237
|
|
201
238
|
|
202
239
|
it 'should play a method with the -m switch (multiple line)' do
|
203
|
-
|
204
|
-
class << $o
|
205
|
-
attr_accessor :var1, :var2
|
206
|
-
end
|
240
|
+
o = Object.new
|
207
241
|
|
208
|
-
def
|
242
|
+
def o.test_method
|
243
|
+
@var0 = 10
|
209
244
|
@var1 = 20
|
210
245
|
@var2 = 30
|
246
|
+
@var3 = 40
|
211
247
|
end
|
212
248
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2..3', "exit-all"), str_output = StringIO.new) do
|
217
|
-
b.pry
|
249
|
+
redirect_pry_io(InputTester.new('play -m test_method --lines 3..4', "exit-all"), str_output = StringIO.new) do
|
250
|
+
o.pry
|
218
251
|
end
|
219
252
|
|
220
|
-
|
221
|
-
|
253
|
+
o.instance_variable_get(:@var0).should == nil
|
254
|
+
o.instance_variable_get(:@var1).should == 20
|
255
|
+
o.instance_variable_get(:@var2).should == 30
|
256
|
+
o.instance_variable_get(:@var3).should == nil
|
222
257
|
str_output.string.should =~ /30/
|
223
258
|
str_output.string.should.not =~ /20/
|
224
259
|
end
|
225
|
-
|
226
260
|
end
|
227
261
|
|
228
262
|
describe "hist" do
|
@@ -235,31 +269,36 @@ describe "Pry::DefaultCommands::Input" do
|
|
235
269
|
@hist.push "hello"
|
236
270
|
@hist.push "world"
|
237
271
|
str_output = StringIO.new
|
238
|
-
redirect_pry_io(InputTester.new("hist", "exit-all"
|
272
|
+
redirect_pry_io(InputTester.new("hist", "exit-all"), str_output) do
|
239
273
|
pry
|
240
274
|
end
|
241
275
|
str_output.string.should =~ /hello\n.*world/
|
242
276
|
end
|
243
277
|
|
244
278
|
it 'should replay history correctly (single item)' do
|
245
|
-
|
246
|
-
@hist.push "
|
247
|
-
@hist.push "
|
279
|
+
o = Object.new
|
280
|
+
@hist.push "@x = 10"
|
281
|
+
@hist.push "@y = 20"
|
282
|
+
@hist.push "@z = 30"
|
248
283
|
str_output = StringIO.new
|
249
|
-
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"
|
250
|
-
pry
|
284
|
+
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"), str_output) do
|
285
|
+
o.pry
|
251
286
|
end
|
252
|
-
|
287
|
+
o.instance_variable_get(:@x).should == nil
|
288
|
+
o.instance_variable_get(:@y).should == nil
|
289
|
+
o.instance_variable_get(:@z).should == 30
|
253
290
|
end
|
254
291
|
|
255
292
|
it 'should replay a range of history correctly (range of items)' do
|
256
|
-
|
257
|
-
@hist.push "
|
293
|
+
o = Object.new
|
294
|
+
@hist.push "@x = 10"
|
295
|
+
@hist.push "@y = 20"
|
258
296
|
str_output = StringIO.new
|
259
|
-
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"
|
260
|
-
pry
|
297
|
+
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"), str_output) do
|
298
|
+
o.pry
|
261
299
|
end
|
262
|
-
|
300
|
+
o.instance_variable_get(:@x).should == 10
|
301
|
+
o.instance_variable_get(:@y).should == 20
|
263
302
|
end
|
264
303
|
|
265
304
|
it 'should grep for correct lines in history' do
|
@@ -274,21 +313,21 @@ describe "Pry::DefaultCommands::Input" do
|
|
274
313
|
@hist.push "place holder"
|
275
314
|
|
276
315
|
str_output = StringIO.new
|
277
|
-
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"
|
316
|
+
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"), str_output) do
|
278
317
|
pry
|
279
318
|
end
|
280
319
|
str_output.string.should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
|
281
320
|
|
282
321
|
# test more than one word in a regex match (def blah)
|
283
322
|
str_output = StringIO.new
|
284
|
-
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"
|
323
|
+
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"), str_output) do
|
285
324
|
pry
|
286
325
|
end
|
287
326
|
str_output.string.should =~ /def blah 1/
|
288
327
|
|
289
328
|
# test more than one word with leading white space in a regex match (def boink)
|
290
329
|
str_output = StringIO.new
|
291
|
-
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"
|
330
|
+
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"), str_output) do
|
292
331
|
pry
|
293
332
|
end
|
294
333
|
str_output.string.should =~ /def boink 2/
|
@@ -300,7 +339,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
300
339
|
end
|
301
340
|
|
302
341
|
str_output = StringIO.new
|
303
|
-
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"
|
342
|
+
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"), str_output) do
|
304
343
|
pry
|
305
344
|
end
|
306
345
|
|
@@ -316,7 +355,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
316
355
|
end
|
317
356
|
|
318
357
|
str_output = StringIO.new
|
319
|
-
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"
|
358
|
+
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"), str_output) do
|
320
359
|
pry
|
321
360
|
end
|
322
361
|
|
@@ -332,7 +371,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
332
371
|
end
|
333
372
|
|
334
373
|
str_output = StringIO.new
|
335
|
-
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"
|
374
|
+
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"), str_output) do
|
336
375
|
pry
|
337
376
|
end
|
338
377
|
|
@@ -342,7 +381,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
342
381
|
|
343
382
|
it "should not contain duplicated lines" do
|
344
383
|
str_output = StringIO.new
|
345
|
-
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all"
|
384
|
+
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all"), str_output) do
|
346
385
|
pry
|
347
386
|
end
|
348
387
|
|
@@ -351,7 +390,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
351
390
|
|
352
391
|
it "should not contain duplicated lines" do
|
353
392
|
str_output = StringIO.new
|
354
|
-
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all"
|
393
|
+
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all"), str_output) do
|
355
394
|
pry
|
356
395
|
end
|
357
396
|
|
@@ -48,52 +48,52 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should reload the file if it is a ruby file" do
|
51
|
-
tf = Tempfile.new(["
|
51
|
+
tf = Tempfile.new(["pry", ".rb"])
|
52
52
|
path = tf.path
|
53
53
|
|
54
54
|
mock_pry("edit #{path}", "$rand").should =~ /#{@rand}/
|
55
55
|
|
56
|
-
tf.close
|
56
|
+
tf.close(true)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should not reload the file if it is not a ruby file" do
|
60
|
-
tf = Tempfile.new(["
|
60
|
+
tf = Tempfile.new(["pry", ".py"])
|
61
61
|
path = tf.path
|
62
62
|
|
63
63
|
mock_pry("edit #{path}", "$rand").should.not =~ /#{@rand}/
|
64
64
|
|
65
|
-
tf.close
|
65
|
+
tf.close(true)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should not reload a ruby file if -n is given" do
|
69
|
-
tf = Tempfile.new(["
|
69
|
+
tf = Tempfile.new(["pry", ".rb"])
|
70
70
|
path = tf.path
|
71
71
|
|
72
72
|
mock_pry("edit -n #{path}", "$rand").should.not =~ /#{@rand}/
|
73
73
|
|
74
|
-
tf.close
|
74
|
+
tf.close(true)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should reload a non-ruby file if -r is given" do
|
78
|
-
tf = Tempfile.new(["
|
78
|
+
tf = Tempfile.new(["pry", ".pryrc"])
|
79
79
|
path = tf.path
|
80
80
|
|
81
81
|
mock_pry("edit -r #{path}", "$rand").should =~ /#{@rand}/
|
82
82
|
|
83
|
-
tf.close
|
83
|
+
tf.close(true)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe "with --ex" do
|
89
89
|
before do
|
90
|
-
@tf = Tempfile.new(["
|
90
|
+
@tf = Tempfile.new(["pry", ".rb"])
|
91
91
|
@path = @tf.path
|
92
92
|
@tf << "1\n2\nraise RuntimeError"
|
93
93
|
@tf.flush
|
94
94
|
end
|
95
95
|
after do
|
96
|
-
@tf.close
|
96
|
+
@tf.close(true)
|
97
97
|
File.unlink("#{@path}c") if File.exists?("#{@path}c") #rbx
|
98
98
|
end
|
99
99
|
it "should open the correct file" do
|
@@ -133,7 +133,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
133
133
|
|
134
134
|
it 'should start editor on first level of backtrace when --ex used with no argument ' do
|
135
135
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex"), :output => StringIO.new)
|
136
|
-
pry_instance.last_exception =
|
136
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
137
137
|
pry_instance.rep(self)
|
138
138
|
@__ex_file__.should == "a"
|
139
139
|
@__ex_line__.should == 1
|
@@ -141,7 +141,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
141
141
|
|
142
142
|
it 'should start editor on first level of backtrace when --ex 0 used ' do
|
143
143
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 0"), :output => StringIO.new)
|
144
|
-
pry_instance.last_exception =
|
144
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
145
145
|
pry_instance.rep(self)
|
146
146
|
@__ex_file__.should == "a"
|
147
147
|
@__ex_line__.should == 1
|
@@ -149,7 +149,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
149
149
|
|
150
150
|
it 'should start editor on second level of backtrace when --ex 1 used' do
|
151
151
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 1"), :output => StringIO.new)
|
152
|
-
pry_instance.last_exception =
|
152
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
153
153
|
pry_instance.rep(self)
|
154
154
|
@__ex_file__.should == "b"
|
155
155
|
@__ex_line__.should == 2
|
@@ -157,7 +157,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
157
157
|
|
158
158
|
it 'should start editor on third level of backtrace when --ex 2 used' do
|
159
159
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 2"), :output => StringIO.new)
|
160
|
-
pry_instance.last_exception =
|
160
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
161
161
|
pry_instance.rep(self)
|
162
162
|
@__ex_file__.should == "c"
|
163
163
|
@__ex_line__.should == 3
|
@@ -165,7 +165,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
165
165
|
|
166
166
|
it 'should display error message when backtrace level is out of bounds (using --ex 4)' do
|
167
167
|
pry_instance = Pry.new(:input => StringIO.new("edit -n --ex 4"), :output => str_output = StringIO.new)
|
168
|
-
pry_instance.last_exception =
|
168
|
+
pry_instance.last_exception = mock_exception("a:1", "b:2", "c:3")
|
169
169
|
pry_instance.rep(self)
|
170
170
|
str_output.string.should =~ /Exception has no associated file/
|
171
171
|
end
|
@@ -254,6 +254,10 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
254
254
|
str_output.string.should =~ /def sample/
|
255
255
|
end
|
256
256
|
|
257
|
+
it 'should output help' do
|
258
|
+
mock_pry('show-method -h').should =~ /Usage: show-method/
|
259
|
+
end
|
260
|
+
|
257
261
|
it 'should output a method\'s source with line numbers' do
|
258
262
|
str_output = StringIO.new
|
259
263
|
redirect_pry_io(InputTester.new("show-method -l sample_method", "exit-all"), str_output) do
|
@@ -316,6 +320,59 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
316
320
|
str_output.string.should =~ /Mr flibble/
|
317
321
|
end
|
318
322
|
|
323
|
+
it "should find instance methods with -M" do
|
324
|
+
c = Class.new{ def moo; "ve over!"; end }
|
325
|
+
mock_pry(binding, "cd c","show-method -M moo").should =~ /ve over/
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should not find instance methods with -m" do
|
329
|
+
c = Class.new{ def moo; "ve over!"; end }
|
330
|
+
mock_pry(binding, "cd c", "show-method -m moo").should =~ /could not be found/
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should find normal methods with -m" do
|
334
|
+
c = Class.new{ def self.moo; "ve over!"; end }
|
335
|
+
mock_pry(binding, "cd c", "show-method -m moo").should =~ /ve over/
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should not find normal methods with -M" do
|
339
|
+
c = Class.new{ def self.moo; "ve over!"; end }
|
340
|
+
mock_pry(binding, "cd c", "show-method -M moo").should =~ /could not be found/
|
341
|
+
end
|
342
|
+
|
343
|
+
it "should find normal methods with no -M or -m" do
|
344
|
+
c = Class.new{ def self.moo; "ve over!"; end }
|
345
|
+
mock_pry(binding, "cd c", "show-method moo").should =~ /ve over/
|
346
|
+
end
|
347
|
+
|
348
|
+
it "should find instance methods with no -M or -m" do
|
349
|
+
c = Class.new{ def moo; "ve over!"; end }
|
350
|
+
mock_pry(binding, "cd c", "show-method moo").should =~ /ve over/
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should find super methods" do
|
354
|
+
class Foo
|
355
|
+
def foo(*bars)
|
356
|
+
:super_wibble
|
357
|
+
end
|
358
|
+
end
|
359
|
+
o = Foo.new
|
360
|
+
Object.remove_const(:Foo)
|
361
|
+
def o.foo(*bars)
|
362
|
+
:wibble
|
363
|
+
end
|
364
|
+
|
365
|
+
mock_pry(binding, "show-method --super o.foo").should =~ /:super_wibble/
|
366
|
+
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should not raise an exception when a non-extant super method is requested" do
|
370
|
+
o = Object.new
|
371
|
+
def o.foo(*bars); end
|
372
|
+
|
373
|
+
mock_pry(binding, "show-method --super o.foo").should =~ /'self.foo' has no super method/
|
374
|
+
end
|
375
|
+
|
319
376
|
# dynamically defined method source retrieval is only supported in
|
320
377
|
# 1.9 - where Method#source_location is native
|
321
378
|
if RUBY_VERSION =~ /1.9/
|
@@ -364,7 +421,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
364
421
|
describe "edit-method" do
|
365
422
|
describe "on a method defined in a file" do
|
366
423
|
before do
|
367
|
-
@tempfile = Tempfile.new(['
|
424
|
+
@tempfile = Tempfile.new(['pry', '*.rb'])
|
368
425
|
@tempfile.puts <<-EOS
|
369
426
|
module A
|
370
427
|
def a
|
@@ -398,7 +455,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
398
455
|
end
|
399
456
|
|
400
457
|
after do
|
401
|
-
@tempfile.close
|
458
|
+
@tempfile.close(true)
|
402
459
|
end
|
403
460
|
|
404
461
|
describe 'without -p' do
|