[rspec-users] JSON matcher

Michael Schuerig michael at schuerig.de
Tue Apr 7 03:37:58 EDT 2009


On Tuesday 07 April 2009, Phlip wrote:
> Michael Schuerig wrote:
> >       def failure_message
> >         "expected\n#{@raw_target}\n" +
> >         "to be JSON code equivalent to\n#{@raw_expected}\n" +
> >         "Difference:\n#{@expected.diff(@target).inspect}"
> >       end
>
> Nice - this fixes the common problem with assertions on large bulky
> variables - they often leave you squinting, trying to see the line
> that's different.
>
> But where did .diff() come from? should I know it's part of
> ActiveSupport::JSON or something?

Hash#diff is part of ActiveSupport and when you look at its code you'll 
probably have to squint.

Michael

-- 
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/


More information about the rspec-users mailing list