Skip to content

Commit 16082e2

Browse files
committed
Fix the attribute tests to work with Ruby that allows attribute methods to be traced
I have a pull request to fix this in Ruby, but it currently cannot be merged because this test fails, as it expects the previous broken behavior. This changes the test to accept either the older broken output or the fixed output.
1 parent 9c63144 commit 16082e2

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

test/block_test.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ def Assertion(&blk)
276276
end
277277

278278
sub_test_case 'attribute' do
279-
# TracePoint cannot trace attributes
280-
# https://bugs.ruby-lang.org/issues/10470
281279
setup do
282280
@obj = Class.new do
283281
attr_accessor :to_i
@@ -287,23 +285,41 @@ def inspect; '#<Class>'; end
287285
end
288286

289287
t do
290-
assert_equal <<END.chomp, assertion_message {
288+
older = <<END.chomp
291289
@obj.to_i.to_i.to_s
292290
| |
293291
| "0"
294292
#<Class>
295293
END
294+
newer = <<END.chomp
295+
@obj.to_i.to_i.to_s
296+
| | | |
297+
| | | "0"
298+
| | 0
299+
| 0
300+
#<Class>
301+
END
302+
assert_includes [older, newer], assertion_message {
303+
296304
@obj.to_i.to_i.to_s
297305
}
298306
end
299307

300308
t do
301-
assert_equal <<END.chomp, assertion_message {
309+
older = <<END.chomp
302310
true ? @obj.to_i.to_s : @obj.to_i
303311
| |
304312
| "0"
305313
#<Class>
306314
END
315+
newer = <<END.chomp
316+
true ? @obj.to_i.to_s : @obj.to_i
317+
| | |
318+
| | "0"
319+
| 0
320+
#<Class>
321+
END
322+
assert_includes [older, newer], assertion_message {
307323
true ? @obj.to_i.to_s : @obj.to_i
308324
}
309325
end

0 commit comments

Comments
 (0)