pry 0.9.8.4-java → 0.9.9-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +26 -0
  3. data/README.markdown +3 -3
  4. data/lib/pry.rb +9 -1
  5. data/lib/pry/code.rb +93 -0
  6. data/lib/pry/command.rb +35 -22
  7. data/lib/pry/command_set.rb +97 -67
  8. data/lib/pry/config.rb +63 -10
  9. data/lib/pry/core_extensions.rb +24 -18
  10. data/lib/pry/default_commands/context.rb +72 -12
  11. data/lib/pry/default_commands/easter_eggs.rb +4 -0
  12. data/lib/pry/default_commands/editing.rb +43 -15
  13. data/lib/pry/default_commands/find_method.rb +171 -0
  14. data/lib/pry/default_commands/hist.rb +10 -6
  15. data/lib/pry/default_commands/introspection.rb +183 -30
  16. data/lib/pry/default_commands/ls.rb +77 -7
  17. data/lib/pry/default_commands/misc.rb +1 -0
  18. data/lib/pry/default_commands/navigating_pry.rb +1 -8
  19. data/lib/pry/helpers/base_helpers.rb +10 -2
  20. data/lib/pry/helpers/command_helpers.rb +23 -40
  21. data/lib/pry/helpers/documentation_helpers.rb +65 -0
  22. data/lib/pry/indent.rb +17 -4
  23. data/lib/pry/method.rb +61 -45
  24. data/lib/pry/pry_class.rb +9 -3
  25. data/lib/pry/pry_instance.rb +99 -65
  26. data/lib/pry/rbx_method.rb +2 -9
  27. data/lib/pry/version.rb +1 -1
  28. data/lib/pry/wrapped_module.rb +236 -1
  29. data/pry.gemspec +5 -5
  30. data/test/helper.rb +22 -0
  31. data/test/test_command.rb +29 -0
  32. data/test/test_command_integration.rb +193 -10
  33. data/test/test_command_set.rb +82 -17
  34. data/test/test_default_commands/test_cd.rb +16 -0
  35. data/test/test_default_commands/test_context.rb +61 -0
  36. data/test/test_default_commands/test_documentation.rb +163 -43
  37. data/test/test_default_commands/test_find_method.rb +42 -0
  38. data/test/test_default_commands/test_input.rb +32 -0
  39. data/test/test_default_commands/test_introspection.rb +50 -197
  40. data/test/test_default_commands/test_ls.rb +22 -0
  41. data/test/test_default_commands/test_show_source.rb +306 -0
  42. data/test/test_pry.rb +3 -3
  43. data/test/test_pry_defaults.rb +21 -0
  44. data/test/test_sticky_locals.rb +81 -1
  45. data/test/test_syntax_checking.rb +7 -6
  46. metadata +24 -16
@@ -44,6 +44,18 @@ describe "Pry::DefaultCommands::Context" do
44
44
  Cor.new.blimey!
45
45
  Object.remove_const(:Cor)
46
46
  end
