actor: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor.
Hello.
After updating to version 3.8.0, a large number of project services in RSpec began to crash with this comment:
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor.
In one of the examples, the service was mocked using allow and the expected result was indicated:
allow(MyService).to(
receive(:result)
.and_return(
ServiceActor::Result.new(failure?: true, error: "Some error")
)
)
But at the same time, when actually checking the result of the service, the following data appears:
service_result.failure?
# => false
service_result.success?
# => true
Please tell me what I’m doing wrong and what happened?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 29 (27 by maintainers)
Commits related to this issue
- Add `#nil?` method to actor results See #146 — committed to sunny/actor by sunny 3 years ago
- Add `#nil?` method to actor results (#157) See #146 — committed to sunny/actor by sunny 3 years ago
- Accept inputs called :error See #146 — committed to sunny/actor by sunny 3 years ago
- Accept inputs called :error (#158) See #146 — committed to sunny/actor by sunny 3 years ago
- Add the `#methods` method on results to avoid introspection warnings 🎀 See #146 — committed to sunny/actor by sunny 3 years ago
@sunny Apparently the problems that were described above have indeed been resolved. Thank you. Can you please make a release so I can finalize this in projects?
Hi @sunny
I tested and it worked.
Thank you 🙏
Thank you for the detailed report @andrik! Indeed the
#methodsmethod is used by introspection tools as well. I’ve merged #159 which should fix this. Can you try again frommain, please? 🙏🏻@sunny Thanks for adding compatibility. Apparently, release 3.9 has fixed the main problems described earlier.
However, there are still the following problems:
And what is most important is:
Which reacts to this:
Unfortunately, I can’t at the moment.
But this does not solve the problem in total.
For now, I have fixed the
3.7release line until better times. Unfortunately, at the moment I do not have time to understand hundreds of problems in tests.We’re using RSpec mocking actively but didn’t encounter any warnings. But I’m pretty sure there are many gems/tools which don’t paly nice with
BasicObject, for example,awesome_print’s missingKernel#aibreaks result introspectionAt the moment I can only talk about those above.
I’ll open a PR soon if you don’t mind @sunny
@afuno Are there any other problematic methods generating warnings in your codebase?
In general, I think it might make sense to add these methods in
ServiceActor::Result. BTW @afuno what’s the use-case for calling public_send/object_id/instance_variables on service result?