Skip to content

Commit

Permalink
Handle renaming of global_constant_state in Ruby 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Apr 6, 2022
1 parent f6f59be commit 94884da
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions activesupport/test/core_ext/enumerable_test.rb
Expand Up @@ -362,11 +362,19 @@ def test_sole
end

def test_doesnt_bust_constant_cache
skip "Only applies to MRI" unless defined?(RubyVM.stat) && RubyVM.stat(:global_constant_state)
skip "Only applies to MRI" unless defined?(RubyVM.stat)

object = Object.new
assert_no_difference -> { RubyVM.stat(:global_constant_state) } do
assert_no_difference -> { constant_cache_invalidations } do
object.extend(Enumerable)
end
end

private

def constant_cache_invalidations
RubyVM.stat(:constant_cache_invalidations)
rescue ArgumentError
RubyVM.stat(:global_constant_state) # RUBY_VERSION < "3.2"
end
end

0 comments on commit 94884da

Please sign in to comment.