pry 0.9.0pre3-java → 0.9.4pre2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +84 -6
- data/CONTRIBUTORS +13 -0
- data/README.markdown +23 -183
- data/Rakefile +22 -19
- data/TODO +36 -6
- data/bin/pry +12 -1
- data/lib/pry.rb +60 -12
- data/lib/pry/command_context.rb +21 -0
- data/lib/pry/command_processor.rb +62 -16
- data/lib/pry/command_set.rb +25 -11
- data/lib/pry/commands.rb +0 -3
- data/lib/pry/completion.rb +6 -6
- data/lib/pry/config.rb +25 -5
- data/lib/pry/default_commands/basic.rb +27 -6
- data/lib/pry/default_commands/context.rb +84 -35
- data/lib/pry/default_commands/documentation.rb +69 -31
- data/lib/pry/default_commands/easter_eggs.rb +5 -0
- data/lib/pry/default_commands/input.rb +193 -56
- data/lib/pry/default_commands/introspection.rb +98 -50
- data/lib/pry/default_commands/ls.rb +51 -21
- data/lib/pry/default_commands/shell.rb +57 -13
- data/lib/pry/extended_commands/experimental.rb +0 -32
- data/lib/pry/extended_commands/user_command_api.rb +33 -2
- data/lib/pry/helpers/base_helpers.rb +30 -10
- data/lib/pry/helpers/command_helpers.rb +75 -16
- data/lib/pry/helpers/text.rb +12 -11
- data/lib/pry/history.rb +61 -0
- data/lib/pry/plugins.rb +23 -12
- data/lib/pry/pry_class.rb +51 -50
- data/lib/pry/pry_instance.rb +129 -119
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +46 -0
- data/test/helper.rb +37 -3
- data/test/test_command_processor.rb +62 -19
- data/test/test_command_set.rb +40 -2
- data/test/test_completion.rb +27 -0
- data/test/test_default_commands/test_context.rb +185 -1
- data/test/test_default_commands/test_documentation.rb +10 -0
- data/test/test_default_commands/test_input.rb +207 -11
- data/test/test_default_commands/test_introspection.rb +20 -1
- data/test/test_default_commands/test_shell.rb +18 -0
- data/test/test_pry.rb +261 -45
- data/test/test_pry_history.rb +82 -0
- data/test/test_pry_output.rb +44 -0
- data/test/test_special_locals.rb +35 -0
- metadata +185 -159
@@ -10,6 +10,16 @@ describe "Pry::DefaultCommands::Documentation" do
|
|
10
10
|
|
11
11
|
str_output.string.should =~ /sample doc/
|
12
12
|
end
|
13
|
+
|
14
|
+
it 'should output multiple methods\' documentation' do
|
15
|
+
str_output = StringIO.new
|
16
|
+
redirect_pry_io(InputTester.new("show-doc sample_method another_sample_method", "exit-all"), str_output) do
|
17
|
+
pry
|
18
|
+
end
|
19
|
+
|
20
|
+
str_output.string.should =~ /sample doc/
|
21
|
+
str_output.string.should =~ /another sample doc/
|
22
|
+
end
|
13
23
|
|
14
24
|
it 'should output a method\'s documentation if inside method without needing to use method name' do
|
15
25
|
$str_output = StringIO.new
|
@@ -13,11 +13,118 @@ describe "Pry::DefaultCommands::Input" do
|
|
13
13
|
|
14
14
|
it 'should correctly amend the specified line of input when line number given ' do
|
15
15
|
str_output = StringIO.new
|
16
|
-
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line
|
16
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 1 def goodbye", "show-input", "exit-all"), str_output) do
|
17
17
|
pry
|
18
18
|
end
|
19
19
|
str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/
|
20
20
|
end
|
21
|
+
|
22
|
+
it 'should correctly amend the specified line of input when line number given, 0 should behave as 1 ' do
|
23
|
+
str_output = StringIO.new
|
24
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 0 def goodbye", "show-input", "exit-all"), str_output) do
|
25
|
+
pry
|
26
|
+
end
|
27
|
+
str_output.string.should =~ /\A\d+: def goodbye\n\d+: puts :bing\n\d+: puts :bang/
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should correctly amend the specified line of input when line number given (negative number)' do
|
31
|
+
str_output = StringIO.new
|
32
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -1 puts :bink", "show-input", "exit-all"), str_output) do
|
33
|
+
pry
|
34
|
+
end
|
35
|
+
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts :bink/
|
36
|
+
|
37
|
+
str_output = StringIO.new
|
38
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line -2 puts :bink", "show-input", "exit-all"), str_output) do
|
39
|
+
pry
|
40
|
+
end
|
41
|
+
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :bang/
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should correctly amend the specified range of lines of input when range of negative numbers given (negative number)' do
|
45
|
+
str_output = StringIO.new
|
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
|
47
|
+
pry
|
48
|
+
end
|
49
|
+
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bink\n\d+: puts :boat/
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should correctly amend the specified line with string interpolated text' do
|
53
|
+
str_output = StringIO.new
|
54
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", 'amend-line puts "#{goodbye}"', "show-input", "exit-all"), str_output) do
|
55
|
+
pry
|
56
|
+
end
|
57
|
+
|
58
|
+
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bing\n\d+: puts \"\#{goodbye}\"/
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should display error if nothing to amend' do
|
62
|
+
str_output = StringIO.new
|
63
|
+
redirect_pry_io(InputTester.new("amend-line", "exit-all"), str_output) do
|
64
|
+
pry
|
65
|
+
end
|
66
|
+
str_output.string.should =~ /No input to amend/
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
it 'should correctly amend the specified range of lines' do
|
71
|
+
str_output = StringIO.new
|
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
|
73
|
+
pry
|
74
|
+
end
|
75
|
+
str_output.string.should =~ /\A\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should correctly delete a specific line using the ! for content' do
|
79
|
+
str_output = StringIO.new
|
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
|
81
|
+
pry
|
82
|
+
end
|
83
|
+
|
84
|
+
str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :boast\n\d+: puts :heart/
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should correctly delete a range of lines using the ! for content' do
|
88
|
+
str_output = StringIO.new
|
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
|
+
pry
|
91
|
+
end
|
92
|
+
|
93
|
+
str_output.string.should =~ /\d+: def hello\n\d+: puts :heart\n\Z/
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should correctly delete the previous line using the ! for content' do
|
97
|
+
str_output = StringIO.new
|
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
|
+
pry
|
100
|
+
end
|
101
|
+
|
102
|
+
str_output.string.should =~ /\d+: def hello\n\d+: puts :bing\n\d+: puts :bang\n\d+: puts :boast\n\Z/
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should correctly amend the specified range of lines, using negative numbers in range' do
|
106
|
+
str_output = StringIO.new
|
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
|
108
|
+
pry
|
109
|
+
end
|
110
|
+
str_output.string.should =~ /\d+: def hello\n\d+: puts :bong\n\d+: puts :heart/
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should correctly insert a new line of input before a specified line using the > syntax' do
|
114
|
+
str_output = StringIO.new
|
115
|
+
redirect_pry_io(InputTester.new("def hello", "puts :bing", "puts :bang", "amend-line 2 >puts :inserted", "show-input", "exit-all"), str_output) do
|
116
|
+
pry
|
117
|
+
end
|
118
|
+
str_output.string.should =~ /\d+: def hello\n\d+: puts :inserted\n\d+: puts :bing\n\d+: puts :bang/
|
119
|
+
end
|
120
|
+
|
121
|
+
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 = StringIO.new
|
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
|
124
|
+
pry
|
125
|
+
end
|
126
|
+
str_output.string.should =~ /\d+: def hello\n\d+: puts :inserted\n\d+: puts :bing\n\d+: puts :bang/
|
127
|
+
end
|
21
128
|
end
|
22
129
|
|
23
130
|
describe "show-input" do
|
@@ -42,14 +149,66 @@ describe "Pry::DefaultCommands::Input" do
|
|
42
149
|
end
|
43
150
|
end
|
44
151
|
|
152
|
+
describe "play" do
|
153
|
+
it 'should play a string variable (with no args)' do
|
154
|
+
b = binding
|
155
|
+
b.eval('x = "\"hello\""')
|
156
|
+
redirect_pry_io(InputTester.new("play x", "exit-all"), str_output = StringIO.new) do
|
157
|
+
Pry.start b, :hooks => {}
|
158
|
+
end
|
159
|
+
str_output.string.should =~ /hello/
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should play a string variable (with no args) using --lines to select what to play' do
|
163
|
+
b = binding
|
164
|
+
b.eval('x = "\"hello\"\n\"goodbye\"\n\"love\""')
|
165
|
+
redirect_pry_io(InputTester.new("play x --lines 1", "exit-all"), str_output = StringIO.new) do
|
166
|
+
Pry.start b, :hooks => {}
|
167
|
+
end
|
168
|
+
str_output.string.should =~ /hello/
|
169
|
+
str_output.string.should.not =~ /love/
|
170
|
+
str_output.string.should.not =~ /goodbye/
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should play a method with the -m switch (a single line)' do
|
174
|
+
$o = Object.new
|
175
|
+
def $o.test_method
|
176
|
+
:test_method_content
|
177
|
+
end
|
178
|
+
|
179
|
+
redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2', "exit-all"), str_output = StringIO.new) do
|
180
|
+
pry
|
181
|
+
end
|
182
|
+
|
183
|
+
str_output.string.should =~ /:test_method_content/
|
184
|
+
$o = nil
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should play a method with the -m switch (multiple line)' do
|
188
|
+
$o = Object.new
|
189
|
+
def $o.test_method
|
190
|
+
1 + 102
|
191
|
+
5 * 6
|
192
|
+
end
|
193
|
+
|
194
|
+
redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2..3', "exit-all"), str_output = StringIO.new) do
|
195
|
+
pry
|
196
|
+
end
|
197
|
+
|
198
|
+
str_output.string.should =~ /103\n.*30/
|
199
|
+
$o = nil
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
45
204
|
describe "hist" do
|
46
205
|
push_first_hist_line = lambda do |hist, line|
|
47
206
|
hist.push line
|
48
207
|
end
|
49
208
|
|
50
209
|
before do
|
51
|
-
|
52
|
-
@hist =
|
210
|
+
Pry.history.clear
|
211
|
+
@hist = Pry.history
|
53
212
|
end
|
54
213
|
|
55
214
|
it 'should display the correct history' do
|
@@ -57,7 +216,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
57
216
|
@hist.push "hello"
|
58
217
|
@hist.push "world"
|
59
218
|
str_output = StringIO.new
|
60
|
-
redirect_pry_io(InputTester.new("hist", "exit-all"), str_output) do
|
219
|
+
redirect_pry_io(InputTester.new("hist", "exit-all", :history => @hist), str_output) do
|
61
220
|
pry
|
62
221
|
end
|
63
222
|
str_output.string.should =~ /hello\n.*world/
|
@@ -69,7 +228,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
69
228
|
@hist.push ":bucket"
|
70
229
|
@hist.push ":ostrich"
|
71
230
|
str_output = StringIO.new
|
72
|
-
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"), str_output) do
|
231
|
+
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all", :history => @hist), str_output) do
|
73
232
|
pry
|
74
233
|
end
|
75
234
|
str_output.string.should =~ /ostrich/
|
@@ -80,7 +239,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
80
239
|
@hist.push ":hello"
|
81
240
|
@hist.push ":carl"
|
82
241
|
str_output = StringIO.new
|
83
|
-
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"), str_output) do
|
242
|
+
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all", :history => @hist), str_output) do
|
84
243
|
pry
|
85
244
|
end
|
86
245
|
str_output.string.should =~ /:hello\n.*:carl/
|
@@ -94,13 +253,29 @@ describe "Pry::DefaultCommands::Input" do
|
|
94
253
|
@hist.push "pepper"
|
95
254
|
@hist.push "orange"
|
96
255
|
@hist.push "grape"
|
256
|
+
@hist.push "def blah 1"
|
257
|
+
@hist.push "def boink 2"
|
258
|
+
@hist.push "place holder"
|
97
259
|
|
98
260
|
str_output = StringIO.new
|
99
|
-
redirect_pry_io(InputTester.new("hist --grep o", "exit-all"), str_output) do
|
261
|
+
redirect_pry_io(InputTester.new("hist --grep o", "exit-all", :history => @hist), str_output) do
|
100
262
|
pry
|
101
263
|
end
|
102
|
-
|
103
264
|
str_output.string.should =~ /\d:.*?box\n\d:.*?button\n\d:.*?orange/
|
265
|
+
|
266
|
+
# test more than one word in a regex match (def blah)
|
267
|
+
str_output = StringIO.new
|
268
|
+
redirect_pry_io(InputTester.new("hist --grep def blah", "exit-all", :history => @hist), str_output) do
|
269
|
+
pry
|
270
|
+
end
|
271
|
+
str_output.string.should =~ /def blah 1/
|
272
|
+
|
273
|
+
# test more than one word with leading white space in a regex match (def boink)
|
274
|
+
str_output = StringIO.new
|
275
|
+
redirect_pry_io(InputTester.new("hist --grep def boink", "exit-all", :history => @hist), str_output) do
|
276
|
+
pry
|
277
|
+
end
|
278
|
+
str_output.string.should =~ /def boink 2/
|
104
279
|
end
|
105
280
|
|
106
281
|
it 'should return last N lines in history with --tail switch' do
|
@@ -110,7 +285,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
110
285
|
end
|
111
286
|
|
112
287
|
str_output = StringIO.new
|
113
|
-
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all"), str_output) do
|
288
|
+
redirect_pry_io(InputTester.new("hist --tail 3", "exit-all", :history => @hist), str_output) do
|
114
289
|
pry
|
115
290
|
end
|
116
291
|
|
@@ -127,7 +302,7 @@ describe "Pry::DefaultCommands::Input" do
|
|
127
302
|
end
|
128
303
|
|
129
304
|
str_output = StringIO.new
|
130
|
-
redirect_pry_io(InputTester.new("hist --head 4", "exit-all"), str_output) do
|
305
|
+
redirect_pry_io(InputTester.new("hist --head 4", "exit-all", :history => @hist), str_output) do
|
131
306
|
pry
|
132
307
|
end
|
133
308
|
|
@@ -144,13 +319,34 @@ describe "Pry::DefaultCommands::Input" do
|
|
144
319
|
end
|
145
320
|
|
146
321
|
str_output = StringIO.new
|
147
|
-
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all"), str_output) do
|
322
|
+
redirect_pry_io(InputTester.new("hist --show 1..4", "exit-all", :history => @hist), str_output) do
|
148
323
|
pry
|
149
324
|
end
|
150
325
|
|
151
326
|
str_output.string.each_line.count.should == 4
|
152
327
|
str_output.string.should =~ /b\n\d+:.*c\n\d+:.*d/
|
153
328
|
end
|
329
|
+
|
330
|
+
it "should not contain duplicated lines" do
|
331
|
+
str_output = StringIO.new
|
332
|
+
redirect_pry_io(InputTester.new("3", "_ += 1", "_ += 1", "hist", "exit-all", :history => @hist), str_output) do
|
333
|
+
pry
|
334
|
+
end
|
335
|
+
|
336
|
+
str_output.string.each_line.grep(/_ \+= 1/).count.should == 1
|
337
|
+
end
|
338
|
+
|
339
|
+
it "should not contain duplicated lines" do
|
340
|
+
str_output = StringIO.new
|
341
|
+
redirect_pry_io(InputTester.new(":place_holder", "2 + 2", "", "", "3 + 3", "hist", "exit-all", :history => @hist), str_output) do
|
342
|
+
pry
|
343
|
+
end
|
344
|
+
|
345
|
+
a = str_output.string.each_line.to_a.index{|line| line.include?("2 + 2") }
|
346
|
+
b = str_output.string.each_line.to_a.index{|line| line.include?("3 + 3") }
|
347
|
+
|
348
|
+
(a + 1).should == b
|
349
|
+
end
|
154
350
|
end
|
155
351
|
|
156
352
|
|
@@ -10,6 +10,16 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
10
10
|
|
11
11
|
str_output.string.should =~ /def sample/
|
12
12
|
end
|
13
|
+
|
14
|
+
it 'should output multiple methods\' sources' do
|
15
|
+
str_output = StringIO.new
|
16
|
+
redirect_pry_io(InputTester.new("show-method sample_method another_sample_method", "exit-all"), str_output) do
|
17
|
+
pry
|
18
|
+
end
|
19
|
+
|
20
|
+
str_output.string.should =~ /def sample/
|
21
|
+
str_output.string.should =~ /def another_sample/
|
22
|
+
end
|
13
23
|
|
14
24
|
it 'should output a method\'s source with line numbers' do
|
15
25
|
str_output = StringIO.new
|
@@ -20,6 +30,15 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
20
30
|
str_output.string.should =~ /\d+: def sample/
|
21
31
|
end
|
22
32
|
|
33
|
+
it 'should output a method\'s source with line numbers starting at 1' do
|
34
|
+
str_output = StringIO.new
|
35
|
+
redirect_pry_io(InputTester.new("show-method -b sample_method", "exit-all"), str_output) do
|
36
|
+
pry
|
37
|
+
end
|
38
|
+
|
39
|
+
str_output.string.should =~ /1: def sample/
|
40
|
+
end
|
41
|
+
|
23
42
|
it 'should output a method\'s source if inside method without needing to use method name' do
|
24
43
|
$str_output = StringIO.new
|
25
44
|
|
@@ -85,7 +104,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
|
85
104
|
|
86
105
|
it 'should output an instance method\'s source for a method defined inside pry using define_method' do
|
87
106
|
str_output = StringIO.new
|
88
|
-
redirect_pry_io(InputTester.new("class A", "define_method(:yup) {}", "end", "
|
107
|
+
redirect_pry_io(InputTester.new("class A", "define_method(:yup) {}", "end", "show-method A#yup"), str_output) do
|
89
108
|
TOPLEVEL_BINDING.pry
|
90
109
|
end
|
91
110
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe "Pry::DefaultCommands::Shell" do
|
4
|
+
describe "cat" do
|
5
|
+
|
6
|
+
# this doesnt work so well on rbx due to differences in backtrace
|
7
|
+
# so we currently skip rbx until we figure out a workaround
|
8
|
+
if !rbx?
|
9
|
+
it 'cat --ex should give warning when exception is raised in repl' do
|
10
|
+
mock_pry("this raises error", "cat --ex").should =~ /Cannot cat exceptions raised in REPL/
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'cat --ex should correctly display code that generated exception' do
|
14
|
+
mock_pry("broken_method", "cat --ex").should =~ /this method is broken/
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/test_pry.rb
CHANGED
@@ -7,14 +7,45 @@ puts "--"
|
|
7
7
|
|
8
8
|
describe Pry do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
if RUBY_PLATFORM !~ /mingw/ && RUBY_PLATFORM !~ /mswin/ && RUBY_PLATFORM != 'java'
|
11
|
+
describe 'warning emissions' do
|
12
|
+
it 'should emit no warnings' do
|
13
|
+
Open4.popen4 'ruby -I lib -rubygems -r"pry" -W -e "exit"' do |pid, stdin, stdout, stderr|
|
14
|
+
stderr.read.empty?.should == true
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
20
|
+
if RUBY_VERSION =~ /1.9/
|
21
|
+
describe "Exotic object support" do
|
22
|
+
|
23
|
+
# regression test for exotic object support
|
24
|
+
it "Should not error when return value is a BasicObject instance" do
|
25
|
+
|
26
|
+
lambda do
|
27
|
+
redirect_pry_io(InputTester.new("BasicObject.new", "exit-all"), StringIO.new) do
|
28
|
+
Pry.start
|
29
|
+
end
|
30
|
+
end.should.not.raise NoMethodError
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "Pry.binding_for" do
|
37
|
+
|
38
|
+
# regression test for burg's bug (see git history)
|
39
|
+
it "Should not error when object doesn't have a valid == method" do
|
40
|
+
o = Object.new
|
41
|
+
def o.==(other)
|
42
|
+
raise
|
43
|
+
end
|
44
|
+
|
45
|
+
lambda { Pry.binding_for(o) }.should.not.raise Exception
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
18
49
|
describe "open a Pry session on an object" do
|
19
50
|
describe "rep" do
|
20
51
|
before do
|
@@ -40,6 +71,17 @@ describe Pry do
|
|
40
71
|
@excep.is_a?(NameError).should == true
|
41
72
|
end
|
42
73
|
|
74
|
+
if defined?(BasicObject)
|
75
|
+
it 'should be able to operate inside the BasicObject class' do
|
76
|
+
$obj = nil
|
77
|
+
redirect_pry_io(InputTester.new(":foo", "$obj = _", "exit-all"), StringIO.new) do
|
78
|
+
BasicObject.pry
|
79
|
+
end
|
80
|
+
$obj.should == :foo
|
81
|
+
$obj = nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
43
85
|
it 'should set an ivar on an object' do
|
44
86
|
input_string = "@x = 10"
|
45
87
|
input = InputTester.new(input_string)
|
@@ -50,13 +92,25 @@ describe Pry do
|
|
50
92
|
o.instance_variable_get(:@x).should == 10
|
51
93
|
end
|
52
94
|
|
95
|
+
it 'should not output anything for no input' do
|
96
|
+
outp = StringIO.new
|
97
|
+
|
98
|
+
# note i could not use mock_pry() for this test for some
|
99
|
+
# reason, as i'd always get "\n" as output instead of ""
|
100
|
+
redirect_pry_io(StringIO.new(""), outp) do
|
101
|
+
Pry.new.rep(self)
|
102
|
+
end
|
103
|
+
|
104
|
+
outp.string.empty?.should == true
|
105
|
+
end
|
106
|
+
|
53
107
|
it 'should make self evaluate to the receiver of the rep session' do
|
54
|
-
o =
|
108
|
+
o = :john
|
55
109
|
str_output = StringIO.new
|
56
110
|
|
57
111
|
pry_tester = Pry.new(:input => InputTester.new("self"), :output => str_output)
|
58
112
|
pry_tester.rep(o)
|
59
|
-
str_output.string.should =~
|
113
|
+
str_output.string.should =~ /:john/
|
60
114
|
end
|
61
115
|
|
62
116
|
it 'should work with multi-line input' do
|
@@ -127,12 +181,18 @@ describe Pry do
|
|
127
181
|
pry_tester.rep(o)
|
128
182
|
was_called.should == true
|
129
183
|
end
|
184
|
+
|
185
|
+
it 'should not try to catch intended exceptions' do
|
186
|
+
lambda { mock_pry("raise SystemExit") }.should.raise SystemExit
|
187
|
+
# SIGTERM
|
188
|
+
lambda { mock_pry("raise SignalException.new(15)") }.should.raise SignalException
|
189
|
+
end
|
130
190
|
end
|
131
191
|
|
132
192
|
describe "repl" do
|
133
193
|
describe "basic functionality" do
|
134
194
|
it 'should set an ivar on an object and exit the repl' do
|
135
|
-
input_strings = ["@x = 10", "exit"]
|
195
|
+
input_strings = ["@x = 10", "exit-all"]
|
136
196
|
input = InputTester.new(*input_strings)
|
137
197
|
|
138
198
|
o = Object.new
|
@@ -155,7 +215,7 @@ describe Pry do
|
|
155
215
|
|
156
216
|
it 'sets out to an array with the result' do
|
157
217
|
res = {}
|
158
|
-
input = InputTester.new *[":foo", "42", "self[:res] =
|
218
|
+
input = InputTester.new *[":foo", "42", "self[:res] = _out_"]
|
159
219
|
pry = Pry.new(:input => input, :output => Pry::NullOutput)
|
160
220
|
pry.repl(res)
|
161
221
|
|
@@ -163,9 +223,9 @@ describe Pry do
|
|
163
223
|
res[:res][1..2].should == [:foo, 42]
|
164
224
|
end
|
165
225
|
|
166
|
-
it 'sets
|
226
|
+
it 'sets _in_ to an array with the entered lines' do
|
167
227
|
res = {}
|
168
|
-
input = InputTester.new *[":foo", "42", "self[:res] =
|
228
|
+
input = InputTester.new *[":foo", "42", "self[:res] = _in_"]
|
169
229
|
pry = Pry.new(:input => input, :output => Pry::NullOutput)
|
170
230
|
pry.repl(res)
|
171
231
|
|
@@ -173,9 +233,9 @@ describe Pry do
|
|
173
233
|
res[:res][1..2].should == [":foo\n", "42\n"]
|
174
234
|
end
|
175
235
|
|
176
|
-
it 'uses 100 as the size of
|
236
|
+
it 'uses 100 as the size of _in_ and _out_' do
|
177
237
|
res = []
|
178
|
-
input = InputTester.new *["self <<
|
238
|
+
input = InputTester.new *["self << _out_.max_size << _in_.max_size"]
|
179
239
|
pry = Pry.new(:input => input, :output => Pry::NullOutput)
|
180
240
|
pry.repl(res)
|
181
241
|
|
@@ -184,7 +244,7 @@ describe Pry do
|
|
184
244
|
|
185
245
|
it 'can change the size of the history arrays' do
|
186
246
|
res = []
|
187
|
-
input = InputTester.new *["self <<
|
247
|
+
input = InputTester.new *["self << _out_.max_size << _in_.max_size"]
|
188
248
|
pry = Pry.new(:input => input, :output => Pry::NullOutput,
|
189
249
|
:memory_size => 1000)
|
190
250
|
pry.repl(res)
|
@@ -194,7 +254,7 @@ describe Pry do
|
|
194
254
|
|
195
255
|
it 'store exceptions' do
|
196
256
|
res = []
|
197
|
-
input = InputTester.new *["foo!","self <<
|
257
|
+
input = InputTester.new *["foo!","self << _in_[-1] << _out_[-1]"]
|
198
258
|
pry = Pry.new(:input => input, :output => Pry::NullOutput,
|
199
259
|
:memory_size => 1000)
|
200
260
|
pry.repl(res)
|
@@ -219,10 +279,10 @@ describe Pry do
|
|
219
279
|
Pry.config.should_load_rc = true
|
220
280
|
Pry::RC_FILES << File.expand_path("../testrc", __FILE__)
|
221
281
|
|
222
|
-
Pry.start(self, :input => StringIO.new("exit\n"), :output => Pry::NullOutput)
|
282
|
+
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput)
|
223
283
|
TEST_RC.should == [0]
|
224
284
|
|
225
|
-
Pry.start(self, :input => StringIO.new("exit\n"), :output => Pry::NullOutput)
|
285
|
+
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput)
|
226
286
|
TEST_RC.should == [0]
|
227
287
|
|
228
288
|
Object.remove_const(:TEST_RC)
|
@@ -230,13 +290,13 @@ describe Pry do
|
|
230
290
|
|
231
291
|
it "should not run the rc file at all if Pry.config.should_load_rc is false" do
|
232
292
|
Pry.config.should_load_rc = false
|
233
|
-
Pry.start(self, :input => StringIO.new("exit\n"), :output => Pry::NullOutput)
|
293
|
+
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput)
|
234
294
|
Object.const_defined?(:TEST_RC).should == false
|
235
295
|
end
|
236
296
|
|
237
297
|
it "should not load the rc file if #repl method invoked" do
|
238
298
|
Pry.config.should_load_rc = true
|
239
|
-
Pry.new(:input => StringIO.new("exit\n"), :output => Pry::NullOutput).repl(self)
|
299
|
+
Pry.new(:input => StringIO.new("exit-all\n"), :output => Pry::NullOutput).repl(self)
|
240
300
|
Object.const_defined?(:TEST_RC).should == false
|
241
301
|
Pry.config.should_load_rc = false
|
242
302
|
end
|
@@ -249,7 +309,7 @@ describe Pry do
|
|
249
309
|
end
|
250
310
|
|
251
311
|
it 'should nest properly' do
|
252
|
-
Pry.input = InputTester.new("
|
312
|
+
Pry.input = InputTester.new("cd 1", "cd 2", "cd 3", "\"nest:\#\{(_pry_.binding_stack.size - 1)\}\"", "exit-all")
|
253
313
|
|
254
314
|
str_output = StringIO.new
|
255
315
|
Pry.output = str_output
|
@@ -300,7 +360,7 @@ describe Pry do
|
|
300
360
|
it 'should run a command with no parameter' do
|
301
361
|
pry_tester = Pry.new
|
302
362
|
pry_tester.commands = CommandTester
|
303
|
-
pry_tester.input = InputTester.new("command1", "
|
363
|
+
pry_tester.input = InputTester.new("command1", "exit-all")
|
304
364
|
pry_tester.commands = CommandTester
|
305
365
|
|
306
366
|
str_output = StringIO.new
|
@@ -314,7 +374,7 @@ describe Pry do
|
|
314
374
|
it 'should run a command with one parameter' do
|
315
375
|
pry_tester = Pry.new
|
316
376
|
pry_tester.commands = CommandTester
|
317
|
-
pry_tester.input = InputTester.new("command2 horsey", "
|
377
|
+
pry_tester.input = InputTester.new("command2 horsey", "exit-all")
|
318
378
|
pry_tester.commands = CommandTester
|
319
379
|
|
320
380
|
str_output = StringIO.new
|
@@ -334,7 +394,7 @@ describe Pry do
|
|
334
394
|
end
|
335
395
|
|
336
396
|
it "should start a pry session on the receiver (first form)" do
|
337
|
-
Pry.input = InputTester.new("self", "exit")
|
397
|
+
Pry.input = InputTester.new("self", "exit-all")
|
338
398
|
|
339
399
|
str_output = StringIO.new
|
340
400
|
Pry.output = str_output
|
@@ -345,7 +405,7 @@ describe Pry do
|
|
345
405
|
end
|
346
406
|
|
347
407
|
it "should start a pry session on the receiver (second form)" do
|
348
|
-
Pry.input = InputTester.new("self", "exit")
|
408
|
+
Pry.input = InputTester.new("self", "exit-all")
|
349
409
|
|
350
410
|
str_output = StringIO.new
|
351
411
|
Pry.output = str_output
|
@@ -403,7 +463,7 @@ describe Pry do
|
|
403
463
|
attr_accessor :prompt
|
404
464
|
def readline(prompt)
|
405
465
|
@prompt = prompt
|
406
|
-
"exit"
|
466
|
+
"exit-all"
|
407
467
|
end
|
408
468
|
end.new
|
409
469
|
|
@@ -416,7 +476,7 @@ describe Pry do
|
|
416
476
|
|
417
477
|
arity_zero_input = Class.new do
|
418
478
|
def readline
|
419
|
-
"exit"
|
479
|
+
"exit-all"
|
420
480
|
end
|
421
481
|
end.new
|
422
482
|
|
@@ -431,7 +491,7 @@ describe Pry do
|
|
431
491
|
|
432
492
|
def readline(*args)
|
433
493
|
@prompt = args.first
|
434
|
-
"exit"
|
494
|
+
"exit-all"
|
435
495
|
end
|
436
496
|
end.new
|
437
497
|
|
@@ -474,6 +534,15 @@ describe Pry do
|
|
474
534
|
$test_interpolation = nil
|
475
535
|
end
|
476
536
|
|
537
|
+
# bug fix for https://github.com/pry/pry/issues/170
|
538
|
+
it 'should not choke on complex string interpolation when checking if ruby code is a command' do
|
539
|
+
redirect_pry_io(InputTester.new('/#{Regexp.escape(File.expand_path("."))}/'), str_output = StringIO.new) do
|
540
|
+
pry
|
541
|
+
end
|
542
|
+
|
543
|
+
str_output.string.should.not =~ /SyntaxError/
|
544
|
+
end
|
545
|
+
|
477
546
|
it 'should NOT interpolate ruby code into commands if :interpolate => false' do
|
478
547
|
klass = Pry::CommandSet.new do
|
479
548
|
command "hello", "", :keep_retval => true, :interpolate => false do |arg|
|
@@ -488,6 +557,21 @@ describe Pry do
|
|
488
557
|
$test_interpolation = nil
|
489
558
|
end
|
490
559
|
|
560
|
+
it 'should NOT try to interpolate pure ruby code (no commands) ' do
|
561
|
+
str_output = StringIO.new
|
562
|
+
Pry.new(:input => StringIO.new('puts \'#{aggy}\''), :output => str_output).rep
|
563
|
+
str_output.string.should.not =~ /NameError/
|
564
|
+
|
565
|
+
Pry.new(:input => StringIO.new('puts #{aggy}'), :output => str_output).rep
|
566
|
+
str_output.string.should.not =~ /NameError/
|
567
|
+
|
568
|
+
$test_interpolation = "blah"
|
569
|
+
Pry.new(:input => StringIO.new('puts \'#{$test_interpolation}\''), :output => str_output).rep
|
570
|
+
|
571
|
+
str_output.string.should.not =~ /blah/
|
572
|
+
$test_interpolation = nil
|
573
|
+
end
|
574
|
+
|
491
575
|
it 'should create a command with a space in its name' do
|
492
576
|
set = Pry::CommandSet.new do
|
493
577
|
command "hello baby", "" do
|
@@ -605,15 +689,13 @@ describe Pry do
|
|
605
689
|
end
|
606
690
|
|
607
691
|
it 'should create a command in a nested context and that command should be accessible from the parent' do
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
Pry.
|
612
|
-
obj = Object.new
|
613
|
-
Pry.new(:output => str_output).repl(obj)
|
614
|
-
Pry.input = Readline
|
615
|
-
str_output.string.should =~ /@x/
|
692
|
+
str_output = StringIO.new
|
693
|
+
x = "@x=nil\ncd 7\n_pry_.commands.instance_eval {\ncommand('bing') { |arg| run arg }\n}\ncd ..\nbing ls\nexit-all"
|
694
|
+
redirect_pry_io(StringIO.new("@x=nil\ncd 7\n_pry_.commands.instance_eval {\ncommand('bing') { |arg| run arg }\n}\ncd ..\nbing ls\nexit-all"), str_output) do
|
695
|
+
Pry.new.repl(0)
|
616
696
|
end
|
697
|
+
|
698
|
+
str_output.string.should =~ /@x/
|
617
699
|
end
|
618
700
|
|
619
701
|
it 'should define a command that keeps its return value' do
|
@@ -640,6 +722,66 @@ describe Pry do
|
|
640
722
|
str_output.string !~ /=>/
|
641
723
|
end
|
642
724
|
|
725
|
+
it 'should define a command that keeps its return value even when nil' do
|
726
|
+
klass = Pry::CommandSet.new do
|
727
|
+
command "hello", "", :keep_retval => true do
|
728
|
+
nil
|
729
|
+
end
|
730
|
+
end
|
731
|
+
str_output = StringIO.new
|
732
|
+
Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => klass).rep
|
733
|
+
str_output.string.should =~ /nil/
|
734
|
+
str_output.string.should =~ /=>/
|
735
|
+
end
|
736
|
+
|
737
|
+
it 'should define a command that keeps its return value but does not return when value is void' do
|
738
|
+
klass = Pry::CommandSet.new do
|
739
|
+
command "hello", "", :keep_retval => true do
|
740
|
+
void
|
741
|
+
end
|
742
|
+
end
|
743
|
+
str_output = StringIO.new
|
744
|
+
Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => klass).rep
|
745
|
+
str_output.string.empty?.should == true
|
746
|
+
end
|
747
|
+
|
748
|
+
it 'a command (with :keep_retval => false) that replaces eval_string with a valid expression should not have the expression value suppressed' do
|
749
|
+
klass = Pry::CommandSet.new do
|
750
|
+
command "hello", "" do
|
751
|
+
eval_string.replace("6")
|
752
|
+
end
|
753
|
+
end
|
754
|
+
str_output = StringIO.new
|
755
|
+
Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
|
756
|
+
str_output.string.should =~ /6/
|
757
|
+
end
|
758
|
+
|
759
|
+
|
760
|
+
it 'a command (with :keep_retval => true) that replaces eval_string with a valid expression should overwrite the eval_string with the return value' do
|
761
|
+
klass = Pry::CommandSet.new do
|
762
|
+
command "hello", "", :keep_retval => true do
|
763
|
+
eval_string.replace("6")
|
764
|
+
7
|
765
|
+
end
|
766
|
+
end
|
767
|
+
str_output = StringIO.new
|
768
|
+
Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
|
769
|
+
str_output.string.should =~ /7/
|
770
|
+
str_output.string.should.not =~ /6/
|
771
|
+
end
|
772
|
+
|
773
|
+
it 'a command that return a value in a multi-line expression should clear the expression and return the value' do
|
774
|
+
klass = Pry::CommandSet.new do
|
775
|
+
command "hello", "", :keep_retval => true do
|
776
|
+
5
|
777
|
+
end
|
778
|
+
end
|
779
|
+
str_output = StringIO.new
|
780
|
+
Pry.new(:input => StringIO.new("def yo\nhello\n"), :output => str_output, :commands => klass).rep
|
781
|
+
str_output.string.should =~ /5/
|
782
|
+
end
|
783
|
+
|
784
|
+
|
643
785
|
it 'should set the commands default, and the default should be overridable' do
|
644
786
|
klass = Pry::CommandSet.new do
|
645
787
|
command "hello" do
|
@@ -673,7 +815,7 @@ describe Pry do
|
|
673
815
|
|
674
816
|
klass.commands.keys.size.should == 3
|
675
817
|
klass.commands.keys.include?("help").should == true
|
676
|
-
klass.commands.keys.include?("install").should == true
|
818
|
+
klass.commands.keys.include?("install-command").should == true
|
677
819
|
klass.commands.keys.include?("h").should == true
|
678
820
|
end
|
679
821
|
|
@@ -859,23 +1001,23 @@ describe Pry do
|
|
859
1001
|
|
860
1002
|
describe "pry return values" do
|
861
1003
|
it 'should return the target object' do
|
862
|
-
Pry.start(self, :input => StringIO.new("exit"), :output => Pry::NullOutput).should == self
|
1004
|
+
Pry.start(self, :input => StringIO.new("exit-all"), :output => Pry::NullOutput).should == self
|
863
1005
|
end
|
864
1006
|
|
865
|
-
it 'should return the parameter given to exit' do
|
866
|
-
Pry.start(self, :input => StringIO.new("exit 10"), :output => Pry::NullOutput).should == 10
|
1007
|
+
it 'should return the parameter given to exit-all' do
|
1008
|
+
Pry.start(self, :input => StringIO.new("exit-all 10"), :output => Pry::NullOutput).should == 10
|
867
1009
|
end
|
868
1010
|
|
869
|
-
it 'should return the parameter (multi word string) given to exit' do
|
870
|
-
Pry.start(self, :input => StringIO.new("exit \"john mair\""), :output => Pry::NullOutput).should == "john mair"
|
1011
|
+
it 'should return the parameter (multi word string) given to exit-all' do
|
1012
|
+
Pry.start(self, :input => StringIO.new("exit-all \"john mair\""), :output => Pry::NullOutput).should == "john mair"
|
871
1013
|
end
|
872
1014
|
|
873
|
-
it 'should return the parameter (function call) given to exit' do
|
874
|
-
Pry.start(self, :input => StringIO.new("exit 'abc'.reverse"), :output => Pry::NullOutput).should == 'cba'
|
1015
|
+
it 'should return the parameter (function call) given to exit-all' do
|
1016
|
+
Pry.start(self, :input => StringIO.new("exit-all 'abc'.reverse"), :output => Pry::NullOutput).should == 'cba'
|
875
1017
|
end
|
876
1018
|
|
877
|
-
it 'should return the parameter (self) given to exit' do
|
878
|
-
Pry.start("carl", :input => StringIO.new("exit self"), :output => Pry::NullOutput).should == "carl"
|
1019
|
+
it 'should return the parameter (self) given to exit-all' do
|
1020
|
+
Pry.start("carl", :input => StringIO.new("exit-all self"), :output => Pry::NullOutput).should == "carl"
|
879
1021
|
end
|
880
1022
|
end
|
881
1023
|
|
@@ -980,8 +1122,82 @@ describe Pry do
|
|
980
1122
|
end
|
981
1123
|
end
|
982
1124
|
|
1125
|
+
describe "view_clip used for displaying an object in a truncated format" do
|
1126
|
+
|
1127
|
+
VC_MAX_LENGTH = 60
|
1128
|
+
|
1129
|
+
describe "given an object with an #inspect string shorter than the maximum specified" do
|
1130
|
+
it "returns the #inspect string" do
|
1131
|
+
o = Object.new
|
1132
|
+
def o.inspect; "a" * VC_MAX_LENGTH; end
|
1133
|
+
|
1134
|
+
Pry.view_clip(o, VC_MAX_LENGTH).should == o.inspect
|
1135
|
+
end
|
1136
|
+
end
|
1137
|
+
|
1138
|
+
describe "given an object with an #inspect string as long as the maximum specified" do
|
1139
|
+
it "returns the #inspect string" do
|
1140
|
+
o = Object.new
|
1141
|
+
def o.inspect; "a" * VC_MAX_LENGTH; end
|
1142
|
+
|
1143
|
+
Pry.view_clip(o, VC_MAX_LENGTH).should == o.inspect
|
1144
|
+
end
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
describe "given a regular object with an #inspect string longer than the maximum specified" do
|
1148
|
+
|
1149
|
+
describe "when the object is a regular one" do
|
1150
|
+
it "returns a string of the #<class name:object idish> format" do
|
1151
|
+
o = Object.new
|
1152
|
+
def o.inspect; "a" * (VC_MAX_LENGTH + 1); end
|
1153
|
+
|
1154
|
+
Pry.view_clip(o, VC_MAX_LENGTH).should =~ /Object:0x\d+?/
|
1155
|
+
end
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
describe "when the object is a Class or a Module" do
|
1159
|
+
describe "without a name (usually a c = Class.new)" do
|
1160
|
+
it "returns a string of the #<class name:object idish> format" do
|
1161
|
+
c, m = Class.new, Module.new
|
1162
|
+
|
1163
|
+
Pry.view_clip(c, VC_MAX_LENGTH).should =~ /Class:0x.*?/
|
1164
|
+
Pry.view_clip(m, VC_MAX_LENGTH).should =~ /Module:0x.*?/
|
1165
|
+
end
|
1166
|
+
end
|
1167
|
+
|
1168
|
+
describe "with a #name longer than the maximum specified" do
|
1169
|
+
it "returns a string of the #<class name:object idish> format" do
|
1170
|
+
c, m = Class.new, Module.new
|
1171
|
+
|
1172
|
+
|
1173
|
+
def c.name; "a" * (VC_MAX_LENGTH + 1); end
|
1174
|
+
def m.name; "a" * (VC_MAX_LENGTH + 1); end
|
1175
|
+
|
1176
|
+
Pry.view_clip(c, VC_MAX_LENGTH).should =~ /Class:0x.*?/
|
1177
|
+
Pry.view_clip(m, VC_MAX_LENGTH).should =~ /Module:0x.*?/
|
1178
|
+
end
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
describe "with a #name shorter than or equal to the maximum specified" do
|
1182
|
+
it "returns a string of the #<class name:object idish> format" do
|
1183
|
+
c, m = Class.new, Module.new
|
1184
|
+
|
1185
|
+
def c.name; "a" * VC_MAX_LENGTH; end
|
1186
|
+
def m.name; "a" * VC_MAX_LENGTH; end
|
1187
|
+
|
1188
|
+
Pry.view_clip(c, VC_MAX_LENGTH).should == c.name
|
1189
|
+
Pry.view_clip(m, VC_MAX_LENGTH).should == m.name
|
1190
|
+
end
|
1191
|
+
end
|
1192
|
+
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
end
|
1196
|
+
|
1197
|
+
end
|
1198
|
+
|
983
1199
|
it 'should set the hooks default, and the default should be overridable' do
|
984
|
-
Pry.input = InputTester.new("exit")
|
1200
|
+
Pry.input = InputTester.new("exit-all")
|
985
1201
|
Pry.hooks = {
|
986
1202
|
:before_session => proc { |out,_| out.puts "HELLO" },
|
987
1203
|
:after_session => proc { |out,_| out.puts "BYE" }
|