47
+
48
+ it 'should work in objects with no method methods' do
49
+ class Cor
50
+ def blimey!
51
+ mock_pry(binding, 'whereami').should =~ /Cor[#]blimey!/
52
+ end
53
+
54
+ def method; "moo"; end
55
+ end
56
+ Cor.new.blimey!
57
+ Object.remove_const(:Cor)
58
+ end
47
59
  end
48
60
 
49
61
  describe "exit" do
@@ -267,4 +279,53 @@ describe "Pry::DefaultCommands::Context" do
267
279
  $obj.should == :mon_ouie
268
280
  end
269
281
  end
282
+
283
+ describe "raise-up" do
284
+ it "should raise the exception with raise-up" do
285
+ redirect_pry_io(InputTester.new("raise NoMethodError", "raise-up NoMethodError"),StringIO.new) do
286
+ lambda { Pry.new.repl(0) }.should.raise NoMethodError
287
+ end
288
+ end
289
+
290
+ it "should raise an unamed exception with raise-up" do
291
+ redirect_pry_io(InputTester.new("raise 'stop'","raise-up 'noreally'"),StringIO.new) do
292
+ lambda { Pry.new.repl(0) }.should.raise RuntimeError, "noreally"
293
+ end
294
+ end
295
+
296
+ it "should eat the exception at the last new pry instance on raise-up" do
297
+ b = Pry.binding_for(:outer)
298
+ b.eval("x = :inner")
299
+
300
+ redirect_pry_io(InputTester.new("x.pry", "raise NoMethodError",
301
+ "$inner = self", "raise-up NoMethodError", "$outer = self", "exit-all"),StringIO.new) do
302
+ b.pry
303
+ end
304
+ $inner.should == :inner
305
+ $outer.should == :outer
306
+ end
307
+
308
+ it "should raise the most recently raised exception" do
309
+ lambda { mock_pry("raise NameError, 'homographery'","raise-up") }.should.raise NameError, 'homographery'
310
+ end
311
+
312
+ it "should allow you to cd up and (eventually) out" do
313
+ $deep = $inner = $outer = nil
314
+ b = Pry.binding_for(:outer)
315
+ b.eval("x = :inner")
316
+ redirect_pry_io(InputTester.new("cd x", "raise NoMethodError","$inner = self",
317
+ "deep = :deep", "cd deep","$deep = self","raise-up NoMethodError", "raise-up", "$outer = self", "raise-up", "exit-all"),StringIO.new) do
318
+ lambda { b.pry }.should.raise NoMethodError
319
+ end
320
+ $deep.should == :deep
321
+ $inner.should == :inner
322
+ $outer.should == :outer
323
+ end
324
+ end
325
+
326
+ describe "raise-up!" do
327
+ it "should jump immediately out of nested context's" do
328
+ lambda { mock_pry("cd 1", "cd 2", "cd 3", "raise-up! 'fancy that...'") }.should.raise RuntimeError, 'fancy that...'
329
+ end
330
+ end
270
331
  end
@@ -1,66 +1,186 @@
1
1
  require 'helper'
2
2
 
3
- describe "Pry::DefaultCommands::Documentation" do
4
- describe "show-doc" do
5
- it 'should output a method\'s documentation' do
6
- redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output=StringIO.new) do
7
- pry
3
+ if !mri18_and_no_real_source_location?
4
+ describe "Pry::DefaultCommands::Documentation" do
5
+ describe "show-doc" do
6
+ it 'should output a method\'s documentation' do
7
+ redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output=StringIO.new) do
8
+ pry
9
+ end
10
+
11
+ str_output.string.should =~ /sample doc/
8
12
  end
9
13
 
10
- str_output.string.should =~ /sample doc/
11
- end
14
+ it 'should output a method\'s documentation with line numbers' do
15
+ redirect_pry_io(InputTester.new("show-doc sample_method -l", "exit-all"), str_output=StringIO.new) do
16
+ pry
17
+ end
12
18
 
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
19
+ str_output.string.should =~ /\d: sample doc/
16
20
  end
17
21
 
18
- str_output.string.should =~ /\d: sample doc/
19
- end
22
+ it 'should output a method\'s documentation with line numbers (base one)' do
23
+ redirect_pry_io(InputTester.new("show-doc sample_method -b", "exit-all"), str_output=StringIO.new) do
24
+ pry
25
+ end
20
26
 
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
27
+ str_output.string.should =~ /1: sample doc/
24
28
  end
25
29
 
26
- str_output.string.should =~ /1: sample doc/
27
- end
30
+ it 'should output a method\'s documentation if inside method without needing to use method name' do
31
+ o = Object.new
32
+
33
+ # sample comment
34
+ def o.sample
35
+ redirect_pry_io(InputTester.new("show-doc", "exit-all"), $out=StringIO.new) do
36
+ binding.pry
37
+ end
38
+ end
39
+ o.sample
40
+ $out.string.should =~ /sample comment/
41
+ $out = nil
42
+ end
43
+
44
+ it "should be able to find super methods" do
45
+
46
+ c = Class.new{
47
+ # classy initialize!
48
+ def initialize(*args); end
49
+ }
50
+
51
+ d = Class.new(c){
52
+ # grungy initialize??
53
+ def initialize(*args, &block); end
54
+ }
28
55
 
29
- it 'should output a method\'s documentation if inside method without needing to use method name' do
30
- o = Object.new
56
+ o = d.new
31
57
 
32
- # sample comment
33
- def o.sample
34
- redirect_pry_io(InputTester.new("show-doc", "exit-all"), $out=StringIO.new) do
35
- binding.pry
36
- end
58
+ # instancey initialize!
59
+ def o.initialize; end
60
+
61
+ mock_pry(binding, "show-doc o.initialize").should =~ /instancey initialize/
62
+ mock_pry(binding, "show-doc --super o.initialize").should =~ /grungy initialize/
63
+ mock_pry(binding, "show-doc o.initialize -ss").should =~ /classy initialize/
64
+ mock_pry(binding, "show-doc --super o.initialize -ss").should == mock_pry("show-doc Object#initialize")
37
65
  end
38
- o.sample
39
- $out.string.should =~ /sample comment/
40
- $out = nil
41
66
  end
42
67
 
43
- it "should be able to find super methods" do
68
+ describe "on modules" do
69
+ before do
70
+ # god this is boring1
71
+ class ShowSourceTestClass
72
+ def alpha
73
+ end
74
+ end
75
+
76
+ # god this is boring2
77
+ module ShowSourceTestModule
78
+ def alpha
79
+ end
80
+ end
81
+
82
+ # god this is boring3
83
+ ShowSourceTestClassWeirdSyntax = Class.new do
84
+ def beta
85
+ end
86
+ end
87
+
88
+ # god this is boring4
89
+ ShowSourceTestModuleWeirdSyntax = Module.new do
90
+ def beta
91
+ end
92
+ end
93
+ end
94
+
95
+ after do
96
+ Object.remove_const :ShowSourceTestClass
97
+ Object.remove_const :ShowSourceTestClassWeirdSyntax
98
+ Object.remove_const :ShowSourceTestModule
99
+ Object.remove_const :ShowSourceTestModuleWeirdSyntax
100
+ end
44
101
 
45
- c = Class.new{
46
- # classy initialize!
47
- def initialize(*args); end
48
- }
102
+ describe "basic functionality, should show docs for top-level module definitions" do
103
+ it 'should show docs for a class' do
104
+ mock_pry("show-doc ShowSourceTestClass").should =~ /god this is boring1/
105
+ end
49
106
 
50
- d = Class.new(c){
51
- # grungy initialize??
52
- def initialize(*args, &block); end
53
- }
107
+ it 'should show docs for a module' do
108
+ mock_pry("show-doc ShowSourceTestModule").should =~ /god this is boring2/
109
+ end
54
110
 
55
- o = d.new
111
+ it 'should show docs for a class when Const = Class.new syntax is used' do
112
+ mock_pry("show-doc ShowSourceTestClassWeirdSyntax").should =~ /god this is boring3/
113
+ end
56
114
 
57
- # instancey initialize!
58
- def o.initialize; end
115
+ it 'should show docs for a module when Const = Module.new syntax is used' do
116
+ mock_pry("show-doc ShowSourceTestModuleWeirdSyntax").should =~ /god this is boring4/
117
+ end
118
+ end
59
119
 
60
- mock_pry(binding, "show-doc o.initialize").should =~ /instancey initialize/
61
- mock_pry(binding, "show-doc --super o.initialize").should =~ /grungy initialize/
62
- mock_pry(binding, "show-doc o.initialize -ss").should =~ /classy initialize/
63
- mock_pry(binding, "show-doc --super o.initialize -ss").should == mock_pry("show-doc Object#initialize")
120
+ if !Pry::Helpers::BaseHelpers.mri_18?
121
+ describe "in REPL" do
122
+ it 'should find class defined in repl' do
123
+ mock_pry("# hello tobina", "class TobinaMyDog", "def woof", "end", "end", "show-doc TobinaMyDog").should =~ /hello tobina/
124
+ Object.remove_const :TobinaMyDog
125
+ end
126
+ end
127
+ end
128
+
129
+ it 'should lookup module name with respect to current context' do
130
+ constant_scope(:AlphaClass, :BetaClass) do
131
+
132
+ # top-level beta
133
+ class BetaClass
134
+ def alpha
135
+ end
136
+ end
137
+
138
+ class AlphaClass
139
+
140
+ # nested beta
141
+ class BetaClass
142
+ def beta
143
+ end
144
+ end
145
+ end
146
+
147
+ redirect_pry_io(InputTester.new("show-doc BetaClass", "exit-all"), out=StringIO.new) do
148
+ AlphaClass.pry
149
+ end
150
+
151
+ out.string.should =~ /nested beta/
152
+ end
153
+ end
154
+
155
+ it 'should lookup nested modules' do
156
+ constant_scope(:AlphaClass) do
157
+ class AlphaClass
158
+
159
+ # nested beta
160
+ class BetaClass
161
+ def beta
162
+ end
163
+ end
164
+ end
165
+
166
+ mock_pry("show-doc AlphaClass::BetaClass").should =~ /nested beta/
167
+ end
168
+ end
169
+
170
+ describe "show-doc -a" do
171
+ it 'should show the docs for all monkeypatches defined in different files' do
172
+
173
+ # local monkeypatch
174
+ class TestClassForShowSource
175
+ def beta
176
+ end
177
+ end
178
+
179
+ result = mock_pry("show-doc TestClassForShowSource -a")
180
+ result.should =~ /used by/
181
+ result.should =~ /local monkeypatch/
182
+ end
183
+ end
64
184
  end
65
185
  end
66
186
  end
@@ -0,0 +1,42 @@
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
+ end
17
+
18
+ describe "find-command" do
19
+ describe "find matching methods by name regex (-n option)" do
20
+ it "should find a method by regex" do
21
+ mock_pry("find-method hell MyKlass").should =~ /MyKlass.*?hello/m
22
+ end
23
+
24
+ it "should NOT match a method that does not match the regex" do
25
+ mock_pry("find-method hell MyKlass").should.not =~ /MyKlass.*?goodbye/m
26
+ end
27
+ end
28
+
29
+ describe "find matching methods by content regex (-c option)" do
30
+ it "should find a method by regex" do
31
+ mock_pry("find-method -c timothy MyKlass").should =~ /MyKlass.*?hello/m
32
+ end
33
+
34
+ it "should NOT match a method that does not match the regex" do
35
+ mock_pry("find-method timothy MyKlass").should.not =~ /MyKlass.*?goodbye/m
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ Object.remove_const(:MyKlass)
42
+ end
@@ -347,6 +347,38 @@ describe "Pry::DefaultCommands::Input" do
347
347
  str_output.string.should =~ /x\n\d+:.*y\n\d+:.*z/
348
348
  end
349
349
 
350
+ it 'should apply --tail after --grep' do
351
+ @hist.push "print 1"
352
+ @hist.push "print 2"
353
+ @hist.push "puts 3"
354
+ @hist.push "print 4"
355
+ @hist.push "puts 5"
356
+
357
+ str_output = StringIO.new
358
+ redirect_pry_io(InputTester.new("hist --tail 2 --grep print", "exit-all"), str_output) do
359
+ pry
360
+ end
361
+
362
+ str_output.string.each_line.count.should == 2
363
+ str_output.string.should =~ /\d:.*?print 2\n\d:.*?print 4/
364
+ end
365
+
366
+ it 'should apply --head after --grep' do
367
+ @hist.push "puts 1"
368
+ @hist.push "print 2"
369
+ @hist.push "puts 3"
370
+ @hist.push "print 4"
371
+ @hist.push "print 5"
372
+
373
+ str_output = StringIO.new
374
+ redirect_pry_io(InputTester.new("hist --head 2 --grep print", "exit-all"), str_output) do
375
+ pry
376
+ end
377
+
378
+ str_output.string.each_line.count.should == 2
379
+ str_output.string.should =~ /\d:.*?print 2\n\d:.*?print 4/
380
+ end
381
+
350
382
  # strangeness in this test is due to bug in Readline::HISTORY not
351
383
  # always registering first line of input
352
384
  it 'should return first N lines in history with --head switch' do
@@ -83,6 +83,23 @@ describe "Pry::DefaultCommands::Introspection" do
83
83
  tf.close(true)
84
84
  end
85
85
  end
86
+
87
+ describe do
88
+ before do
89
+ @reloading = nil
90
+ Pry.config.editor = lambda do |file, line, reloading|
91
+ @file = file; @line = line; @reloading = reloading
92
+ nil
93
+ end
94
+ end
95
+
96
+ it "should pass the editor a reloading arg" do
97
+ mock_pry("edit foo.rb")
98
+ @reloading.should == true
99
+ mock_pry("edit -n foo.rb")
100
+ @reloading.should == false
101
+ end
102
+ end
86
103
  end
87
104
 
88
105
  describe "with --ex" do
@@ -244,203 +261,6 @@ describe "Pry::DefaultCommands::Introspection" do
244
261
  end
245
262
  end
246
263
 
