diff --git a/contrib/ruby/test/test_helper.rb b/contrib/ruby/test/test_helper.rb index 2c288ecc..f532fd75 100644 --- a/contrib/ruby/test/test_helper.rb +++ b/contrib/ruby/test/test_helper.rb @@ -10,7 +10,14 @@ if GC.respond_to?(:verify_compaction_references) # This method was added in Ruby 3.0.0. Calling it this way asks the GC to # move objects around, helping to find object movement bugs. - GC.verify_compaction_references(double_heap: true, toward: :empty) + if Gem::Version::new(RUBY_VERSION) >= Gem::Version::new("3.2.0") + # double_heap is deprecated and expand_heap is the updated argument. This change + # was introduced in: + # https://github.com/ruby/ruby/commit/a6dd859affc42b667279e513bb94fb75cfb133c1 + GC.verify_compaction_references(expand_heap: true, toward: :empty) + else + GC.verify_compaction_references(double_heap: true, toward: :empty) + end end class TrilogyTest < Minitest::Test