lib/flexmock/argument_matchers.rb in flexmock-0.8.3 vs lib/flexmock/argument_matchers.rb in flexmock-0.8.4

- old
+ new

@@ -51,7 +51,36 @@ def inspect "on{...}" end end + #################################################################### + # Match only things where the block evaluates to true. + class HashMatcher + def initialize(hash) + @hash = hash + end + def ===(target) + @hash.all? { |k, v| target[k] == v } + end + def inspect + "hsh(#{@hash.inspect})" + "hsh(...)" + end + end + + #################################################################### + # Match only things where the block evaluates to true. + class DuckMatcher + def initialize(methods) + @methods = methods + end + def ===(target) + @methods.all? { |m| target.respond_to?(m) } + end + def inspect + "ducktype(#{@methods.map{|m| m.inspect}.join(',')})" + end + end + end