[rspec-users] Someone please name this matcher for me

Zach Dennis zach.dennis at gmail.com
Wed Aug 6 14:15:05 EDT 2008

On Wed, Aug 6, 2008 at 1:50 PM, Pat Maddox <pergesu at gmail.com> wrote:
> I've had a matcher in my head for a couple months, that I frequently
> want but never get around to writing because I can't think of the name
> for it.  Here's how it would look
> [1, 2, 3, 4, 1].should ... [1, 3, 1, 4, 2]
> I have a couple ideas for names, but I'll hold off on them so I don't
> influence anyone's opinion.
> btw, I realize that .sort works in this case.  But that's slightly
> less clear than I'd like, and it doesn't work for non-Comparable
> objects (like activerecords).

  [1, 2, 3, 4, 1].should consist_of([1, 3, 1, 4, 2])

Since consist means "to be composed or made up of", which matches the usage.

To me it reads like, this thing should be made up of these other things.


Zach Dennis

More information about the rspec-users mailing list