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
Fix unstubbing of not defined methods #811
base: master
Are you sure you want to change the base?
Fix unstubbing of not defined methods #811
Conversation
d458a18
to
e02edf4
Compare
e02edf4
to
ea8edfe
Compare
Rebased to the latest master from upstream. |
Technically your case is a subset of the #891 i.e. the method should be kept on the singleton_class only if it was defined on the singleton_class already. Otherwise it should be removed after stubbing is done. You can examine your added test cases against my branch. |
Great! my tests are passing with your fix. 👏 I will close this PR once your PR is merged. |
Cool, but we still should do something with the tests you wrote for dynamic module definitions. May be re-PR with tests only. |
👍 I will rebase this branch after your merge and use my tests to protect the code against regressions. |
I think this solution is good. Question though: why, in the test, are you manually setting |
Probably just left-overs from previous code, tomorrow I'll rebase/re-run the code. |
ea8edfe
to
e3e3a3a
Compare
Rebased and removed the fix (only added the tests), still failing. Ruby 2.7
Ruby 3.2
|
I reviewed the code: @assertion_count is asserted in teardown to ensure all the expected assertions were run. |
It seems the force-push got rid of your changes to the stub implementation and only kept the tests. Also can you change the test name to be more explanatory, something like: |
Yes, I've rebased to latest version from upstream (my branch was really old). I wanted to be sure the error is still there. If #891 is fixing the problems I want to know if my test cases are covered. |
After stubbing a method not really defined, but the module (probably will behave the same for classes) accepts a message (respond to...) and it's managed by meta-prorgramming used "method_missing" then the unstubbing is not working because the stubbed method is still there.
This fix the behaviour, ensuring after the stubbing block the stubbed method is removed and calls to "respond_to..." are called as usual.