pry 0.9.9.6pre2-i386-mingw32 → 0.9.10-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +41 -0
- data/CONTRIBUTORS +27 -26
- data/README.markdown +4 -4
- data/Rakefile +2 -2
- data/lib/pry.rb +25 -19
- data/lib/pry/cli.rb +31 -10
- data/lib/pry/code.rb +41 -83
- data/lib/pry/command.rb +87 -76
- data/lib/pry/command_set.rb +13 -20
- data/lib/pry/completion.rb +139 -121
- data/lib/pry/config.rb +4 -0
- data/lib/pry/core_extensions.rb +88 -31
- data/lib/pry/default_commands/cd.rb +31 -8
- data/lib/pry/default_commands/context.rb +4 -58
- data/lib/pry/default_commands/easter_eggs.rb +1 -1
- data/lib/pry/default_commands/editing.rb +21 -14
- data/lib/pry/default_commands/find_method.rb +5 -7
- data/lib/pry/default_commands/gist.rb +187 -0
- data/lib/pry/default_commands/hist.rb +6 -6
- data/lib/pry/default_commands/input_and_output.rb +73 -129
- data/lib/pry/default_commands/introspection.rb +107 -52
- data/lib/pry/default_commands/ls.rb +1 -1
- data/lib/pry/default_commands/misc.rb +0 -5
- data/lib/pry/default_commands/whereami.rb +92 -0
- data/lib/pry/helpers/base_helpers.rb +6 -1
- data/lib/pry/helpers/command_helpers.rb +30 -9
- data/lib/pry/helpers/documentation_helpers.rb +7 -7
- data/lib/pry/helpers/options_helpers.rb +1 -1
- data/lib/pry/helpers/text.rb +7 -9
- data/lib/pry/history.rb +15 -2
- data/lib/pry/hooks.rb +1 -1
- data/lib/pry/indent.rb +17 -10
- data/lib/pry/method.rb +35 -19
- data/lib/pry/module_candidate.rb +130 -0
- data/lib/pry/pry_class.rb +54 -22
- data/lib/pry/pry_instance.rb +71 -14
- data/lib/pry/repl_file_loader.rb +80 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +121 -142
- data/pry.gemspec +13 -13
- data/test/candidate_helper1.rb +11 -0
- data/test/candidate_helper2.rb +8 -0
- data/test/helper.rb +16 -0
- data/test/test_code.rb +1 -1
- data/test/test_command.rb +364 -270
- data/test/test_command_integration.rb +235 -267
- data/test/test_completion.rb +36 -0
- data/test/test_control_d_handler.rb +45 -0
- data/test/test_default_commands/example.erb +5 -0
- data/test/test_default_commands/test_cd.rb +316 -11
- data/test/test_default_commands/test_context.rb +143 -192
- data/test/test_default_commands/test_documentation.rb +81 -14
- data/test/test_default_commands/test_find_method.rb +10 -2
- data/test/test_default_commands/test_input.rb +102 -111
- data/test/test_default_commands/test_introspection.rb +17 -12
- data/test/test_default_commands/test_ls.rb +8 -6
- data/test/test_default_commands/test_shell.rb +18 -15
- data/test/test_default_commands/test_show_source.rb +170 -44
- data/test/test_exception_whitelist.rb +6 -2
- data/test/test_hooks.rb +32 -0
- data/test/test_input_stack.rb +19 -16
- data/test/test_method.rb +0 -4
- data/test/test_prompt.rb +60 -0
- data/test/test_pry.rb +23 -31
- data/test/test_pry_defaults.rb +75 -57
- data/test/test_syntax_checking.rb +12 -11
- data/test/test_wrapped_module.rb +103 -0
- metadata +72 -26
@@ -3,42 +3,47 @@ require 'helper'
|
|
3
3
|
if !mri18_and_no_real_source_location?
|
4
4
|
describe "Pry::DefaultCommands::Documentation" do
|
5
5
|
describe "show-doc" do
|
6
|
+
before do
|
7
|
+
@str_output = StringIO.new
|
8
|
+
@o = Object.new
|
9
|
+
end
|
10
|
+
|
6
11
|
it 'should output a method\'s documentation' do
|
7
|
-
redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output
|
12
|
+
redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), @str_output) do
|
8
13
|
pry
|
9
14
|
end
|
10
15
|
|
11
|
-
str_output.string.should =~ /sample doc/
|
16
|
+
@str_output.string.should =~ /sample doc/
|
12
17
|
end
|
13
18
|
|
14
19
|
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
|
20
|
+
redirect_pry_io(InputTester.new("show-doc sample_method -l", "exit-all"), @str_output) do
|
16
21
|
pry
|
17
22
|
end
|
18
23
|
|
19
|
-
str_output.string.should =~ /\d: sample doc/
|
24
|
+
@str_output.string.should =~ /\d: sample doc/
|
20
25
|
end
|
21
26
|
|
22
27
|
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
|
28
|
+
redirect_pry_io(InputTester.new("show-doc sample_method -b", "exit-all"), @str_output) do
|
24
29
|
pry
|
25
30
|
end
|
26
31
|
|
27
|
-
str_output.string.should =~ /1: sample doc/
|
32
|
+
@str_output.string.should =~ /1: sample doc/
|
28
33
|
end
|
29
34
|
|
30
35
|
it 'should output a method\'s documentation if inside method without needing to use method name' do
|
31
|
-
|
36
|
+
Pad.str_output = @str_output
|
32
37
|
|
33
38
|
# sample comment
|
34
|
-
def o.sample
|
35
|
-
redirect_pry_io(InputTester.new("show-doc", "exit-all"),
|
39
|
+
def @o.sample
|
40
|
+
redirect_pry_io(InputTester.new("show-doc", "exit-all"), Pad.str_output) do
|
36
41
|
binding.pry
|
37
42
|
end
|
38
43
|
end
|
39
|
-
o.sample
|
40
|
-
|
41
|
-
|
44
|
+
@o.sample
|
45
|
+
|
46
|
+
Pad.str_output.string.should =~ /sample comment/
|
42
47
|
end
|
43
48
|
|
44
49
|
it "should be able to find super methods" do
|
@@ -206,11 +211,11 @@ if !mri18_and_no_real_source_location?
|
|
206
211
|
end
|
207
212
|
end
|
208
213
|
|
209
|
-
redirect_pry_io(InputTester.new("show-doc BetaClass", "exit-all"),
|
214
|
+
redirect_pry_io(InputTester.new("show-doc BetaClass", "exit-all"), outp=StringIO.new) do
|
210
215
|
AlphaClass.pry
|
211
216
|
end
|
212
217
|
|
213
|
-
|
218
|
+
outp.string.should =~ /nested beta/
|
214
219
|
end
|
215
220
|
end
|
216
221
|
|
@@ -243,6 +248,68 @@ if !mri18_and_no_real_source_location?
|
|
243
248
|
result.should =~ /local monkeypatch/
|
244
249
|
end
|
245
250
|
end
|
251
|
+
|
252
|
+
describe "when no class/module arg is given" do
|
253
|
+
before do
|
254
|
+
module TestHost
|
255
|
+
|
256
|
+
# hello there froggy
|
257
|
+
module M
|
258
|
+
def d; end
|
259
|
+
def e; end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
after do
|
265
|
+
Object.remove_const(:TestHost)
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'should return doc for current module' do
|
269
|
+
redirect_pry_io(InputTester.new("show-doc"), out = StringIO.new) do
|
270
|
+
Pry.start(TestHost::M)
|
271
|
+
end
|
272
|
+
|
273
|
+
out.string.should =~ /hello there froggy/
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|
277
|
+
|
278
|
+
|
279
|
+
describe "should skip over broken modules" do
|
280
|
+
before do
|
281
|
+
module TestHost
|
282
|
+
|
283
|
+
# hello
|
284
|
+
module M
|
285
|
+
binding.eval("def a; end", "dummy.rb", 1)
|
286
|
+
binding.eval("def b; end", "dummy.rb", 2)
|
287
|
+
binding.eval("def c; end", "dummy.rb", 3)
|
288
|
+
end
|
289
|
+
|
290
|
+
# goodbye
|
291
|
+
module M
|
292
|
+
def d; end
|
293
|
+
def e; end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
after do
|
299
|
+
Object.remove_const(:TestHost)
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'should return doc for first valid module' do
|
303
|
+
redirect_pry_io(InputTester.new("show-doc TestHost::M"), out = StringIO.new) do
|
304
|
+
Pry.start
|
305
|
+
end
|
306
|
+
|
307
|
+
out.string.should =~ /goodbye/
|
308
|
+
out.string.should.not =~ /hello/
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|
246
312
|
end
|
313
|
+
|
247
314
|
end
|
248
315
|
end
|
@@ -20,7 +20,7 @@ unless Pry::Helpers::BaseHelpers.mri_18?
|
|
20
20
|
it "should find a method by regex" do
|
21
21
|
mock_pry("find-method hell MyKlass").should =~ /MyKlass.*?hello/m
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should NOT match a method that does not match the regex" do
|
25
25
|
mock_pry("find-method hell MyKlass").should.not =~ /MyKlass.*?goodbye/m
|
26
26
|
end
|
@@ -35,7 +35,15 @@ unless Pry::Helpers::BaseHelpers.mri_18?
|
|
35
35
|
mock_pry("find-method timothy MyKlass").should.not =~ /MyKlass.*?goodbye/m
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
|
+
it "should work with badly behaved constants" do
|
40
|
+
MyKlass::X = Object.new
|
41
|
+
def (MyKlass::X).hash
|
42
|
+
raise "mooo"
|
43
|
+
end
|
44
|
+
|
45
|
+
mock_pry("find-method -c timothy MyKlass").should =~ /MyKlass.*?hello/m
|
46
|
+
end
|
39
47
|
end
|
40
48
|
|
41
49
|
Object.remove_const(:MyKlass)
|
@@ -1,149 +1,148 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe "Pry::DefaultCommands::Input" do
|
4
|
+
before do
|
5
|
+
@str_output = StringIO.new
|
6
|
+
end
|
4
7
|
|
5
8
|
describe "amend-line" do
|
6
9
|
it 'should correctly amend the last line of input when no line number specified ' do
|
7
|
-
str_output
|
8
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "amend-line puts :blah", "show-input", "exit-all"), str_output) do
|
10
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "amend-line puts :blah", "show-input", "exit-all"), @str_output) do
|
9
11
|
pry
|
10
12
|
end
|
11
|
-
|
13
|
+
|
14
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :blah/
|
12
15
|
end
|
13
16
|
|
14
17
|
it 'should correctly amend the specified line of input when line number given ' do
|
15
|
-
str_output
|
16
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 1 def goodbye", "show-input", "exit-all"), str_output) do
|
18
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 1 def goodbye", "show-input", "exit-all"), @str_output) do
|
17
19
|
pry
|
18
20
|
end
|
19
|
-
|
21
|
+
|
22
|
+
@str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/
|
20
23
|
end
|
21
24
|
|
22
25
|
it 'should correctly amend the specified line of input when line number given, 0 should behave as 1 ' do
|
23
|
-
str_output
|
24
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 0 def goodbye", "show-input", "exit-all"), str_output) do
|
26
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 0 def goodbye", "show-input", "exit-all"), @str_output) do
|
25
27
|
pry
|
26
28
|
end
|
27
|
-
|
29
|
+
|
30
|
+
@str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/
|
28
31
|
end
|
29
32
|
|
30
33
|
it 'should correctly amend the specified line of input when line number given (negative number)' do
|
31
|
-
str_output
|
32
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -1 puts :bink", "show-input", "exit-all"), str_output) do
|
34
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -1 puts :bink", "show-input", "exit-all"), @str_output) do
|
33
35
|
pry
|
34
36
|
end
|
35
|
-
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts :bink/
|
36
37
|
|
37
|
-
str_output
|
38
|
-
|
38
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts :bink/
|
39
|
+
|
40
|
+
@str_output = StringIO.new
|
41
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -2 puts :bink", "show-input", "exit-all"), @str_output) do
|
39
42
|
pry
|
40
43
|
end
|
41
|
-
|
44
|
+
|
45
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :bang/
|
42
46
|
end
|
43
47
|
|
44
48
|
it 'should correctly amend the specified range of lines of input when range of negative numbers given (negative number)' do
|
45
|
-
str_output
|
46
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boat", "amend-line -3..-2 puts :bink", "show-input", "exit-all"), str_output) do
|
49
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boat", "amend-line -3..-2 puts :bink", "show-input", "exit-all"), @str_output) do
|
47
50
|
pry
|
48
51
|
end
|
49
|
-
|
52
|
+
|
53
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :boat/
|
50
54
|
end
|
51
55
|
|
52
56
|
it 'should correctly amend the specified line with string interpolated text' do
|
53
|
-
str_output
|
54
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", 'amend-line puts "#{goodbye}"', "show-input", "exit-all"), str_output) do
|
57
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", 'amend-line puts "#{goodbye}"', "show-input", "exit-all"), @str_output) do
|
55
58
|
pry
|
56
59
|
end
|
57
60
|
|
58
|
-
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts \"\#\{goodbye\}\"/
|
61
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts \"\#\{goodbye\}\"/
|
59
62
|
end
|
60
63
|
|
61
64
|
it 'should display error if nothing to amend' do
|
62
|
-
str_output
|
63
|
-
redirect_pry_io(InputTester.new("amend-line", "exit-all"), str_output) do
|
65
|
+
redirect_pry_io(InputTester.new("amend-line", "exit-all"), @str_output) do
|
64
66
|
pry
|
65
67
|
end
|
66
|
-
|
68
|
+
|
69
|
+
@str_output.string.should =~ /No input to amend/
|
67
70
|
end
|
68
71
|
|
69
72
|
|
70
73
|
it 'should correctly amend the specified range of lines' do
|
71
|
-
str_output
|
72
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :heart", "amend-line 2..3 puts :bong", "show-input", "exit-all"), str_output) do
|
74
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :heart", "amend-line 2..3 puts :bong", "show-input", "exit-all"), @str_output) do
|
73
75
|
pry
|
74
76
|
end
|
75
|
-
|
77
|
+
|
78
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
|
76
79
|
end
|
77
80
|
|
78
81
|
it 'should correctly delete a specific line using the ! for content' do
|
79
|
-
str_output
|
80
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 3 !", "show-input", "exit-all"), str_output) do
|
82
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 3 !", "show-input", "exit-all"), @str_output) do
|
81
83
|
pry
|
82
84
|
end
|
83
85
|
|
84
|
-
str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :boast\n\d+: puts :heart/
|
86
|
+
@str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :boast\n\d+: puts :heart/
|
85
87
|
end
|
86
88
|
|
87
89
|
it 'should correctly delete a range of lines using the ! for content' do
|
88
|
-
str_output
|
89
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 2..4 !", "show-input", "exit-all"), str_output) do
|
90
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 2..4 !", "show-input", "exit-all"), @str_output) do
|
90
91
|
pry
|
91
92
|
end
|
92
93
|
|
93
|
-
str_output.string.should =~ /\d+: def hello\n\d+: puts :heart\n\Z/
|
94
|
+
@str_output.string.should =~ /\d+: def hello\n\d+: puts :heart\n\Z/
|
94
95
|
end
|
95
96
|
|
96
97
|
it 'should correctly delete the previous line using the ! for content' do
|
97
|
-
str_output
|
98
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line !", "show-input", "exit-all"), str_output) do
|
98
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line !", "show-input", "exit-all"), @str_output) do
|
99
99
|
pry
|
100
100
|
end
|
101
101
|
|
102
|
-
str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :bang\n\d+: puts :boast\n\Z/
|
102
|
+
@str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :bang\n\d+: puts :boast\n\Z/
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'should correctly amend the specified range of lines, using negative numbers in range' do
|
106
|
-
str_output
|
107
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 2..-2 puts :bong", "show-input", "exit-all"), str_output) do
|
106
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "puts :boast", "puts :heart", "amend-line 2..-2 puts :bong", "show-input", "exit-all"), @str_output) do
|
108
107
|
pry
|
109
108
|
end
|
110
|
-
str_output.string.should =~ /\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
|
109
|
+
@str_output.string.should =~ /\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
|
111
110
|
end
|
112
111
|
|
113
112
|
it 'should correctly insert a new line of input before a specified line using the > syntax' do
|
114
|
-
str_output
|
115
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2 >puts :inserted", "show-input", "exit-all"), str_output) do
|
113
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2 >puts :inserted", "show-input", "exit-all"), @str_output) do
|
116
114
|
pry
|
117
115
|
end
|
118
|
-
|
116
|
+
|
117
|
+
@str_output.string.should =~ /\d+: def hello\n\d+: puts :inserted\n\d+: puts :bing\n\d+: puts :bang/
|
119
118
|
end
|
120
119
|
|
121
120
|
it 'should correctly insert a new line of input before a specified line using the > syntax (should ignore second value of range)' do
|
122
|
-
str_output
|
123
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2..21 >puts :inserted", "show-input", "exit-all"), str_output) do
|
121
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2..21 >puts :inserted", "show-input", "exit-all"), @str_output) do
|
124
122
|
pry
|
125
123
|
end
|
126
|
-
|
124
|
+
|
125
|
+
@str_output.string.should =~ /\d+: def hello\n\d+: puts :inserted\n\d+: puts :bing\n\d+: puts :bang/
|
127
126
|
end
|
128
127
|
end
|
129
128
|
|
130
129
|
describe "show-input" do
|
131
130
|
it 'should correctly show the current lines in the input buffer' do
|
132
|
-
str_output
|
133
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "show-input", "exit-all"), str_output) do
|
131
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "show-input", "exit-all"), @str_output) do
|
134
132
|
pry
|
135
133
|
end
|
136
|
-
|
134
|
+
|
135
|
+
@str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing/
|
137
136
|
end
|
138
137
|
end
|
139
138
|
|
140
139
|
describe "!" do
|
141
140
|
it 'should correctly clear the input buffer ' do
|
142
|
-
str_output
|
143
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "!", "show-input", "exit-all"), str_output) do
|
141
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "!", "show-input", "exit-all"), @str_output) do
|
144
142
|
pry
|
145
143
|
end
|
146
|
-
|
144
|
+
|
145
|
+
stripped_output = @str_output.string.strip!
|
147
146
|
stripped_output.each_line.count.should == 1
|
148
147
|
stripped_output.should =~ /Input buffer cleared!/
|
149
148
|
end
|
@@ -153,21 +152,23 @@ describe "Pry::DefaultCommands::Input" do
|
|
153
152
|
it 'should play a string variable (with no args)' do
|
154
153
|
b = binding
|
155
154
|
b.eval('x = "\"hello\""')
|
156
|
-
redirect_pry_io(InputTester.new("play x", "exit-all"), str_output
|
155
|
+
redirect_pry_io(InputTester.new("play x", "exit-all"), @str_output) do
|
157
156
|
Pry.start b, :hooks => Pry::Hooks.new
|
158
157
|
end
|
159
|
-
|
158
|
+
|
159
|
+
@str_output.string.should =~ /hello/
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'should play a string variable (with no args) using --lines to select what to play' do
|
163
163
|
b = binding
|
164
164
|
b.eval('x = "\"hello\"\n\"goodbye\"\n\"love\""')
|
165
|
-
redirect_pry_io(InputTester.new("play x --lines 1", "exit-all"), str_output
|
165
|
+
redirect_pry_io(InputTester.new("play x --lines 1", "exit-all"), @str_output) do
|
166
166
|
Pry.start b, :hooks => Pry::Hooks.new
|
167
167
|
end
|
168
|
-
|
169
|
-
str_output.string.should
|
170
|
-
str_output.string.should.not =~ /
|
168
|
+
|
169
|
+
@str_output.string.should =~ /hello/
|
170
|
+
@str_output.string.should.not =~ /love/
|
171
|
+
@str_output.string.should.not =~ /goodbye/
|
171
172
|
end
|
172
173
|
|
173
174
|
it 'should play documentation with the -d switch' do
|
@@ -179,7 +180,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
179
180
|
:test_method_content
|
180
181
|
end
|
181
182
|
|
182
|
-
redirect_pry_io(InputTester.new('play -d test_method', "exit-all")
|
183
|
+
redirect_pry_io(InputTester.new('play -d test_method', "exit-all")) do
|
183
184
|
o.pry
|
184
185
|
end
|
185
186
|
|
@@ -198,7 +199,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
198
199
|
:test_method_content
|
199
200
|
end
|
200
201
|
|
201
|
-
redirect_pry_io(InputTester.new('play -d test_method --lines 2..3', "exit-all")
|
202
|
+
redirect_pry_io(InputTester.new('play -d test_method --lines 2..3', "exit-all")) do
|
202
203
|
o.pry
|
203
204
|
end
|
204
205
|
|
@@ -215,11 +216,11 @@ describe "Pry::DefaultCommands::Input" do
|
|
215
216
|
:test_method_content
|
216
217
|
end
|
217
218
|
|
218
|
-
redirect_pry_io(InputTester.new('play -m test_method --lines 2', "exit-all"), str_output
|
219
|
+
redirect_pry_io(InputTester.new('play -m test_method --lines 2', "exit-all"), @str_output) do
|
219
220
|
o.pry
|
220
221
|
end
|
221
222
|
|
222
|
-
str_output.string.should =~ /:test_method_content/
|
223
|
+
@str_output.string.should =~ /:test_method_content/
|
223
224
|
end
|
224
225
|
|
225
226
|
it 'should APPEND to the input buffer when playing a line with play -m, not replace it' do
|
@@ -228,11 +229,12 @@ describe "Pry::DefaultCommands::Input" do
|
|
228
229
|
:test_method_content
|
229
230
|
end
|
230
231
|
|
231
|
-
redirect_pry_io(InputTester.new('def another_test_method', 'play -m test_method --lines 2', 'show-input', 'exit-all'), str_output
|
232
|
+
redirect_pry_io(InputTester.new('def another_test_method', 'play -m test_method --lines 2', 'show-input', 'exit-all'), @str_output) do
|
232
233
|
o.pry
|
233
234
|
end
|
234
|
-
|
235
|
-
str_output.string.should =~
|
235
|
+
|
236
|
+
@str_output.string.should =~ /def another_test_method/
|
237
|
+
@str_output.string.should =~ /:test_method_content/
|
236
238
|
end
|
237
239
|
|
238
240
|
|
@@ -246,7 +248,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
246
248
|
@var3 = 40
|
247
249
|
end
|
248
250
|
|
249
|
-
redirect_pry_io(InputTester.new('play -m test_method --lines 3..4', "exit-all"), str_output
|
251
|
+
redirect_pry_io(InputTester.new('play -m test_method --lines 3..4', "exit-all"), @str_output) do
|
250
252
|
o.pry
|
251
253
|
end
|
252
254
|
|
@@ -254,8 +256,8 @@ describe "Pry::DefaultCommands::Input" do
|
|
254
256
|
o.instance_variable_get(:@var1).should == 20
|
255
257
|
o.instance_variable_get(:@var2).should == 30
|
256
258
|
o.instance_variable_get(:@var3).should == nil
|
257
|
-
str_output.string.should =~ /30/
|
258
|
-
str_output.string.should.not =~ /20/
|
259
|
+
@str_output.string.should =~ /30/
|
260
|
+
@str_output.string.should.not =~ /20/
|
259
261
|
end
|
260
262
|
end
|
261
263
|
|
@@ -268,11 +270,11 @@ describe "Pry::DefaultCommands::Input" do
|
|
268
270
|
it 'should display the correct history' do
|
269
271
|
@hist.push "hello"
|
270
272
|
@hist.push "world"
|
271
|
-
str_output
|
272
|
-
redirect_pry_io(InputTester.new("hist", "exit-all"), str_output) do
|
273
|
+
redirect_pry_io(InputTester.new("hist", "exit-all"), @str_output) do
|
273
274
|
pry
|
274
275
|
end
|
275
|
-
|
276
|
+
|
277
|
+
@str_output.string.should =~ /hello\n.*world/
|
276
278
|
end
|
277
279
|
|
278
280
|
it 'should replay history correctly (single item)' do
|
@@ -280,8 +282,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
280
282
|
@hist.push "@x = 10"
|
281
283
|
@hist.push "@y = 20"
|
282
284
|
@hist.push "@z = 30"
|
283
|
-
|
284
|
-
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"), str_output) do
|
285
|
+
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all")) do
|
285
286
|
o.pry
|
286
287
|
end
|
287
288
|
o.instance_variable_get(:@x).should == nil
|
@@ -293,8 +294,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
293
294
|
o = Object.new
|
294
295
|
@hist.push "@x = 10"
|
295
296
|
@hist.push "@y = 20"
|
296
|
-
|
297
|
-
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"), str_output) do
|
297
|
+
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all")) do
|
298
298
|
o.pry
|
299
299
|
end
|
300
300
|
o.instance_variable_get(:@x).should == 10
|
@@ -312,25 +312,24 @@ describe "Pry::DefaultCommands::Input" do
|
|
312
312
|
@hist.push "def boink 2"
|
313
313
|
@hist.push "place holder"
|
314
314
|
|
315
|
-
str_output
|
316
|
-
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"), str_output) do
|
315
|
+
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"), @str_output) do
|
317
316
|
pry
|
318
317
|
end
|
319
|
-
str_output.string.should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
|
318
|
+
@str_output.string.should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
|
320
319
|
|
321
320
|
# test more than one word in a regex match (def blah)
|
322
|
-
str_output = StringIO.new
|
323
|
-
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"), str_output) do
|
321
|
+
@str_output = StringIO.new
|
322
|
+
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all"), @str_output) do
|
324
323
|
pry
|
325
324
|
end
|
326
|
-
str_output.string.should =~ /def blah 1/
|
325
|
+
@str_output.string.should =~ /def blah 1/
|
327
326
|
|
327
|
+
@str_output = StringIO.new
|
328
328
|
# test more than one word with leading white space in a regex match (def boink)
|
329
|
-
str_output
|
330
|
-
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"), str_output) do
|
329
|
+
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all"), @str_output) do
|
331
330
|
pry
|
332
331
|
end
|
333
|
-
str_output.string.should =~ /def boink 2/
|
332
|
+
@str_output.string.should =~ /def boink 2/
|
334
333
|
end
|
335
334
|
|
336
335
|
it 'should return last N lines in history with --tail switch' do
|
@@ -338,13 +337,12 @@ describe "Pry::DefaultCommands::Input" do
|
|
338
337
|
@hist.push v
|
339
338
|
end
|
340
339
|
|
341
|
-
str_output
|
342
|
-
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"), str_output) do
|
340
|
+
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"), @str_output) do
|
343
341
|
pry
|
344
342
|
end
|
345
343
|
|
346
|
-
str_output.string.each_line.count.should == 3
|
347
|
-
str_output.string.should =~ /x\n\d+:.*y\n\d+:.*z/
|
344
|
+
@str_output.string.each_line.count.should == 3
|
345
|
+
@str_output.string.should =~ /x\n\d+:.*y\n\d+:.*z/
|
348
346
|
end
|
349
347
|
|
350
348
|
it 'should apply --tail after --grep' do
|
@@ -355,12 +353,12 @@ describe "Pry::DefaultCommands::Input" do
|
|
355
353
|
@hist.push "puts 5"
|
356
354
|
|
357
355
|
str_output = StringIO.new
|
358
|
-
redirect_pry_io(InputTester.new("hist --tail 2 --grep print", "exit-all"), str_output) do
|
356
|
+
redirect_pry_io(InputTester.new("hist --tail 2 --grep print", "exit-all"), @str_output) do
|
359
357
|
pry
|
360
358
|
end
|
361
359
|
|
362
|
-
str_output.string.each_line.count.should == 2
|
363
|
-
str_output.string.should =~ /\d:.*?print 2\n\d:.*?print 4/
|
360
|
+
@str_output.string.each_line.count.should == 2
|
361
|
+
@str_output.string.should =~ /\d:.*?print 2\n\d:.*?print 4/
|
364
362
|
end
|
365
363
|
|
366
364
|
it 'should apply --head after --grep' do
|
@@ -370,13 +368,12 @@ describe "Pry::DefaultCommands::Input" do
|
|
370
368
|
@hist.push "print 4"
|
371
369
|
@hist.push "print 5"
|
372
370
|
|
373
|
-
str_output
|
374
|
-
redirect_pry_io(InputTester.new("hist --head 2 --grep print", "exit-all"), str_output) do
|
371
|
+
redirect_pry_io(InputTester.new("hist --head 2 --grep print", "exit-all"), @str_output) do
|
375
372
|
pry
|
376
373
|
end
|
377
374
|
|
378
|
-
str_output.string.each_line.count.should == 2
|
379
|
-
str_output.string.should =~ /\d:.*?print 2\n\d:.*?print 4/
|
375
|
+
@str_output.string.each_line.count.should == 2
|
376
|
+
@str_output.string.should =~ /\d:.*?print 2\n\d:.*?print 4/
|
380
377
|
end
|
381
378
|
|
382
379
|
# strangeness in this test is due to bug in Readline::HISTORY not
|
@@ -386,13 +383,12 @@ describe "Pry::DefaultCommands::Input" do
|
|
386
383
|
@hist.push v
|
387
384
|
end
|
388
385
|
|
389
|
-
str_output
|
390
|
-
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"), str_output) do
|
386
|
+
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"), @str_output) do
|
391
387
|
pry
|
392
388
|
end
|
393
389
|
|
394
|
-
str_output.string.each_line.count.should == 4
|
395
|
-
str_output.string.should =~ /a\n\d+:.*b\n\d+:.*c/
|
390
|
+
@str_output.string.each_line.count.should == 4
|
391
|
+
@str_output.string.should =~ /a\n\d+:.*b\n\d+:.*c/
|
396
392
|
end
|
397
393
|
|
398
394
|
# strangeness in this test is due to bug in Readline::HISTORY not
|
@@ -402,36 +398,31 @@ describe "Pry::DefaultCommands::Input" do
|
|
402
398
|
@hist.push v
|
403
399
|
end
|
404
400
|
|
405
|
-
str_output
|
406
|
-
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"), str_output) do
|
401
|
+
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"), @str_output) do
|
407
402
|
pry
|
408
403
|
end
|
409
404
|
|
410
|
-
str_output.string.each_line.count.should == 4
|
411
|
-
str_output.string.should =~ /b\n\d+:.*c\n\d+:.*d/
|
405
|
+
@str_output.string.each_line.count.should == 4
|
406
|
+
@str_output.string.should =~ /b\n\d+:.*c\n\d+:.*d/
|
412
407
|
end
|
413
408
|
|
414
409
|
it "should not contain duplicated lines" do
|
415
|
-
str_output
|
416
|
-
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all"), str_output) do
|
410
|
+
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all"), @str_output) do
|
417
411
|
pry
|
418
412
|
end
|
419
413
|
|
420
|
-
str_output.string.each_line.grep(/_ \+= 1/).count.should == 1
|
414
|
+
@str_output.string.each_line.grep(/_ \+= 1/).count.should == 1
|
421
415
|
end
|
422
416
|
|
423
417
|
it "should not contain duplicated lines" do
|
424
|
-
str_output
|
425
|
-
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all"), str_output) do
|
418
|
+
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all"), @str_output) do
|
426
419
|
pry
|
427
420
|
end
|
428
421
|
|
429
|
-
a = str_output.string.each_line.to_a.index{|line| line.include?("2 + 2") }
|
430
|
-
b = str_output.string.each_line.to_a.index{|line| line.include?("3 + 3") }
|
422
|
+
a = @str_output.string.each_line.to_a.index{|line| line.include?("2 + 2") }
|
423
|
+
b = @str_output.string.each_line.to_a.index{|line| line.include?("3 + 3") }
|
431
424
|
|
432
425
|
(a + 1).should == b
|
433
426
|
end
|
434
427
|
end
|
435
|
-
|
436
|
-
|
437
428
|
end
|