3 Matching Annotations
  1. Nov 2023
    1. Otherwise, M does not respond to works? (NoMethodError) because there was a context switch before the require triggered by autoload returned.
    2. If it passed before I would think it was just lucky timings.
    3. BTW to improve the reliability of that test I believe you would need a sleep (smaller, e.g. of 0.1) between the Thread.new and assert M.works?, otherwise it's likely the M.works? runs first and then the other thread will see the constant is autoloading and wait, and anyway that thread does not check what is defined on M. For the test to fail it needs to be the Thread.new running first and defining the constant but not yet the method, before the main thread keeps running and call the method.