RSpec Matchers Combinators 2 : spec_combos gem

less than 1 minute read

I already wrote about my RSpec Matchers Combinators, I decided to extract them into the spec_combos gem.

To use it, just add the following to your Gemfile :

gem 'spec_combos', :group => 'test'

Compared to the first version of the matchers, I added better error messages. For example, consider the following complex nested assertion :

expect([1,2,3]).to all_{and_(be_odd, be_instance_of(Fixnum))}

It outputs the following error :

Failure/Error: expect([1,2,3]).to all_{and_(be_odd, be_instance_of(Fixnum))}
  expected [1, 2, 3] to all be odd and be an instance of Fixnum, but the following were not:
    [1] (2): expected 2 to be odd and be an instance of Fixnum, but:
      expected odd? to return true, got false

I hope this might help !

I usually write about 15 minutes worth of reading per month. I won't transfer your email. No Spam, unsubscribe whenever you want.

As a gift for subscribing, you'll receive an illustrated mini-ebook "How to start a team coding dojo"!

Leave a comment