Simple Matchers made Simple 3
Although RSpec supports custom matchers, it has always been a bit more work than is ideal for simpler situations. This could be attributed to the desire for a system which would be flexible.
But now, with a bit of convention-over-configuration kool-aide, we offer you the SimpleMatcher.
The SimpleMatcher snuck its way into RSpec’s source when we merged in the Story Runner (formerly RBehave). Dan North had wanted a simpler way to create custom matchers, and so he created one and used it throughout the specs for the Story Runner.
And now we bring it to you (today if you use trunk, otherwise next release).
Here’s how you use it:
def beat(hand)
return simple_matcher("hand that beats #{hand.to_s}") do |actual|
actual.beats?(hand)
end
end
full_house.should beat(flush)
=> nil #passes
straight.should beat(flush)
=> Expected hand that beats Flush, got Straight
Admittedly, these are only useful for very simple cases. But what’s in a name?

Doesn’t get much simpler than that. Cool!
This is a great addition; definitely helps me go down the same declarative direction I enjoyed so much with Test::Unit. Any idea on when the next release might be out?
Unfortunately, I can’t pin down the next release right now. I’m hopeful that it will be within a couple of weeks, but can’t commit to that.
We’re in the middle of restructuring things to better support test/unit integration. We were just about done and decided we didn’t like the resulting design, so it’s still in progress for a bit longer.
The good news is that the result will boast a nice, clean separation between rspec and its support for test/unit, but still provide the benefits of complete integration via an adapter layer.