Included page: .RestFixtureTests.SetUp (edit)
| script | smartrics.rest.test.fitnesse.fixture.HttpServerFixture | |
| check | is started | true |
| reset resources database | ||
Issue #176 Deep compare JSON object
The question is how to compare JSON objects in the response. .RestFixture doesn't provide, off the shelf, any method.
But a deep compare of JSON objects can be easily achieved in ~JavaScript
(see this ~StackOverflow question).
So, using the ability to include at runtime a ~JavaScript file (from .RestFixture 4.1 onwards), we can
include the deepCompare function
and use it to perform the equality check on json objects
| Table: Rest Fixture Config | with-deepCompare.js |
| restfixture.javascript.imports.map | deepCompare=src/main/resources/FitNesseRoot/files/javascript/deepCompare.js |
| Table: Rest Fixture | http://localhost:9876 | with-deepCompare.js | ||
| GET | 200 |
Content-Type : application/json expected Set-Cookie : JID="ABC.${a.y}"; Content-Type : application/json;charset=ISO-8859-1 Content-Length : 77 Server : Jetty(6.0.2) actual |
/* javascript */ var expectedJson = { 'resource' : { 'name' : 'a funky name', 'data' : 'an important message' } }; deepCompare(jsonbody, expectedJson); expected { "resource" : { "name" : "a funky name", "data" : "an important message" } } actual |
|