From 49eda788c5dca4c051148b70b61b04ae557d9445 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 3 May 2024 10:28:12 +1200 Subject: [PATCH] Add test for nested threads. --- test/fiber/local.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/fiber/local.rb b/test/fiber/local.rb index 827ac53..8f2399f 100644 --- a/test/fiber/local.rb +++ b/test/fiber/local.rb @@ -49,6 +49,22 @@ class MyThing MyThing.fiber_local_attribute_name => be_equal(instance) ) end + + it "inherits assigned values in nested threads" do + instance = Object.new + + storage = Thread.new do + MyThing.instance = instance + + Thread.new do + Fiber.current.storage + end.value + end.value + + expect(storage).to have_keys( + MyThing.fiber_local_attribute_name => be_equal(instance) + ) + end end with '#instance=' do