Skip to content

Commit ede97a5

Browse files
committed
Update assert response docs.
1 parent 9e92b60 commit ede97a5

File tree

2 files changed

+90
-24
lines changed

2 files changed

+90
-24
lines changed

sites/hurl.dev/_data/docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@
217217
path: /docs/asserting-response.html
218218
items:
219219
- title: Asserts
220+
items:
221+
- title: Structure
220222
- title: Implicit asserts
221223
items:
222224
- title: Version - Status
@@ -248,7 +250,6 @@
248250
- title: Variable assert
249251
- title: Duration assert
250252
- title: SSL certificate assert
251-
252253
- title: Filters
253254
path: /docs/filters.html
254255
items:

sites/hurl.dev/_docs/asserting-response.md

Lines changed: 88 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,67 @@ affected by this content compression. All body asserts (`body`, `bytes`, `sha256
3232
Finally, body text asserts (`body`, `jsonpath`, `xpath` etc...) are also decoded to strings based on [`Content-Type` header]
3333
so these asserts can be written with usual strings.
3434

35+
### Structure
36+
37+
The asserts order in a Hurl file is:
38+
39+
- [implicit asserts on version and status](#version-status)
40+
- [implicit asserts on headers](#headers)
41+
- [explicit asserts](#explicit-asserts)
42+
- [implicit assert on body](#body)
43+
44+
<div class="hurl-structure-schema">
45+
<div class="hurl-structure">
46+
<div class="hurl-structure-col-0">
47+
<div class="hurl-part-0">
48+
HTTP 200
49+
</div>
50+
<div class=" hurl-part-1">
51+
content-length: 206<br>accept-ranges: bytes<br>user-agent: Test
52+
</div>
53+
<div class="hurl-part-2">
54+
[Captures]<br>...
55+
</div>
56+
<div class="hurl-part-2">
57+
[Asserts]<br>...
58+
</div>
59+
<div class="hurl-part-3">
60+
{<br>
61+
&nbsp;&nbsp;"type": "FOO",<br>
62+
&nbsp;&nbsp;"value": 356789,<br>
63+
&nbsp;&nbsp;"ordered": true,<br>
64+
&nbsp;&nbsp;"index": 10<br>
65+
}
66+
</div>
67+
</div>
68+
<div class="hurl-structure-col-1">
69+
<div class="hurl-request-explanation-part-0">
70+
<a href="/docs/asserting-response.html#version-status">Version and status (mandatory if response present)</a>
71+
</div>
72+
<div class="hurl-request-explanation-part-1">
73+
<br><a href="/docs/asserting-response.html#headers">HTTP response headers</a> (optional)
74+
</div>
75+
<div class="hurl-request-explanation-part-2">
76+
<br>
77+
<br>
78+
</div>
79+
<div class="hurl-request-explanation-part-2">
80+
<a href="/docs/capturing-response.html">Captures</a> and <a href="/docs/asserting-response.html#explicit-asserts">explicit asserts</a> (optional sections, unordered)
81+
</div>
82+
<div class="hurl-request-explanation-part-2">
83+
<br>
84+
<br>
85+
<br>
86+
<br>
87+
</div>
88+
<div class="hurl-request-explanation-part-3">
89+
<a href="/docs/asserting-response.html#body">HTTP response body</a> (optional)
90+
</div>
91+
</div>
92+
</div>
93+
</div>
94+
95+
3596
## Implicit asserts
3697

3798
### Version - Status
@@ -334,29 +395,33 @@ sizes.
334395

335396
Predicates consist of a predicate function and a predicate value. Predicate functions are:
336397

337-
| Predicate | Description | Example |
338-
|--------------------|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
339-
| __`==`__ | Query and predicate value are equal | `jsonpath "$.book" == "Dune"` |
340-
| __`!=`__ | Query and predicate value are different | `jsonpath "$.color" != "red"` |
341-
| __`>`__ | Query number is greater than predicate value | `jsonpath "$.year" > 1978` |
342-
| __`>=`__ | Query number is greater than or equal to the predicate value | `jsonpath "$.year" >= 1978` |
343-
| __`<`__ | Query number is less than that predicate value | `jsonpath "$.year" < 1978` |
344-
| __`<=`__ | Query number is less than or equal to the predicate value | `jsonpath "$.year" <= 1978` |
345-
| __`startsWith`__ | Query starts with the predicate value<br>Value is string or a binary content | `jsonpath "$.movie" startsWith "The"`<br><br>`bytes startsWith hex,efbbbf;` |
346-
| __`endsWith`__ | Query ends with the predicate value<br>Value is string or a binary content | `jsonpath "$.movie" endsWith "Back"`<br><br>`bytes endsWith hex,ab23456;` |
347-
| __`contains`__ | Query contains the predicate value<br>Value is string or a binary content | `jsonpath "$.movie" contains "Empire"`<br><br>`bytes contains hex,beef;` |
348-
| __`matches`__ | Part of the query string matches the regex pattern described by the predicate value | `jsonpath "$.release" matches "\\d{4}"`<br><br>`jsonpath "$.release" matches /\d{4}/` |
349-
| __`exists`__ | Query returns a value | `jsonpath "$.book" exists` |
350-
| __`isBoolean`__ | Query returns a boolean | `jsonpath "$.succeeded" isBoolean` |
351-
| __`isCollection`__ | Query returns a collection | `jsonpath "$.books" isCollection` |
352-
| __`isEmpty`__ | Query returns an empty collection | `jsonpath "$.movies" isEmpty` |
353-
| __`isFloat`__ | Query returns a float | `jsonpath "$.height" isFloat` |
354-
| __`isInteger`__ | Query returns an integer | `jsonpath "$.count" isInteger` |
355-
| __`isIsoDate`__ | Query string returns a [RFC 3339] date (`YYYY-MM-DDTHH:mm:ss.sssZ`) | `jsonpath "$.publication_date" isIsoDate` |
356-
| __`isNumber`__ | Query returns an integer or a float | `jsonpath "$.count" isNumber` |
357-
| __`isString`__ | Query returns a string | `jsonpath "$.name" isString` |
358-
| __`isIpv4`__ | Query returns an IPv4 address | `ip isIpv4` |
359-
| __`isIpv6`__ | Query returns an IPv6 address | `ip isIpv6` |
398+
| Predicate | Description | Example |
399+
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
400+
| __`==`__ | Query and predicate value are equal | `jsonpath "$.book" == "Dune"` |
401+
| __`!=`__ | Query and predicate value are different | `jsonpath "$.color" != "red"` |
402+
| __`>`__ | Query number is greater than predicate value | `jsonpath "$.year" > 1978` |
403+
| __`>=`__ | Query number is greater than or equal to the predicate value | `jsonpath "$.year" >= 1978` |
404+
| __`<`__ | Query number is less than that predicate value | `jsonpath "$.year" < 1978` |
405+
| __`<=`__ | Query number is less than or equal to the predicate value | `jsonpath "$.year" <= 1978` |
406+
| __`startsWith`__ | Query starts with the predicate value<br>Value is string or a binary content | `jsonpath "$.movie" startsWith "The"`<br><br>`bytes startsWith hex,efbbbf;` |
407+
| __`endsWith`__ | Query ends with the predicate value<br>Value is string or a binary content | `jsonpath "$.movie" endsWith "Back"`<br><br>`bytes endsWith hex,ab23456;` |
408+
| __`contains`__ | If query returns a collection of string or numbers, query collection includes the predicate value (string or number)<br>If query returns a string or a binary content, query contains the predicate value (string or bytes) | `jsonpath "$.movie" contains "Empire"`<br><br>`bytes contains hex,beef;`<br><br>`jsonpath "$.numbers" contains 42` |
409+
| __`matches`__ | Part of the query string matches the regex pattern described by the predicate value | `jsonpath "$.release" matches "\\d{4}"`<br><br>`jsonpath "$.release" matches /\d{4}/` |
410+
| __`exists`__ | Query returns a value | `jsonpath "$.book" exists` |
411+
| __`isBoolean`__ | Query returns a boolean | `jsonpath "$.succeeded" isBoolean` |
412+
| __`isCollection`__ | Query returns a collection | `jsonpath "$.books" isCollection` |
413+
| __`isEmpty`__ | Query returns an empty collection | `jsonpath "$.movies" isEmpty` |
414+
| __`isFloat`__ | Query returns a float | `jsonpath "$.height" isFloat` |
415+
| __`isInteger`__ | Query returns an integer | `jsonpath "$.count" isInteger` |
416+
| __`isIsoDate`__ | Query string returns a [RFC 3339] date (`YYYY-MM-DDTHH:mm:ss.sssZ`) | `jsonpath "$.publication_date" isIsoDate` |
417+
| __`isNumber`__ | Query returns an integer or a float | `jsonpath "$.count" isNumber` |
418+
| __`isString`__ | Query returns a string | `jsonpath "$.name" isString` |
419+
| __`isIpv4`__ | Query returns an IPv4 address | `ip isIpv4` |
420+
| __`isIpv6`__ | Query returns an IPv6 address | `ip isIpv6` |
421+
422+
Query contains the predicate value if query returns a collection of string or numbers<br>
423+
Query
424+
360425

361426

362427
Each predicate can be negated by prefixing it with `not` (for instance, `not contains` or `not exists`)

0 commit comments

Comments
 (0)