Closed palkan closed 1 year ago
Why does MessageExpectation
need to b e a subclass of Object
, not BasicObject
?
Even then, why would it not redefine existing methods? I'll git blame to see if I can find the reason for this.
Ah, I think the intent is to not redefine methods directly defined in Receive
, since we're copying all the matchers. method_defined?(name, false)
would fix it I think.
I think I have a fix for it, but GitHub seems to be having issues, I get an error message when trying to create the PR....
Pull request creation failed. Validation failed: You can't perform that action at this time.
https://github.com/rspec/rspec-mocks/compare/rspec:main...casperisfine:receiver-with?expand=1
@byroot I’ve opened one, does it work for you?
Sure, thank you.
Your environment
Steps to reproduce
In a Rails application (i.e., with Rails loaded), define a method expectation:
Expected behavior
Pass.
Actual behavior
What happened?
Rails monkey-patched
Object#with
https://github.com/rails/rails/pull/46681 /cc @byrootRSpec
receive
matcher defines chain methods only for undefined methods: https://github.com/rspec/rspec-mocks/blob/4a1032bf93fe8b47c9e3416413e2b05d604d109f/lib/rspec/mocks/matchers/receive.rb#L58-L59Since
#with
is defined onObject
, thewith
modifier is no longer available.