-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
Prevent custom matcher is called twice without compound #1428
base: main
Are you sure you want to change the base?
Prevent custom matcher is called twice without compound #1428
Conversation
3c736f1
to
8689f8e
Compare
Thanks for starting to tackle this, the issue as I see it is somehow this method is being responded to by the matcher, this is what needs to be fixed
|
9f60afd
to
269e7e1
Compare
Hello @JonRowe thank you, sure I can raise P/S: #1428 (comment) |
The fix should be to find where the method is being responded to and prevent it, I suspect its probably including a module it shouldn't do. |
Hey there JonRowe, sorry I have updated my comment above. |
I'll paste it here just to be sure I believe I understand what you said and I agree with you too. I tried to do that but I am not sure about removing or adjusting this piece of code, I played around with our code before (the method was coming from def respond_to_missing?(method, include_private=false)
super || @matcher_execution_context.respond_to?(method, include_private)
end
def method_missing(method, *args, &block)
if @matcher_execution_context.respond_to?(method)
@matcher_execution_context.__send__ method, *args, &block
else
super(method, *args, &block)
end
end Otherwise, even calling P/S: If we were somehow to adjust that |
What concerns me the most, why are matchers available as methods on an i stance of a matcher in the first place? |
Hello there @pirj 👋 I am not really sure I am not sure (maybe it could be recursive?) if I should do like what Jon said because it can result in breaking changes This is what I found: I checked and the matcher available because of this https://github.com/rspec/rspec-expectations/blob/main/lib/rspec/matchers/dsl.rb#L75 here we call and later in And then in class def respond_to_missing?(method, include_private=false)
super || @matcher_execution_context.respond_to?(method, include_private)
end
def method_missing(method, *args, &block)
if @matcher_execution_context.respond_to?(method)
@matcher_execution_context.__send__ method, *args, &block
else
super(method, *args, &block)
end
end Even though |
Hey lovely folks 👋, I hope you all are doing well
This PR here is to address #1426 which is to prevent a custom matcher from calling twice without compound like
.and
or.or