OperatorMatcher considers ancestor chain #192

Merged
merged 1 commit into from Dec 5, 2012

2 participants

@alindeman
@phiggins phiggins commented on the diff Dec 5, 2012
lib/rspec/matchers/operator_matcher.rb
def get(klass, operator)
- registry[klass] && registry[klass][operator]
+ klass.ancestors.each { |ancestor|
+ matcher = registry[ancestor] && registry[ancestor][operator]
+ return matcher if matcher
+ }
@phiggins
phiggins added a note Dec 5, 2012

Would klass.ancestors.detect {|ancestor| registry[ancestor] && registry[ancestor][operator] } work?

I wish! Unfortunately detect returns the element that matched, and not the result of the block.

@phiggins
phiggins added a note Dec 5, 2012

Ahh, good point. I read too quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@myronmarston myronmarston merged commit abefb76 into rspec:master Dec 5, 2012

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment