The Life of a Radar

Adding Your Own Differ to RSpec
17 Jul 2009

Recently I added diff_as_hash to rspec and I’d like to show you what I did, so you can add your own differs, and it’s only a couple of lines of code. You can edit your own local gem copy of rspec using the find_gem gem’s edit_gem command.

Let’s use the example that you want to add a BigDecimal differ.

lib/spec/expectations/fail_with.rb

First of all you’re going to need to add a line to this file, something that looks like the lines here, along with the other elsifs:

blog comments powered by Disqus