Class: FlexMock::DuckMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/flexmock/argument_matchers.rb

Overview

Match objects that implement all the methods in methods.

Instance Method Summary collapse

Constructor Details

#initialize(methods) ⇒ DuckMatcher

Returns a new instance of DuckMatcher.



73
74
75
# File 'lib/flexmock/argument_matchers.rb', line 73

def initialize(methods)
  @methods = methods
end

Instance Method Details

#===(target) ⇒ Object



76
77
78
# File 'lib/flexmock/argument_matchers.rb', line 76

def ===(target)
  @methods.all? { |m| target.respond_to?(m) }
end

#inspectObject



79
80
81
# File 'lib/flexmock/argument_matchers.rb', line 79

def inspect
  "ducktype(#{@methods.map{|m| m.inspect}.join(',')})"
end