Permalink
Browse files

Array =~ matcher works with subclasses of Array (Matthew Peychich & P…

…at Maddox)
  • Loading branch information...
1 parent bcc4765 commit b63cb94ee056cebdf200a7e7e74d93e66cd872ea Pat Maddox committed Feb 25, 2010
Showing with 14 additions and 1 deletion.
  1. +3 −0 History.rdoc
  2. +6 −1 lib/spec/matchers/operator_matcher.rb
  3. +5 −0 spec/spec/matchers/match_array_spec.rb
View
@@ -1,5 +1,8 @@
=== Version 1.3.1 / (Date TBD)
+* Enhancements
+ * Array =~ matcher works with subclasses of Array (Matthew Peychich & Pat Maddox)
+
* bug fix
* QuitBacktraceTweaker no longer eats all paths with 'lib'
(Tim Harper - #912)
@@ -13,7 +13,12 @@ def register(klass, operator, matcher)
end
def get(klass, operator)
- registry[klass] && registry[klass][operator]
+ matcher = registry[klass] && registry[klass][operator]
+ unless matcher
+ parent_class = registry.keys.detect {|pc| klass <= pc }
+ matcher = registry[parent_class] && registry[parent_class][operator]
+ end
+ matcher
end
end
@@ -97,6 +97,11 @@ def ==(other)
MESSAGE
end
+ it "should work with subclasses of Array" do
+ class SuperArray < Array; end
+ SuperArray.new([1,2,3]).should =~ SuperArray.new([3,2,1])
+ end
+
end
describe "should_not =~ [:with, :multiple, :args]" do

0 comments on commit b63cb94

Please sign in to comment.