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
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
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
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