-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
demo-mock.feature
50 lines (40 loc) · 1.44 KB
/
demo-mock.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Feature: stateful mock server
Background:
* def curId = 0
* def nextId = function(){ return ~~curId++ }
* def cats = {}
Scenario: pathMatches('/greeting') && paramExists('name')
* def content = 'Hello ' + paramValue('name') + '!'
* def response = { id: '#(nextId())', content: '#(content)' }
Scenario: pathMatches('/greeting')
* def response = { id: '#(nextId())', content: 'Hello World!' }
Scenario: pathMatches('/cats') && methodIs('post') && typeContains('xml')
* def cat = request
* def id = nextId()
* set cat /cat/id = id
* set catJson
| path | value |
| id | id |
| name | cat.cat.name |
* cats[id + ''] = catJson
* def response = cat
Scenario: pathMatches('/cats') && methodIs('post')
* def cat = request
* def id = nextId()
* set cat.id = id
* cats[id + ''] = cat
* def response = cat
Scenario: pathMatches('/cats')
* def response = $cats.*
Scenario: pathMatches('/cats/{id}') && methodIs('put')
* def cat = request
* def id = pathParams.id
* cats[id + ''] = cat
* def response = cat
Scenario: pathMatches('/cats/{id}') && acceptContains('xml')
* def cat = cats[pathParams.id]
* def response = <cat><id>#(cat.id)</id><name>#(cat.name)</name></cat>
Scenario: pathMatches('/cats/{id}')
* def response = cats[pathParams.id]
Scenario: pathMatches('/cats/{id}/kittens')
* def response = cats[pathParams.id].kittens