Threads provide no guarantees about when the OS will schedule them. When you start using threads you need to synchronize at appropriate points if you want to assert that the thread completed it's work. For this kind of situation, the standard way to do that is `Thread#join`:
It will block until the thread is complete, so that have a guarantee that the thread's work was finished.
Unfortunately, the thread instance is created in a private method and discarded so you don't have direct access to that thread from your spec in order to join on it. You could use `Thread.list` to find that thread:
...but I'd say that your code isn't very testable, and it's far better to use your testing pain as an impetus to improve the design.
Most people do that kind of background work using something like Sidekiq rather than a thread:
Have you considered using that?
Myron