Hello,

I'm toying around with a matcher to compare the interface of two classes.
I intend to use this where ever I am providing an explicit fake or stub of a class.

class MatchInterface
  def initialize(klass)
    @klass = klass
  end

  def matches?(other)
    @other = other
    @lhs = @klass.public_instance_methods
    @rhs = @other.public_instance_methods

    lhs == rhs
  end

  def failure_message
    diff = (@lhs - @rhs) + (@rhs - @lhs)
    "The following methods are different:\n#{diff.join("\n")}"
  end
end

I'd like to include
* Class methods
* Arity verification (would love to use RSpec::Support::MethodSignature for this ... might consider making it public) * Partial interface (i.e. it doesn't implement all methods, but the ones it does are correct and valid)

Has anyone built anything like this already?

Xav

--
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/532B0388.1050302%40xaviershay.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to