-
-
Notifications
You must be signed in to change notification settings - Fork 394
Prevent custom matcher is called twice without compound #1428
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 |
Migrated to the monorepo as rspec/rspec#148 |
Hey lovely folks 👋, I hope you all are doing well
This PR here is to address rspec/rspec#142 which is to prevent a custom matcher from calling twice without compound like
.and
or.or