Skip to content

Commit 62edd74

Browse files
github-actions[bot]github-actions[bot]
authored andcommitted
updated
1 parent 3d23290 commit 62edd74

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

changelog.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ title: Codeception Changelog
99

1010

1111

12+
### module-rest 3.2.0: 3.2.0
13+
14+
Released by [![](https://avatars.githubusercontent.com/u/395992?v=4&s=16) Naktibalda](https://github.com/Naktibalda) on 2022/08/13 12:18:30 / [Repository](https://github.com/Codeception/module-rest) / [Releases](https://github.com/Codeception/module-rest/releases)
15+
16+
17+
18+
* Add (dont)seeResponseJsonXpathEvaluatesTo methods [#85](https://github.com/Codeception/module-rest/issues/85)
19+
* Fixed return type of grabHttpHeader method [#86](https://github.com/Codeception/module-rest/issues/86)
20+
21+
1222
### module-laravel 3.0.1: 3.0.1
1323

1424
Released by [![](https://avatars.githubusercontent.com/u/64917965?v=4&s=16) TavoNiievez](https://github.com/TavoNiievez) on 2022/08/07 15:25:34 / [Repository](https://github.com/Codeception/module-laravel) / [Releases](https://github.com/Codeception/module-laravel/releases)

docs/modules/REST.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ Opposite to seeResponseJsonMatchesXpath
265265
* `[Part]` json
266266

267267

268+
#### dontSeeResponseJsonXpathEvaluatesTo
269+
270+
Opposite to seeResponseJsonXpathEvaluatesTo
271+
272+
* `[Part]` json
273+
274+
268275
#### dontSeeResponseMatchesJsonType
269276

270277
Opposite to `seeResponseMatchesJsonType`.
@@ -702,6 +709,48 @@ $I->seeResponseJsonMatchesXpath('/store//price');
702709
* `[Part]` json
703710

704711

712+
#### seeResponseJsonXpathEvaluatesTo
713+
714+
Checks if applying xpath to json structure in response matches the expected result.
715+
JSON is not supposed to be checked against XPath, yet it can be converted to xml and used with XPath.
716+
This assertion allows you to check the structure of response json.
717+
*
718+
{% highlight json %}
719+
720+
{ "store": {
721+
"book": [
722+
{ "category": "reference",
723+
"author": "Nigel Rees",
724+
"title": "Sayings of the Century",
725+
"price": 8.95
726+
},
727+
{ "category": "fiction",
728+
"author": "Evelyn Waugh",
729+
"title": "Sword of Honour",
730+
"price": 12.99
731+
}
732+
],
733+
"bicycle": {
734+
"color": "red",
735+
"price": 19.95
736+
}
737+
}
738+
}
739+
740+
{% endhighlight %}
741+
742+
{% highlight php %}
743+
744+
<?php
745+
// at least one book in store has author
746+
$I->seeResponseJsonXpathEvaluatesTo('count(//store/book/author) > 0', true);
747+
// count the number of books written by given author is 5
748+
$I->seeResponseJsonMatchesXpath("//author[text() = 'Nigel Rees']", 1.0);
749+
750+
{% endhighlight %}
751+
* `[Part]` json
752+
753+
705754
#### seeResponseMatchesJsonType
706755

707756
Checks that JSON matches provided types.

0 commit comments

Comments
 (0)