Skip to content

Commit 94884da

Browse files
committed
Handle renaming of global_constant_state in Ruby 3.2
Ref: ruby/ruby#5766
1 parent f6f59be commit 94884da

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

activesupport/test/core_ext/enumerable_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,19 @@ def test_sole
362362
end
363363

364364
def test_doesnt_bust_constant_cache
365-
skip "Only applies to MRI" unless defined?(RubyVM.stat) && RubyVM.stat(:global_constant_state)
365+
skip "Only applies to MRI" unless defined?(RubyVM.stat)
366366

367367
object = Object.new
368-
assert_no_difference -> { RubyVM.stat(:global_constant_state) } do
368+
assert_no_difference -> { constant_cache_invalidations } do
369369
object.extend(Enumerable)
370370
end
371371
end
372+
373+
private
374+
375+
def constant_cache_invalidations
376+
RubyVM.stat(:constant_cache_invalidations)
377+
rescue ArgumentError
378+
RubyVM.stat(:global_constant_state) # RUBY_VERSION < "3.2"
379+
end
372380
end

0 commit comments

Comments
 (0)