Re: [rspec-users] JSON matcher

2011-05-19 Thread Bill Burcham
JSON matcher updated (works with Rspec 1.3.1). Put this in spec/support/matchers/json_matcher.rb: Spec::Matchers.define :be_json_eql do | expected | match do | actual | @expected = decode(expected, 'expected') @actual = decode(actual, 'actual') @actual == @expected end failure_m

Re: [rspec-users] JSON matcher

2009-04-07 Thread Michael Schuerig
On Tuesday 07 April 2009, Phlip wrote: > Michael Schuerig wrote: > > def failure_message > > "expected\...@raw_target}\n" + > > "to be JSON code equivalent to\...@raw_expected}\n" + > > "Difference:\...@expected.diff(@target).inspect}" > > end > > Nice - this fix

Re: [rspec-users] JSON matcher

2009-04-06 Thread Phlip
Michael Schuerig wrote: def failure_message "expected\...@raw_target}\n" + "to be JSON code equivalent to\...@raw_expected}\n" + "Difference:\...@expected.diff(@target).inspect}" end Nice - this fixes the common problem with assertions on large bulky variabl

[rspec-users] JSON matcher

2009-04-06 Thread Michael Schuerig
Curiously, there doesn't seem to be a matcher around that matches a JSON string against an expected ruby object. Below is what I've come up with, including some Rails idiosyncrasies. Any suggestions for improvements? Michael module Spec module JSONMatchers class BeJsonEql def init