Skip to content

Commit 6a1ab01

Browse files
committed
Update to support pry 0.13
1 parent 7d9dcf1 commit 6a1ab01

File tree

2 files changed

+41
-21
lines changed

2 files changed

+41
-21
lines changed

pry-inline.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
1818
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
1919
spec.require_paths = ['lib']
2020

21-
spec.add_dependency 'pry', '> 0.10.0', '<= 0.12.2'
21+
spec.add_dependency 'pry', '> 0.10.0', '<= 0.13'
2222
spec.add_dependency 'unicode', '~> 0.4.4'
2323
spec.add_development_dependency 'bundler', '~> 1.10'
2424
spec.add_development_dependency 'rake', '~> 12.3'

test/test_inline.rb

+40-20
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ def greet
1414
end
1515

1616
actual = output_of_whereami { greet }
17-
assert_equal <<EOF.chomp, actual
17+
expected = <<EOF.chomp
1818
def greet
1919
message = 'Hello, world!' # message: "Hello, world!"
2020
@binding = binding
2121
message
2222
end
2323
EOF
24+
assert { actual.end_with?(expected) }
2425
end
2526

2627
test 'multiple assignment of local variables' do
@@ -30,12 +31,13 @@ def multiple_assign
3031
end
3132

3233
actual = output_of_whereami { multiple_assign }
33-
assert_equal <<EOF.chomp, actual
34+
expected = <<EOF.chomp
3435
def multiple_assign
3536
x, y = 10, 20 # x: 10, y: 20
3637
@binding = binding
3738
end
3839
EOF
40+
assert { actual.end_with?(expected) }
3941
end
4042

4143
test 'operator assign of local variables' do
@@ -48,7 +50,7 @@ def opassign
4850
end
4951

5052
actual = output_of_whereami { opassign }
51-
assert_equal <<EOF.chomp, actual
53+
expected = <<EOF.chomp
5254
def opassign
5355
x, y, z = 1, 2, false
5456
x += 10 # x: 11
@@ -57,6 +59,7 @@ def opassign
5759
@binding = binding
5860
end
5961
EOF
62+
assert { actual.end_with?(expected) }
6063
end
6164

6265
test 'parameters of block' do
@@ -67,13 +70,14 @@ def block_parameters
6770
end
6871

6972
actual = output_of_whereami { block_parameters }
70-
assert_equal <<EOF.chomp, actual
73+
expected = <<EOF.chomp
7174
def block_parameters
7275
(1..10).each do |i| # i: 5
7376
@binding = binding if i == 5
7477
end
7578
end
7679
EOF
80+
assert { actual.end_with?(expected) }
7781
end
7882

7983
test 'assignment of instance variable' do
@@ -84,13 +88,14 @@ def assign_instance_variable
8488
end
8589

8690
actual = output_of_whereami { assign_instance_variable }
87-
assert_equal <<EOF.chomp, actual
91+
expected = <<EOF.chomp
8892
def assign_instance_variable
8993
@x = [1, 2, 3] # @x: [1, 2, 3]
9094
@binding = binding
9195
@y = [4, 5, 6]
9296
end
9397
EOF
98+
assert { actual.end_with?(expected) }
9499
end
95100

96101
test 'assignment of class variable' do
@@ -100,12 +105,13 @@ def assign_class_variable
100105
end
101106

102107
actual = output_of_whereami { assign_class_variable }
103-
assert_equal <<EOF.chomp, actual
108+
expected = <<EOF.chomp
104109
def assign_class_variable
105110
@@var = { x: 10 } # @@var: {:x=>10}
106111
@binding = binding
107112
end
108113
EOF
114+
assert { actual.end_with?(expected) }
109115
end
110116

111117
test 'assignment of global variable' do
@@ -115,12 +121,13 @@ def assign_class_variable
115121
end
116122

117123
actual = output_of_whereami { assign_class_variable }
118-
assert_equal <<EOF.chomp, actual
124+
expected = <<EOF.chomp
119125
def assign_class_variable
120126
$var = { x: 10 } # $var: {:x=>10}
121127
@binding = binding
122128
end
123129
EOF
130+
assert { actual.end_with?(expected) }
124131
end
125132

126133
test 'assignment of var args' do
@@ -129,11 +136,12 @@ def use_var_args(*args)
129136
end
130137

131138
actual = output_of_whereami { use_var_args(1, 2, 3) }
132-
assert_equal <<EOF.chomp, actual
139+
expected = <<EOF.chomp
133140
def use_var_args(*args) # args: [1, 2, 3]
134141
@binding = binding
135142
end
136143
EOF
144+
assert { actual.end_with?(expected) }
137145
end
138146

139147
test 'assignment after binding.pry' do
@@ -144,13 +152,14 @@ def assignment_after_binding
144152
end
145153

146154
actual = output_of_whereami { assignment_after_binding }
147-
assert_equal <<EOF.chomp, actual
155+
expected = <<EOF.chomp
148156
def assignment_after_binding
149157
x = 10 # x: 10
150158
@binding = binding
151159
y = 10
152160
end
153161
EOF
162+
assert { actual.end_with?(expected) }
154163
end
155164

156165
test 'keyword arguments' do
@@ -159,11 +168,12 @@ def keyword_arguments(a: 10, b: 20)
159168
end
160169

161170
actual = output_of_whereami { keyword_arguments(b: 100) }
162-
assert_equal <<EOF.chomp, actual
171+
expected = <<EOF.chomp
163172
def keyword_arguments(a: 10, b: 20) # a: 10, b: 100
164173
@binding = binding
165174
end
166175
EOF
176+
assert { actual.end_with?(expected) }
167177
end
168178