247
- describe "show-method" do
248
- it 'should output a method\'s source' do
249
- str_output = StringIO.new
250
- redirect_pry_io(InputTester.new("show-method sample_method", "exit-all"), str_output) do
251
- pry
252
- end
253
-
254
- str_output.string.should =~ /def sample/
255
- end
256
-
257
- it 'should output help' do
258
- mock_pry('show-method -h').should =~ /Usage: show-method/
259
- end
260
-
261
- it 'should output a method\'s source with line numbers' do
262
- str_output = StringIO.new
263
- redirect_pry_io(InputTester.new("show-method -l sample_method", "exit-all"), str_output) do
264
- pry
265
- end
266
-
267
- str_output.string.should =~ /\d+: def sample/
268
- end
269
-
270
- it 'should output a method\'s source with line numbers starting at 1' do
271
- str_output = StringIO.new
272
- redirect_pry_io(InputTester.new("show-method -b sample_method", "exit-all"), str_output) do
273
- pry
274
- end
275
-
276
- str_output.string.should =~ /1: def sample/
277
- end
278
-
279
- it 'should output a method\'s source if inside method without needing to use method name' do
280
- $str_output = StringIO.new
281
-
282
- o = Object.new
283
- def o.sample
284
- redirect_pry_io(InputTester.new("show-method", "exit-all"), $str_output) do
285
- binding.pry
286
- end
287
- end
288
- o.sample
289
-
290
- $str_output.string.should =~ /def o.sample/
291
- $str_output = nil
292
- end
293
-
294
- it 'should output a method\'s source if inside method without needing to use method name, and using the -l switch' do
295
- $str_output = StringIO.new
296
-
297
- o = Object.new
298
- def o.sample
299
- redirect_pry_io(InputTester.new("show-method -l", "exit-all"), $str_output) do
300
- binding.pry
301
- end
302
- end
303
- o.sample
304
-
305
- $str_output.string.should =~ /\d+: def o.sample/
306
- $str_output = nil
307
- end
308
-
309
- it "should find methods even if there are spaces in the arguments" do
310
- o = Object.new
311
- def o.foo(*bars);
312
- "Mr flibble"
313
- self;
314
- end
315
-
316
- str_output = StringIO.new
317
- redirect_pry_io(InputTester.new("show-method o.foo('bar', 'baz bam').foo", "exit-all"), str_output) do
318
- binding.pry
319
- end
320
- str_output.string.should =~ /Mr flibble/
321
- end
322
-
323
- it "should find methods even if the object has an overridden method method" do
324
- c = Class.new{
325
- def method;
326
- 98
327
- end
328
- }
329
-
330
- mock_pry(binding, "show-method c.new.method").should =~ /98/
331
- end
332
-
333
- it "should find instance_methods even if the class has an override instance_method method" do
334
- c = Class.new{
335
- def method;
336
- 98
337
- end
338
-
339
- def self.instance_method; 789; end
340
- }
341
-
342
- mock_pry(binding, "show-method c#method").should =~ /98/
343
-
344
- end
345
-
346
- it "should find instance methods with -M" do
347
- c = Class.new{ def moo; "ve over!"; end }
348
- mock_pry(binding, "cd c","show-method -M moo").should =~ /ve over/
349
- end
350
-
351
- it "should not find instance methods with -m" do
352
- c = Class.new{ def moo; "ve over!"; end }
353
- mock_pry(binding, "cd c", "show-method -m moo").should =~ /could not be found/
354
- end
355
-
356
- it "should find normal methods with -m" do
357
- c = Class.new{ def self.moo; "ve over!"; end }
358
- mock_pry(binding, "cd c", "show-method -m moo").should =~ /ve over/
359
- end
360
-
361
- it "should not find normal methods with -M" do
362
- c = Class.new{ def self.moo; "ve over!"; end }
363
- mock_pry(binding, "cd c", "show-method -M moo").should =~ /could not be found/
364
- end
365
-
366
- it "should find normal methods with no -M or -m" do
367
- c = Class.new{ def self.moo; "ve over!"; end }
368
- mock_pry(binding, "cd c", "show-method moo").should =~ /ve over/
369
- end
370
-
371
- it "should find instance methods with no -M or -m" do
372
- c = Class.new{ def moo; "ve over!"; end }
373
- mock_pry(binding, "cd c", "show-method moo").should =~ /ve over/
374
- end
375
-
376
- it "should find super methods" do
377
- class Foo
378
- def foo(*bars)
379
- :super_wibble
380
- end
381
- end
382
- o = Foo.new
383
- Object.remove_const(:Foo)
384
- def o.foo(*bars)
385
- :wibble
386
- end
387
-
388
- mock_pry(binding, "show-method --super o.foo").should =~ /:super_wibble/
389
-
390
- end
391
-
392
- it "should not raise an exception when a non-extant super method is requested" do
393
- o = Object.new
394
- def o.foo(*bars); end
395
-
396
- mock_pry(binding, "show-method --super o.foo").should =~ /'self.foo' has no super method/
397
- end
398
-
399
- # dynamically defined method source retrieval is only supported in
400
- # 1.9 - where Method#source_location is native
401
- if RUBY_VERSION =~ /1.9/
402
- it 'should output a method\'s source for a method defined inside pry' do
403
- str_output = StringIO.new
404
- redirect_pry_io(InputTester.new("def dyna_method", ":testing", "end", "show-method dyna_method"), str_output) do
405
- TOPLEVEL_BINDING.pry
406
- end
407
-
408
- str_output.string.should =~ /def dyna_method/
409
- Object.remove_method :dyna_method
410
- end
411
-
412
- it 'should output a method\'s source for a method defined inside pry, even if exceptions raised before hand' do
413
- str_output = StringIO.new
414
- redirect_pry_io(InputTester.new("bad code", "123", "bad code 2", "1 + 2", "def dyna_method", ":testing", "end", "show-method dyna_method"), str_output) do
415
- TOPLEVEL_BINDING.pry
416
- end
417
-
418
- str_output.string.should =~ /def dyna_method/
419
- Object.remove_method :dyna_method
420
- end
421
-
422
- it 'should output an instance method\'s source for a method defined inside pry' do
423
- str_output = StringIO.new
424
- redirect_pry_io(InputTester.new("class A", "def yo", "end", "end", "show-method A#yo"), str_output) do
425
- TOPLEVEL_BINDING.pry
426
- end
427
-
428
- str_output.string.should =~ /def yo/
429
- Object.remove_const :A
430
- end
431
-
432
- it 'should output an instance method\'s source for a method defined inside pry using define_method' do
433
- str_output = StringIO.new
434
- redirect_pry_io(InputTester.new("class A", "define_method(:yup) {}", "end", "show-method A#yup"), str_output) do
435
- TOPLEVEL_BINDING.pry
436
- end
437
-
438
- str_output.string.should =~ /define_method\(:yup\)/
439
- Object.remove_const :A
440
- end
441
- end
442
- end
443
-
444
264
  describe "edit-method" do
