From b082276376e6cd798e05d196a8e8f5df32120105 Mon Sep 17 00:00:00 2001 From: CarterPerez-dev Date: Sun, 26 Jul 2026 10:09:11 -0400 Subject: [PATCH] fix(rube): load erb at require time, not inside generate test_generate_returns_an_object_not_bytes errored on roughly 1 run in 12 under Minitest's random ordering. assert_kind_of ERB, chain.generate evaluates the ERB constant before calling generate, and generate was performing a lazy require of erb inside itself. If that test ran before anything else had loaded erb, the constant did not exist. The lazy require was the defect rather than the test. A require buried in a method makes constant availability depend on call order for every caller, not just this one. Moved to the top of the file. Verified across 40 randomized runs, 0 unstable. The previous commit shipped this suite showing 1 error and should not have. --- .../lib/rube/chains/erb_def_method.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PROJECTS/beginner/deserialization-gadget-lab/lib/rube/chains/erb_def_method.rb b/PROJECTS/beginner/deserialization-gadget-lab/lib/rube/chains/erb_def_method.rb index 81dc1d90..08fb5dcb 100644 --- a/PROJECTS/beginner/deserialization-gadget-lab/lib/rube/chains/erb_def_method.rb +++ b/PROJECTS/beginner/deserialization-gadget-lab/lib/rube/chains/erb_def_method.rb @@ -1,6 +1,8 @@ # ©AngelaMos | 2026 # erb_def_method.rb +require "erb" + module Rube module Chains class ErbDefMethod < Base @@ -47,8 +49,6 @@ module Rube end def generate - require "erb" - object = ERB.allocate object.instance_variable_set(IVAR_SRC, src) object.instance_variable_set(IVAR_FILENAME, DEFAULT_FILENAME)