mspec/lib/mspec/matchers/respond_to.rb
class RespondToMatcher
def initialize(expected)
@expected = expected
end
def matches?(actual)
@actual = actual
@actual.respond_to?(@expected)
end
def failure_message
["Expected #{@actual.inspect} (#{@actual.class})", "to respond to #{@expected}"]
end
def negative_failure_message
["Expected #{@actual.inspect} (#{@actual.class})", "not to respond to #{@expected}"]
end
end
class Object
def respond_to(expected)
RespondToMatcher.new(expected)
end
end