[rspec-devel] matcher dsl

David Chelimsky dchelimsky at gmail.com
Sun Mar 29 13:16:13 EDT 2009

Hey all,

rspec-1.2.0 introduced a new matcher DSL, which lets you define a
matcher like this:

      Spec::Matchers.create :be_a_multiple_of do |expected|
        match do |actual|
          actual % expected == 0

This defines a matcher that you can use in an example like this:

  25.should be_a_multiple_of(5)

It occurs to me that "Spec::Matchers.create" is not the most intuitive
entry point. We're not defining Matchers (plural), nor are we really
creating anything at the point of declaration.

So I'm thinking of changing it (still supporting the original for now)
to "Spec.matcher" or "Spec.define_matcher", or something similar.
Anybody have any suggestions? My only restriction for the moment is
that it should not be top level (i.e. define_matcher with no scoping).


More information about the rspec-devel mailing list