-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
any_instance_of
does not restore method on JRuby
#1338
Comments
Nice find, thanks for reporting. Would it make sense to add JRuby check to |
@marcotc ping |
For context, I spent around 2 tries trying to fix this issue, but I wasn't able to figure out how the internals of
It would this specific issue, but I don't have enough confidence to say if that's the right solution.
I tried my best to reduce the test to its minimal form, and I wasn't able to simplify it any further than the reported version above. In our use-case it boiled down to:
Trying to simplify/remove any of these steps did not allow me to reproduce the issue anymore.
I don't have the confidence to know if the issue lies in this repo or JRuby. I noticed there's an issue linked from |
- if RUBY_VERSION < "2.3" || backed_up_method_owner[method_name.to_sym] == self
+ if RUBY_VERSION < "2.3" || RSpec::Support::Ruby.jruby? || backed_up_method_owner[method_name.to_sym] == self made your spec green on I propose the following:
|
Ah JRuby, I haven't missed your quirks, is this something thats happening only on the current head? Why haven't our builds caught it @pirj? |
The example
But there is:
without any one of those the issue doesn't reproduce. |
Care to add an example to our build that fails as a draft as a first step? |
Subject of the issue
A special combination of
any_instance_of
calls can preventrspec-mocks
from properly restoring the originally mocked method method during it cleanup step. I'm only able to observe this on JRuby.Your environment
Steps to reproduce
Expected behavior
No failures:
Actual behavior
Preliminary investigation
My semi-educated guess is that the issue lies in this code block: https://github.com/rspec/rspec-mocks/blob/v3.9.1/lib/rspec/mocks/any_instance/recorder.rb#L202-L222
Forcing
alias_method method_name, alias_method_name
to when running on JRuby in that code block "solves" the problem from my example. I unfortunately wasn't able process how the comment included in that snippet linked is applying to our case, so I'm not 100% confident that this is the correct solution.The text was updated successfully, but these errors were encountered: