forked from hidroh/cucumber-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.feature
48 lines (43 loc) · 1.92 KB
/
sample.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
# https://github.com/HackerNews/API
Feature: Hacker News REST API validation
Scenario: Verify top stories JSON schema
Given I send and accept JSON
And I add Headers:
| Cache-Control | no-cache |
When I send a GET request to "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
Then the response status should be "200"
And the JSON response should follow "features/schemas/topstories.json"
Scenario Outline: Verify item JSON schema
When I send and accept JSON
And I send a GET request to "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
Then the response status should be "200"
And the JSON response root should be array
When I grab "$[0]" as "id"
And I send a GET request to "https://hacker-news.firebaseio.com/v0/item/{id}.json" with:
| print |
| pretty |
Then the response status should be "200"
And the JSON response root should be object
And the JSON response should have <optionality> key "<key>" of type <value type>
And the JSON response should have "id" of type numeric and value "{id}"
Examples:
| key | value type | optionality |
| id | numeric | required |
| score | numeric | required |
| url | string | optional |
Scenario: Demonstrate setting the JSON body with a docstring
Given I send and accept JSON
And I set JSON request body to:
"""
{
"title": "foo",
"body": "bar",
"userId": 1
}
"""
When I send a POST request to "http://jsonplaceholder.typicode.com/posts"
Then the response status should be "201"
And the JSON response should have "id" of type numeric and value "101"
And the JSON response should have "title" of type string and value "foo"
And the JSON response should have "body" of type string and value "bar"
And the JSON response should have "userId" of type numeric and value "1"