cucumber-rest-bdd 0.5.3 → 0.6.0.pre.183

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/STEPS.md DELETED
@@ -1,257 +0,0 @@
1
- # Gherkin Steps
2
-
3
- This test suite introduces behavioural test steps on top of functional REST API steps from [cucumber-api](https://github.com/hidroh/cucumber-api)
4
-
5
- The following is a list of steps, and their equivalent functional step
6
-
7
- ## Setup
8
-
9
- ```
10
- Behavioural Functional
11
- --------------------------------------------------- --------------------------------------------------------------
12
- Given I am a client Given I send and accept JSON
13
- ```
14
-
15
- ## Retrieval
16
-
17
- ```
18
- Behavioural Functional
19
- --------------------------------------------------- --------------------------------------------------------------
20
- When I request an item "2" When I send a GET request to "http://url/items/2"
21
-
22
- When I request a list of items When I send a GET request to "http://url/items"
23
-
24
- When I request a list of items with: When I send a GET request to "http://url/items" with:
25
- | User Id | 12 | | userId |
26
- | 12 |
27
- ```
28
-
29
- ## Creation
30
-
31
- ```
32
- Behavioural Functional
33
- --------------------------------------------------- --------------------------------------------------------------
34
- When I request to create an item When I send a POST request to "http://url/items"
35
-
36
- When I request to create an item with: When I set JSON request body to:
37
- | attribute | type | value | """
38
- | User Id | integer | 12 | {"userId":12,"title":"foo"}
39
- | Title | string | foo | """
40
- And I send a POST request to "http://url/items"
41
-
42
- When I request to create an item with id "4" When I send a PUT request to "http://url/items/4"
43
-
44
- When I request to replace the item "4" with: When I set JSON request body to:
45
- | attribute | type | value | """
46
- | User Id | integer | 7 | {"userId":7,"title":"foo"}
47
- | Title | string | foo | """
48
- And I send a PUT request to "http://url/items/4"
49
- ```
50
-
51
- ## Modification
52
-
53
- ```
54
- Behavioural Functional
55
- --------------------------------------------------- --------------------------------------------------------------
56
- When I request to modify the item "4" with: When I set JSON request body to:
57
- | attribute | type | value | """
58
- | Body | string | bar | {"body":"bar"}
59
- """
60
- And I send a PATCH request to "http://url/items/4"
61
- ```
62
-
63
- ## Status Inspection
64
-
65
- ```
66
- Behavioural Functional
67
- --------------------------------------------------- --------------------------------------------------------------
68
- Then the request is successful Then the response status should be "200"
69
-
70
- Then the request was redirected <N/A> (response status between "300" and "400")
71
-
72
- Then the request failed <N/A> (response status between "400" and "600")
73
-
74
- Then the request was successful and an item was Then the response status should be "201"
75
- created
76
-
77
- Then the request was successfully accepted Then the response status should be "202"
78
-
79
- Then the request was successful and no response Then the response status should be "204"
80
- body is returned
81
-
82
- Then the request failed because it was invalid Then the response status should be "400"
83
-
84
- Then the request failed because I am unauthorised Then the response status should be "401"
85
-
86
- Then the request failed because it was forbidden Then the response status should be "403"
87
-
88
- Then the request failed because the item was not Then the response status should be "404"
89
- found
90
-
91
- Then the request failed because it was not allowed Then the response status should be "405"
92
-
93
- Then the request failed because there was a Then the response status should be "409"
94
- conflict
95
-
96
- Then the request failed because the item has gone Then the response status should be "410"
97
-
98
- Then the request failed because it was not Then the response status should be "501"
99
- implemented
100
- ```
101
-
102
- ## Response Inspection
103
-
104
- ```
105
- Behavioural Functional
106
- --------------------------------------------------- --------------------------------------------------------------
107
- Then the response has the following attributes: Then the JSON response should have "userId" of type numeric
108
- | attribute | type | value | with value "12"
109
- | User Id | integer | 12 | Then the JSON response should have "title" of type numeric
110
- | Title | string | foo | with value "foo"
111
- | Body | string | bar | Then the JSON response should have "body" of type numeric with
112
- value "bar"
113
-
114
- Then the response is a list of 12 items Then the JSON response should have "$." of type array with 12
115
- entries
116
-
117
- Then the response is a list of at least 12 items Then the JSON response should have "$." of type array with at
118
- least 12 entries
119
- Then the response is a list of at most 12 items <N/A>
120
- Then the response is a list of fewer than 12 items <N/A>
121
- Then the response is a list of more than 12 items <N/A>
122
-
123
- Then two items have have the following attributes: <N/A>
124
- | attribute | type | value |
125
- | User Id | integer | 12 |
126
- | Title | string | foo |
127
- | Body | string | bar |
128
-
129
- Then more than two items have have the following <N/A>
130
- attributes:
131
- | attribute | type | value |
132
- | User Id | integer | 12 |
133
- | Title | string | foo |
134
- | Body | string | bar |
135
-
136
- <N/A> Then the JSON response should follow "schema.json"
137
-
138
- <N/A> Then the response has the header "Content Type" with value
139
- "application/json"
140
- ```
141
-
142
- ### Error Handling
143
-
144
- Using the environment variable: `error_key` to represent the error resource
145
-
146
- ```
147
- Behavioural Functional
148
- --------------------------------------------------- --------------------------------------------------------------
149
- Then the response has one error: Then the JSON response should have "errors[0].code" of type
150
- | attribute | type | value | string with value "ERR-BLA"
151
- | code | string | ERR-BLA |
152
-
153
- Then the response has one error with attributes: Then the JSON response should have "errors[0].code" of type
154
- | attribute | type | value | string with value "ERR-BLA"
155
- | code | string | ERR-BLA |
156
-
157
- Then the response has at least one error Then the JSON response should have "errors" of type array
158
- with at least 1 entry
159
-
160
- Then the response has an error Then the JSON response should have required key "error" of
161
- Then the response contains an error type object
162
-
163
- Then the response has two errors with:
164
- | attribute | type | value |
165
- | message | string | super error |
166
-
167
- Then the response has three errors with two links <N/A>
168
- with:
169
- | attribute | type | value |
170
- | href | string | http://oops |
171
- ```
172
-
173
- ### Attribute saving and re-use
174
-
175
- ```
176
- Behavioural Functional
177
- --------------------------------------------------- --------------------------------------------------------------
178
- When I save "User Id" as "user" When I grab "$.userId" as "user"
179
- And I request the user "{user}" And I send a GET request to "http://url/users/{user}"
180
- ```
181
-
182
- ### Nested requests
183
-
184
- ```
185
- Behavioural Functional
186
- --------------------------------------------------- --------------------------------------------------------------
187
- When I request a list of comments for post "1" When I send a GET request to "http://url/posts/1/comments"
188
-
189
- When I request the comment "2" for post "3" When I send a GET request to "http://url/posts/3/comments/2"
190
-
191
- When I request the photo "3" in album "4" for user When I send a GET request to
192
- "5" "http://url/users/5/albums/4/photos/3"
193
-
194
- When I request a list of photos in album "6" for When I send a GET request to
195
- user "7" "http://url/users/7/albums/6/photos"
196
-
197
- When I request to create a comment for post "8" When I send a POST request to "http://url/posts/8/comments"
198
-
199
- When I request to modify the comment "9" for post When I send a PATCH request to
200
- "10" "http://url/posts/10/comments/9"
201
-
202
- When I request to set photo "11" in album "12" to: When I set JSON request body to:
203
- | attribute | type | value | """
204
- | url | string | http://url/image.jpg | {"url":"http://url/image.jpg"}
205
- """
206
- And I send a PUT request to "http://url/albums/12/photos/11"
207
- ```
208
-
209
- ### Nested responses
210
-
211
- ```
212
- Behavioural Functional
213
- --------------------------------------------------- --------------------------------------------------------------
214
- Then the response has the following attributes: Then the JSON response should have "userId" of type numeric
215
- | attribute | type | value | with value "12"
216
- | User Id | integer | 12 | Then the JSON response should have "title" of type numeric
217
- | Title | string | foo | with value "foo"
218
- | Body | string | bar | Then the JSON response should have "body" of type numeric with
219
- | Post : Title | string | baz | value "bar"
220
- | Post : Body | string | boo | Then the JSON response should have "post.title" of type string
221
- with value "baz"
222
- Then the JSON response should have "post.body" of type string
223
- with value "boo"
224
-
225
- Then the response has a list of comments Then the JSON response should have "comments" of type array
226
-
227
- Then the response has a list of 2 comments Then the JSON response should have "comments" of type array with
228
- 2 entries
229
- Then the response has a list of at least Then the JSON response should have "comments" of type array with
230
- 2 comments at least 2 entries
231
-
232
- Then the response has a post with two comments <N/A>
233
- with attributes:
234
- | attribute | type | value |
235
- | Title | string | foo |
236
- | Body | string | bar |
237
-
238
- Then two items contains two posts with three <N/A>
239
- comments with an image with attributes:
240
- | attribute | type | value |
241
- | Href | string | some_url |
242
-
243
- Then more than two items contains fewer than two <N/A>
244
- posts with at least three comments with an
245
- image with attributes:
246
- | attribute | type | value |
247
- | Href | string | some_url |
248
-
249
- Then the response has a post with a list of Then the JSON response should have "post.comments" of type array
250
- comments
251
-
252
- Then the response has a post with a list of more Then the JSON response should have "post.comments" of type array
253
- than 3 comments with at least 4 comments
254
-
255
- Then more than three posts have less than two <N/A>
256
- comments
257
- ```
@@ -1,19 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'cucumber-rest-bdd'
3
- s.version = '0.5.3'
4
- s.version = "#{s.version}-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS'] && ENV['TRAVIS_TAG'] == ''
5
- s.platform = Gem::Platform::RUBY
6
- s.date = '2017-01-10'
7
- s.summary = 'BDD Rest API specifics for cucumber'
8
- s.description = 'Series of BDD cucumber rules for testing API endpoints'
9
- s.authors = ["Harry Bragg"]
10
- s.email = ["harry.bragg@graze.com"]
11
- s.files = `git ls-files`.split("\n")
12
- s.require_paths = ["lib"]
13
- s.homepage = 'http://github.com/graze/cucumber-rest-bdd'
14
- s.license = 'MIT'
15
-
16
- s.add_dependency('cucumber-api', '~> 0.4')
17
- s.add_dependency('activesupport', '~> 5.0')
18
- s.add_dependency('easy_diff', '~> 1.0')
19
- end
data/docker-compose.yml DELETED
@@ -1,23 +0,0 @@
1
- version: '2'
2
- services:
3
- test-server:
4
- image: clue/json-server
5
- command: --routes /data/routes.json --middlewares /data/error.js
6
- volumes:
7
- - ./server:/data:ro
8
-
9
- runner:
10
- image: graze/cucumber-rest-bdd
11
- build: .
12
- volumes:
13
- - .:/opt/src
14
- working_dir: /opt/src
15
- environment:
16
- - endpoint=http://test-server/
17
- - cucumber_api_verbose=false
18
- - field_separator=_
19
- - field_camel=true
20
- - resource_single=false
21
- - data_key=
22
- - error_key=error
23
- - set_parent_id=true
@@ -1,23 +0,0 @@
1
- @errors
2
- Feature: Handling error responses
3
-
4
- Background:
5
- Given I am a client
6
-
7
- Scenario: Handle errors as a list
8
- When I request the error "list"
9
- Then the request fails because the post was not found
10
- And the response contains at least one errors
11
- And the response has one error
12
- And the response has one error with the attributes:
13
- | attribute | type | value |
14
- | Message | string | Not Found |
15
-
16
- Scenario: Handle error as a single item
17
- When I request the error "single"
18
- Then the request fails because it was invalid
19
- And the response contains an error
20
- And the response has an error
21
- And the response has an error with the attributes:
22
- | attribute | type | value |
23
- | Message | string | Bad Request |
@@ -1,25 +0,0 @@
1
- Feature: Performing different rest methods
2
-
3
- Background:
4
- Given I am a client
5
-
6
- Scenario: Count the number of elements
7
- When I request a list of posts with:
8
- | User Id | 8 |
9
- Then the request is successful
10
- And the JSON response should have "$." of type array with at least 1 entry
11
- And the JSON response should have "$." of type array with at least 10 entries
12
- And the JSON response should have "$." of type array with 10 entries
13
- And the JSON response should have "$." of type array with at most 10 entries
14
- And the JSON response should have "$." of type array with at most 11 entries
15
-
16
- Scenario: Check for null type
17
- When I request to create a post with:
18
- | attribute | type | value |
19
- | title | string | foo |
20
- | body | text | bar |
21
- | null | null | |
22
- | nil | nil | |
23
- Then the JSON response should have "null" of type null
24
- Then the JSON response should have "nil" of type nil
25
- Then the JSON response should have "nil" of type nill
@@ -1,21 +0,0 @@
1
- Feature: Using the response from a previous request
2
-
3
- Background:
4
- Given I am a client
5
-
6
- Scenario: Get an id from creation and use in get
7
- When I request to create a post with:
8
- | attribute | type | value |
9
- | Title | string | foo |
10
- | Body | string | bar |
11
- | User Id | integer | 12 |
12
- Then the request is successful
13
- When I save "id"
14
- And I request the post "{id}"
15
- Then the request is successful
16
- And the response has the following attributes:
17
- | attribute | type | value |
18
- | Title | string | foo |
19
- | Body | string | bar |
20
- | User Id | numeric | 12 |
21
- | Id | numeric | {id} |
@@ -1,16 +0,0 @@
1
- Feature: We can inspect the headers of the response
2
-
3
- Scenario: Parse a single result
4
- When I request the post "1"
5
- Then the request was successful
6
- And the response has the header "Content Type" with value "application/json; charset=utf-8"
7
-
8
- Scenario Outline: Can check for multiple headers
9
- When I request the post "1"
10
- Then the request was successful
11
- And the response has the header "<header>" with the value "<value>"
12
-
13
- Examples:
14
- | header | value |
15
- | Content Type | application/json; charset=utf-8 |
16
- | Cache Control | no-cache |
@@ -1,121 +0,0 @@
1
- Feature: Request multiple levels of REST api
2
- As a user
3
- I would like to query a url with multiple levels of depth
4
- So that I can get all the data from this api
5
-
6
- Background:
7
- Given I am a client
8
-
9
- Scenario: get single id from sub layer
10
- When I request the comment "1" for post "1"
11
- Then the request was successful
12
- And the response has the attributes:
13
- | attribute | type | value |
14
- | id | int | 1 |
15
-
16
- Scenario: get list from sub layer
17
- When I request a list of comments for post "1"
18
- Then the request was successful
19
- And the response is a list of more than 4 comments
20
- And one comment has the attributes:
21
- | attribute | type | value |
22
- | id | int | 1 |
23
-
24
- Scenario: multiple sub levels
25
- When I request the photo "1" for album "1" for user "1"
26
- Then the request was successful
27
- And the response has the attributes:
28
- | attribute | type | value |
29
- | title | string | accusamus beatae ad facilis cum similique qui sunt |
30
-
31
- Scenario: request a list of multiple sub levels
32
- When I request a list of photos for album "1" for user "1"
33
- Then the request was successful
34
- And the response is a list of more than 2 photos
35
- And one photo has the attributes:
36
- | attribute | type | value |
37
- | title | string | accusamus beatae ad facilis cum similique qui sunt |
38
-
39
- Scenario: create a item as a child
40
- When I request to create a comment for post "18" with:
41
- | attribute | type | value |
42
- | Title | string | foo |
43
- | Body | string | bar |
44
- Then the comment was created
45
- And the response has the attributes:
46
- | attribute | type | value |
47
- | Post Id | string | 18 |
48
- | Title | string | foo |
49
- | Body | string | bar |
50
- When I request a list of comments for post "18"
51
- Then the request was successful
52
- And one comment has the attributes:
53
- | attribute | type | value |
54
- | Title | string | foo |
55
- | Body | string | bar |
56
-
57
- Scenario: create a 2nd level child item
58
- When I request to create a photo in album "2" for user "1" with:
59
- | attribute | type | value |
60
- | title | string | foo |
61
- Then the comment was created
62
- And the response has the attributes:
63
- | attribute | type | value |
64
- | Album Id | int | 2 |
65
- | Title | string | foo |
66
- When I request a list of photos for album "2" for user "1"
67
- Then the request was successful
68
- And one comment has the attributes:
69
- | attribute | type | value |
70
- | Title | string | foo |
71
-
72
- Scenario: delete a child item
73
- When I request to delete the comment "91" for post "19"
74
- Then the request was successful
75
- When I request a list of comments for post "19"
76
- Then the request was successful
77
- And zero comments have the attributes:
78
- | attribute | type | value |
79
- | id | int | 91 |
80
-
81
- Scenario: modify a child item
82
- When I request to modify the comment "102" for post "21" with:
83
- | attribute | type | value |
84
- | Name | string | foo |
85
- | Body | string | bar |
86
- Then the request was successful
87
- And the response has the attributes:
88
- | attribute | type | value |
89
- | Post Id | int | 21 |
90
- | Name | string | foo |
91
- | Body | string | bar |
92
- When I request a list of comments for post "21"
93
- Then the request was successful
94
- And one comment has the attributes:
95
- | attribute | type | value |
96
- | Name | string | foo |
97
- | Body | string | bar |
98
-
99
- Scenario: modify a child item
100
- When I request to replace the comment "106" for post "22" with:
101
- | attribute | type | value |
102
- | Title | string | foo |
103
- | Body | string | bar |
104
- Then the request was successful
105
- And the response has the attributes:
106
- | attribute | type | value |
107
- | Post Id | int | 22 |
108
- | Title | string | foo |
109
- | Body | string | bar |
110
- When I request a list of comments for post "22"
111
- Then the request was successful
112
- And one comment has the attributes:
113
- | attribute | type | value |
114
- | Title | string | foo |
115
- | Body | string | bar |
116
- When I request the comment "106"
117
- Then the request was successful
118
- And the response has the attributes:
119
- | attribute | type | value |
120
- | Title | string | foo |
121
- | Body | string | bar |