RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Make writing Rspec custom matchers a breeze

To be fair, custom matchers in rspec are pretty easy as is: create a class that implements a few methods and then define a method to wrap that class.

Taking that one step further, with this simple script you can define your own custom matchers with a one liner:
matcher(:be_even) {|number| number % 2 == 0} matcher(:be_divisible_by) {|n, d| n % d == 0}

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in