445
265
  describe "on a method defined in a file" do
446
266
  before do
@@ -471,6 +291,10 @@ describe "Pry::DefaultCommands::Introspection" do
471
291
  super
472
292
  end
473
293
  alias c b
294
+
295
+ def y?
296
+ :because
297
+ end
474
298
  end
475
299
  EOS
476
300
  @tempfile.flush
@@ -572,6 +396,13 @@ describe "Pry::DefaultCommands::Introspection" do
572
396
  X.instance_method(:a).owner.should == A
573
397
  X.new.a.should == :maybe
574
398
  end
399
+
400
+ it "should successfully replace a method with a question mark" do
401
+ mock_pry("edit-method -p X#y?")
402
+
403
+ X.instance_method(:y?).owner.should == X
404
+ X.new.y?.should == :maybe
405
+ end
575
406
  end
576
407
 
577
408
  describe 'on an aliased method' do
@@ -599,6 +430,28 @@ describe "Pry::DefaultCommands::Introspection" do
599
430
  X.new.c.should == :kindaaa
600
431
  end
601
432
  end
433
+
434
+ describe 'with three-arg editor' do
435
+ before do
436
+ @old_editor = Pry.config.editor
437
+ @file, @line, @reloading = nil, nil, nil
438
+ Pry.config.editor = lambda do |file, line, reloading|
439
+ @file = file; @line = line; @reloading = reloading
440
+ nil
441
+ end
442
+ end
443
+ after do
444
+ Pry.config.editor = @old_editor
445
+ end
446
+
447
+ it "should pass the editor a reloading arg" do
448
+ mock_pry('edit-method X.x')
449
+ @reloading.should == true
450
+ mock_pry('edit-method -n X.x')
451
+ @reloading.should == false
452
+ end
453
+ end
454
+
602
455
  end
603
456
  end
604
457