rubinius/rubinius

View on GitHub
mspec/lib/mspec/matchers/respond_to.rb

Summary

Maintainability
A
50 mins
Test Coverage
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