From 450bb48953ad3ef01d3f47b08086c7b916da9132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Hurtado?= Date: Wed, 21 Aug 2019 11:03:29 +0200 Subject: [PATCH] Replaced gherkin tables by json documents in requests and responses of insert features --- .../insert/error_unprocessable.feature | 40 ++++- .../control/insert/list_order.feature | 165 +++++++++++++++--- .../features/control/insert/success.feature | 46 ++++- 3 files changed, 211 insertions(+), 40 deletions(-) diff --git a/spec/test/features/control/insert/error_unprocessable.feature b/spec/test/features/control/insert/error_unprocessable.feature index 2600f15..2f8ad59 100644 --- a/spec/test/features/control/insert/error_unprocessable.feature +++ b/spec/test/features/control/insert/error_unprocessable.feature @@ -9,13 +9,23 @@ Feature: Kapow! server reject insert responses with semantic errors. Given I have a running Kapow! server When I insert the route: - | entrypoint | command | - | /bin/sh -c | ls -la / \| response /body | + """ + { + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body" + } + """ Then I get 422 as response code And I get "Missing Mandatory Field" as response reason phrase And I get the following entity as response body: - | missing_mandatory_fields | - | "url_pattern", "method" | + """ + { + "missing_mandatory_fields": [ + "url_pattern", + "method" + ] + } + """ Scenario: Error because of wrong route specification. If a request contains an invalid expression in the @@ -23,8 +33,15 @@ Feature: Kapow! server reject insert responses with semantic errors. Given I have a running Kapow! server When I insert the route: - | method | url_pattern | entrypoint | command | index | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | + """ + { + "method": "GET", + "url_pattern": "+123--", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": 0 + } + """ Then I get 422 as response code And I get "Invalid Route Spec" as response reason phrase And I get an empty response body @@ -35,8 +52,15 @@ Feature: Kapow! server reject insert responses with semantic errors. Given I have a running Kapow! server When I insert the route: - | method | url_pattern | entrypoint | command | index | - | AVECES | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | + """ + { + "method": "SOMETIMES", + "url_pattern": "/", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": 0 + } + """ Then I get 422 as response code And I get "Invalid Data Type" as response reason phrase And I get an empty response body diff --git a/spec/test/features/control/insert/list_order.feature b/spec/test/features/control/insert/list_order.feature index 2c3db06..122e78e 100644 --- a/spec/test/features/control/insert/list_order.feature +++ b/spec/test/features/control/insert/list_order.feature @@ -15,42 +15,120 @@ Feature: Routes auto-ordering after inserting in a Kapow! server. will be increased by one. When I insert the route: - | method | url_pattern | entrypoint | command | index | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 0 | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 0 + } + """ Then I get 200 as response code And I get "OK" as response phrase And I get the following entity as response body: - | method | url_pattern | entrypoint | command | index | id | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 0 | * | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 0, + "id": "*" + } + """ When I request a routes listing Then I get 200 as response code And I get "OK" as response phrase And I get a list with the following elements: - | method | url_pattern | entrypoint | command | Index | id | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 0 | * | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | * | - | GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 2 | * | + """ + [ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 0, + "id": "*" + }, + { + "method": "GET", + "url_pattern": "/listRootDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": 1, + "id": "*" + }, + { + "method": "GET", + "url_pattern": "/listDir/:dirname", + "entrypoint": "/bin/sh -c", + "command": "ls -la /request/params/dirname | response /body", + "index": 2, + "id": "*" + } + ] + """ Scenario: Inserting after the last routes. After inserting after the last route the previous set will maintain their relative order and indexes. When I insert the route: - | method | url_pattern | entrypoint | command | index | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 2 | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 2 + } + """ Then I get 200 as response code And I get "OK" as response phrase And I get the following entity as response body: - | method | url_pattern | entrypoint | command | index | id | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 2 | * | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 2, + "id": "*" + } + """ When I request a routes listing Then I get 200 as response code And I get "OK" as response phrase And I get a list with the following elements: - | method | url_pattern | entrypoint | command | Index | id | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * | - | GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 1 | * | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 2 | * | + """ + [ + { + "method": "GET", + "url_pattern": "/listRootDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": 0, + "id": "*" + }, + { + "method": "GET", + "url_pattern": "/listDir/:dirname", + "entrypoint": "/bin/sh -c", + "command": "ls -la /request/params/dirname | response /body", + "index": 1, + "id": "*" + }, + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 2, + "id": "*" + } + ] + """ Scenario: Inserting a midst route. After inserting a midst route the previous route set @@ -58,18 +136,57 @@ Feature: Routes auto-ordering after inserting in a Kapow! server. of thefollowing routes will be increased by one. When I insert the route: - | method | url_pattern | entrypoint | command | index | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 1 | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 1 + } + """ Then I get 200 as response code And I get "OK" as response phrase And I get the following entity as response body: - | method | url_pattern | entrypoint | command | index | id | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 1 | * | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 1, + "id": "*" + } + """ When I request a routes listing Then I get 200 as response code And I get "OK" as response phrase And I get a list with the following elements: - | method | url_pattern | entrypoint | command | Index | id | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * | - | GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 1 | * | - | GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 2 | * | + """ + [ + { + "method": "GET", + "url_pattern": "/listRootDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": 0, + "id": "*" + }, + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 1, + "id": "*" + }, + { + "method": "GET", + "url_pattern": "/listDir/:dirname", + "entrypoint": "/bin/sh -c", + "command": "ls -la /request/params/dirname | response /body", + "index": 2, + "id": "*" + } + ] + """ diff --git a/spec/test/features/control/insert/success.feature b/spec/test/features/control/insert/success.feature index 35775ab..1c1fdb6 100644 --- a/spec/test/features/control/insert/success.feature +++ b/spec/test/features/control/insert/success.feature @@ -14,13 +14,28 @@ Feature: Insert new routes in Kapow! server. by specifying an index 0 in the request. When I insert the route: - | method | url_pattern | entrypoint | command | index | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 0 + } + """ Then I get 200 as response code And I get "OK" as response reason phrase And I get the following entity as response body: - | method | url_pattern | entrypoint | command | index | id | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 0, + "id": "*" + } + """ Scenario: Insert a route in the middle. A route can be inserted in the middle of the list @@ -28,10 +43,25 @@ Feature: Insert new routes in Kapow! server. index in the request. When I insert the route: - | method | url_pattern | entrypoint | command | index | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 1 + } + """ Then I get 200 as response code And I get "OK" as response reason phrase And I get the following entity as response body: - | method | url_pattern | entrypoint | command | index | id | - | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | * | + """ + { + "method": "GET", + "url_pattern": "/listVarDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la /var | response /body", + "index": 1, + "id": "*" + } + """