169179
test 'combinations of arguments' do
@@ -176,11 +186,12 @@ def f(a, m = 1, *rest, x, k: 1, **kwrest) # a: "a", m: 2, rest: ["f", "b"], x: "
176186
end
177187
EOF
178188
actual = output_of_whereami { f('a', 2, 'f', 'b', 'x', k: 42, u: 'u') }
179-
assert_equal <<EOF.chomp, actual
189+
expected = <<EOF.chomp
180190
def f(a, m = 1, *rest, x, k: 1, **kwrest) # a: "a", m: 2, rest: ["f", "b"], x: "x", k: 42, kwrest: {:u=>"u"}
181191
@binding = binding
182192
end
183193
EOF
194+
assert { actual.end_with?(expected) }
184195
end
185196

186197
test 'too long function' do
@@ -217,7 +228,7 @@ def too_long_function
217228
i += 1
218229
end
219230
actual = output_of_whereami { too_long_function }
220-
assert_equal <<EOF.chomp, actual
231+
expected = <<EOF.chomp
221232
def too_long_function
222233
i = 0
223234
i += 1
@@ -230,6 +241,7 @@ def too_long_function
230241
i += 1
231242
i += 1
232243
EOF
244+
assert { actual.end_with?(expected) }
233245
end
234246

235247
test 'line number' do
@@ -241,13 +253,14 @@ def greet_with_line_number
241253

242254
actual = output_of_whereami(with_line_number: true) { greet_with_line_number }
243255
lineno = method(:greet_with_line_number).source_location[1]
244-
assert_equal <<EOF.chomp, actual
256+
expected = <<EOF.chomp
245257
#{lineno + 0}: def greet_with_line_number
246258
#{lineno + 1}: message = 'Hello, world!' # message: "Hello, world!"
247259
=> #{lineno + 2}: @binding = binding
248260
#{lineno + 3}: message
249261
#{lineno + 4}: end
250262
EOF
263+
assert { actual.end_with?(expected) }
251264
end
252265

253266
test 'too long debug info' do
@@ -258,12 +271,13 @@ def too_long_debug_info
258271

259272
actual = output_of_whereami(terminal_width: 40) { too_long_debug_info }
260273
# <= 40
261-
assert_equal <<EOF.chomp, actual
274+
expected = <<EOF.chomp
262275
def too_long_debug_info
263276
message = '0' * 100 # message: "000000
264277
@binding = binding
265278
end
266279
EOF
280+
assert { actual.end_with?(expected) }
267281
end
268282

269283
test 'too long debug info and line number' do
@@ -276,12 +290,13 @@ def too_long_debug_info_and_line_number
276290
too_long_debug_info_and_line_number
277291
end
278292
lineno = method(:too_long_debug_info_and_line_number).source_location[1]
279-
assert_equal <<EOF.chomp, actual
293+
expected = <<EOF.chomp
280294
#{lineno + 0}: def too_long_debug_info_and_line_number
281295
#{lineno + 1}: message = '0' * 100 # message
282296
=> #{lineno + 2}: @binding = binding
283297
#{lineno + 3}: end
284298
EOF
299+
assert { actual.end_with?(expected) }
285300
end
286301

287302
test 'too long debug info including wide characters' do
@@ -294,12 +309,13 @@ def too_long_debug_info_including_wide_characters
294309
too_long_debug_info_including_wide_characters
295310
end
296311
# <= 40
297-
assert_equal <<EOF.chomp, actual
312+
expected = <<EOF.chomp
298313
def too_long_debug_info_including_wide_characters
299314
a = 'あa' * 100 # a: "あaあaあaあaあa
300315
@binding = binding
301316
end
302317
EOF
318+
assert { actual.end_with?(expected) }
303319
end
304320

305321
test 'too long debug info including ambigous characters' do
@@ -312,12 +328,13 @@ def too_long_debug_info_including_wide_characters
312328
too_long_debug_info_including_wide_characters
313329
end
314330
# <= 41
315-
assert_equal <<EOF.chomp, actual
331+
expected = <<EOF.chomp
316332
def too_long_debug_info_including_wide_characters
317333
a = 'あa☆' * 100 # a: "あa☆あa☆あa☆
318334
@binding = binding
319335
end
320336
EOF
337+
assert { actual.end_with?(expected) }
321338
end
322339

323340
test 'min debug info width option' do
@@ -330,12 +347,13 @@ def min_debug_info
330347
min_debug_info
331348
end
332349
# <= 40
333-
assert_equal <<EOF.chomp, actual
350+
expected = <<EOF.chomp
334351
def min_debug_info
335352
message = '0' * 100 # message: "0000000000000000000000000000000000000000000000
336353
@binding = binding
337354
end
338355
EOF
356+
assert { actual.end_with?(expected) }
339357
end
340358

341359
test 'first statement' do
@@ -352,7 +370,7 @@ def foo(x)
352370
end
353371

354372
actual = output_of_whereami { foo(3) }
355-
assert_equal <<EOF.chomp, actual
373+
expected = <<EOF.chomp
356374
def foo(x)
357375
x += 9 # x: 12
358376
@binding = binding
@@ -361,6 +379,7 @@ def foo(x)
361379
x
362380
end
363381
EOF
382+
assert { actual.end_with?(expected) }
364383
end
365384

366385
test 'rescue variable' do
@@ -371,13 +390,14 @@ def cause_error
371390
end
372391

373392
actual = output_of_whereami { cause_error }
374-
assert_equal <<EOF.chomp, actual
393+
expected = <<EOF.chomp
375394
def cause_error
376395
raise 'Hello, world!'
377396
rescue => e # e: #<RuntimeError: Hello, world!>
378397
@binding = binding
379398
end
380399
EOF
400+
assert { actual.end_with?(expected) }
381401
end
382402

383403
private

0 commit comments

Comments
 (0)