-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking Thread.current.thread_variable_get
causes stack overflow.
#605
Comments
Apparently caused by #581 |
…er to mock them Fixes rspec#605.
Yes. I had tracked down the issue to 01eb9b2, but I forgot to mention this in the report. Sorry for that!
If I understood correctly, mutexes use a copy of the stdlib code. Because |
…er to mock them Fixes rspec#605.
…er to mock them Fixes rspec#605.
…er to mock them Fixes rspec#605.
…er to mock them Fixes rspec#605.
…er to mock them Fixes rspec#605.
Mocking
Thread.current.thread_variable_get
used to work with rspec-support <= 3.12.0. With rspec-support >= 3.12.1, it causes a stack overflow.Your environment
Analysis
There is infinite recursion between the following steps:
RSpec::Support.thread_local_data
.RSpec::Support.thread_local_data
callsThread.current.thread_variable_get
.Thread.current.thread_variable_get
is mocked, RSpec code is called. See 1.Workaround
Add
allow(Thread.current).to receive(:thread_variable_get).with(:__rspec).and_call_original
.The intention of the original code was to mock only
Thread.current.thread_variable_get(:test)
but notThread.current.thread_variable_get
called with any other arguments. However, I could not find a way to do that.Proposed solution
If some mocked method is called from internal RSpec code, it should do nothing but delegate to the original method.
The text was updated successfully, but these errors were encountered: