0

In reference to workflow of creating tests using RestFixture, I am asking myself, what kind of syntax the following statement represents:

jsonbody.name === 'Ted'

I need to know all possibilities of this kind of syntax to write down the expected value for much more complex JSON responses. Is there a name or reference for the type of syntax that is used here?

legoscia
  • 39,593
  • 22
  • 116
  • 167
eSKape
  • 71
  • 11

1 Answers1

1

The syntax is Javascript syntax. jsonbody is a variable containing the response.

See JavascriptExpectations in RestFixtureLiveDoc for more details. E.g.:

As of RestFixture Version 2, a javascript engine is embedded to allow expectations in Javascript on response body contents in JSON format.

!**** XPaths and JSON
For backward compatibility XPath expressions are maintained and executed
****!

After a successful response is received with content type "application/json" the expectation cell in a .RestFixture row is interpreted as a string with Javascript and executed within the context of the response body.

An example:

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/%id%.json | 200 |Content-Type : application/json |!-
jsonbody.resource.name=="test post" && jsonbody.resource.data=="some data"
-!|
legoscia
  • 39,593
  • 22
  • 116
  • 167