Specification¶
The behavior of Brine is itself specified using Cucumber specs; these are intended to provide examples for all of the provided steps, including representations of all offered behavior and handling of edge and corner cases. Additionally the specifications are intended to facilitate porting of Brine to new runtimes as the same specifications should be able to be used across those runtimes.
Request Construction¶
Feature: Basic Request Construction
A simple request with a specified method and path can be sent.
Scenario Outline: Basic URL
When a <method> is sent to `/anything`
Then the value of the response body child `method` is equal to `<method>`
Examples:
| method |
| GET |
| POST |
| PATCH |
| DELETE |
| PUT |
Feature: Assigning a Request Body
Scenario: Attach a basic body.
When the request body is assigned:
"""
{"request": 1}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to:
"""
{"request": 1}
"""
Scenario: Attach a template body.
Given `val` is assigned `foo`
When the request body is assigned:
"""
{"request":"{{val}}"}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to:
"""
{"request": "foo"}
"""
Feature: Adding Query Parameters
Scenario: A single parameter is appended to the URL.
When the request query parameter `foo` is assigned `bar`
And a GET is sent to `/get`
Then the value of the response body child `args` is equal to:
"""
{"foo": "bar"}
"""
Scenario: Multiple parameters are appended to the URL with proper formatting.
When the request query parameter `foo` is assigned `bar`
And the request query parameter `baz` is assigned `1`
And a GET is sent to `/get`
Then the value of the response body child `args` is equal to:
"""
{"foo": "bar",
"baz": "1"}
"""
Scenario Outline: Values are encoded appropriately.
When the request query parameter `foo` is assigned `<input>`
And a GET is sent to `/get`
Then the value of the response body child `args` is equal to:
"""
{"foo": "<input>"}
"""
Examples:
| input |
| bar & grill |
| + + |
| (imbalance)) |
Scenario Outline: Parametes are added regardless of HTTP method.
When the request query parameter `foo` is assigned `bar`
And a <method> is sent to `/anything`
Then the value of the response body child `args` is equal to:
"""
{"foo": "bar"}
"""
Examples:
| method |
| POST |
| PUT |
| DELETE |
Feature: Adding Headers
Scenario: A new header with a single value is added to request.
When the request header `foo` is assigned `bar`
And a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Foo": "bar"}
"""
Scenario: Default headers are present in requests.
When a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Content-Type": "application/json"}
"""
Scenario: Default headers can be overridden.
When the request header `Content-Type` is assigned `text/plain`
And a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Content-Type": "text/plain"}
"""
Scenario: Array header values are added to requests.
When the request header `X-Array` is assigned `[1, 2, 3]`
And a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"X-Array": "1, 2, 3"}
"""
Scenario: The last set value for a given header wins.
When the request header `foo` is assigned `bar`
And the request header `foo` is assigned `baz`
And a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Foo": "baz"}
"""
Scenario Outline: Header is added regardless of HTTP method.
When the request header `Foo` is assigned `bar`
And a <method> is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Foo": "bar"}
"""
Examples:
| method |
| POST |
| PUT |
| DELETE |
Feature: Cleared After Sent
After a request is sent, any values that were added to that request
are cleared and will not be present in subsequent requests.
Scenario: Request body is cleared.
When the request body is assigned:
"""
{"request":1}
"""
And a PUT is sent to `/anything`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is empty
Scenario: Request parameter
When the request query parameter `foot` is assigned `bar`
And a GET is sent to `/anything`
And a GET is sent to `/anything`
Then the value of the response body child `args` is empty
Feature: Adding Basic Auth
Scenario: A new header with expected value is added to request.
When the request credentials are set for basic auth user `user` and password `pass`
And a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Authorization":"Basic dXNlcjpwYXNz"}
"""
Client Configuration¶
Feature: Adding Extra Headers
Scenario: A header is added to the request on basic construction.
When the client sets the header `Foo` to `Bar`
And a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Foo": "Bar"}
"""
Scenario Outline: A header is added to subsequent requests.
Given the client sets the header `Foo` to `Bar`
And a GET is sent to `/anything`
When a <method> is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Foo": "Bar"}
"""
Examples:
| method |
| GET |
| POST |
| PUT |
| DELETE |
Scenario: Each header assignment is idempotent.
Given the client sets the header `Foo` to `Bar`
And the client sets the header `Foo` to `Bar`
And a GET is sent to `/anything`
Given the client sets the header `Foo` to `Bar`
When a GET is sent to `/anything`
Then the value of the response body children `headers.Foo` is equal to:
"""
["Bar"]
"""
Scenario: Multiple header assignments can be combined.
Given the client sets the header `Foo` to `Bar`
And the client sets the header `Blah` to `Baz`
And a GET is sent to `/anything`
When a GET is sent to `/anything`
Then the value of the response body child `headers` is including:
"""
{"Foo": "Bar",
"Blah": "Baz"}
"""
Resource Cleanup¶
@pending @171
Feature: Resource Cleanup
Resources created during testing can be marked for deletion.
Scenario: Successful Basic Deletion
Given expected DELETE sent to `/some/path`
When a resource is created at `/some/path`
Scenario: Returned 4xx
Given expected response status of `409`
And expected DELETE sent to `/some/path`
When a resource is created at `/some/path`
Scenario: Success Upon Retry
Given expected response status sequence of `[504, 200]`
And expected DELETE sent to `/some/path`
When a resource is created at `/some/path`
Scenario: Unreached Success
Given expected response status sequence of `[504, 504, 504, 200]`
And expected DELETE sent to `/some/path`
When a resource is created at `/some/path`
Assignment¶
Feature: A Parameter
An identifier can be assigned the value of the provided parameter.
Scenario: Simple assignment.
Given `foo` is assigned `bar`
When the request body is assigned `{{ foo }}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to `bar`
@pending @170
Feature: A Random String
An identifier can be assigned a random string with decent entropy.
Scenario: Several unique variables.
Given `v1` is assigned a random string
And `v2` is assigned a random string
And `v3` is assigned a random string
When the response body is assigned `[ "{{ v1 }}","{{ v2 }}","{{ v3 }}" ]`
Then the value of the response body does not have any element that is empty
And the value of the response body child `.[0]` is equal to `{{ v1 }}`
And the value of the response body children `.[1:2]` does not have any element that is equal to `{{ v1 }}`
And the value of the response body child `.[2]` is not equal to `{{ v2 }}`
Feature: A Timestamp
An identifier can be assigned a current timestamp.
Scenario: Newer than some old date.
Given `v1` is assigned a timestamp
When the request body is assigned `{{ v1 }}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is greater than `2018-06-17T12:00:00Z`
Scenario: Values increase.
Given `v1` is assigned a timestamp
When `v2` is assigned a timestamp
And the request body is assigned `{{ v2 }}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is greater than or equal to `{{ v1 }}`
When `v3` is assigned a timestamp
And the request body is assigned `{{ v3 }}`
Then the value of the response body child `data` is greater than or equal to `{{ v1 }}`
And the value of the response body child `data` is greater than or equal to `{{ v2 }}`
Feature: Response Attribute
An identifier can be assigned a value extracted from a response attribute.
Scenario: Response body.
Given the request body is assigned `foo`
And a PUT is sent to `/anything`
When `myVar` is assigned the response body child `data`
And the request body is assigned `{{ myVar }}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to `foo`
Scenario: Response body child.
Given the request body is assigned `{"response": "foo"}`
And a PUT is sent to `/anything`
When `myVar` is assigned the response body child `json.response`
And the request body is assigned `{{ myVar }}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to `foo`
Scenario: Response body children.
Given the request body is assigned `{"response": "foo"}`
And a PUT is sent to `/anything`
When `myVar` is assigned the response body children `json.response`
And the request body is assigned `{{{ myVar }}}`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `["foo"]`
Scenario: Response header.
Given the request query parameter `test` is assigned `val`
And a GET is sent to `/response-headers`
When `myVar` is assigned the response headers child `test`
And the request body is assigned `{{ myVar }}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to `val`
Feature: Assign conventional environment variables.
Scenario: Conventional environment variable is present in binding.
When the request body is assigned `{{from_env}}`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to `Read from environment`
Selection¶
Feature: Response Attribute
A response attribute can be selected for assertion.
Scenario: Response body.
When a GET is sent to `/base64/SFRUUEJJTiBpcyBhd2Vzb21l`
Then the value of the response body is equal to `HTTPBIN is awesome`
Scenario: Response status.
When a GET is sent to `/status/409`
Then the value of the response status is equal to `409`
Scenario: Response headers.
When the request query parameter `foo` is assigned `bar`
And a GET is sent to `/response-headers`
Then the value of the response headers is including:
"""
{"foo":"bar"}
"""
Scenario: Response header child.
When the request query parameter `foo` is assigned `bar`
And a GET is sent to `/response-headers`
Then the value of the response headers is including:
"""
{"foo":"bar"}
"""
Then the value of the response headers child `foo` is equal to `bar`
Feature: Any Element
Assertions can be done against any element of a structure.
Scenario: Nested list in response body
When the request body is assigned:
"""
["a", "b", "c"]
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` does have any element that is equal to `a`
And the value of the response body child `json` does not have any element that is equal to `d`
Scenario: Map matches entries
When the request body is assigned:
"""
{"a": 1, "b": 2}
"""
#Equality will match keys
And a PUT is sent to `/anything`
Then the value of the response body child `json` does have any element that is equal to `a`
And the value of the response body child `json` does not have any element that is equal to `d`
Scenario: Spread nested lists
When the request body is assigned:
"""
[{"val":"foo"},{"val":"bar"}]
"""
And a PUT is sent to `/anything`
Then the value of the response body children `json..val` does have any element that is equal to `foo`
And the value of the response body children `json..val` does not have any element that is equal to `other`
Feature: All Elements
Assertions can be done against all elements of a structure.
Scenario: List in response body
When the request body is assigned:
"""
["a", "bb", "ccc"]
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` has elements which are all matching `/\w+/`
Scenario: Spread nested lists
When the request body is assigned:
"""
[{"val": "foo"},{"val": "foo"}]
"""
And a PUT is sent to `/anything`
Then the value of the response body children `json..val` has elements which are all equal to `foo`
Assertion¶
Feature: Equal To
It can be asserted that a value is equal to another value.
Scenario: String in response body
When the request body is assigned:
"""
foo
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to `foo`
And the value of the response body child `data` is not equal to `foot`
Scenario: Response Status
When a GET is sent to `/status/404`
Then the value of the response status is equal to `404`
And the value of the response status is not equal to `200`
Scenario: Object in response body
When the request body is assigned:
"""
{"foo": "bar"}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to:
"""
{"foo":"bar"}
"""
And the value of the response body child `json` is not equal to:
"""
{"foo": "baz"}
"""
Scenario: List in response body
When the request body is assigned `[1, "foo", true]`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `[1, "foo", true]`
And the value of the response body child `json` is not equal to `[1, "bar", true]`
Scenario Outline: Objects must match completely
When the request body is assigned `{"foo": "bar", "baz": 1}`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not equal to `<comparison>`
Examples:
| comparison |
| {} |
| {"foo": "bar"} |
| {"foo": "bar", "baz": 1, "extra": 2} |
| {"foo": "bar", "baz": 2} |
Feature: Matching
It can be asserted that a value matches another string or regex.
Scenario: String in response body is matched against a regex.
When the request body is assigned:
"""
http://www.github.com?var=val
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is matching `/github/`
And the value of the response body child `data` is matching `/git.*\?.*=/`
And the value of the response body child `data` is not matching `/gh/`
And the value of the response body child `data` is not matching `/^github/`
@pending @assertion_against_assignment
Scenario: Regex in response body matched against a string
When the request body is assigned:
"""
/(.+)\1/
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is matching `blahblah`
And the value of the response body child `data` is matching `boo`
And the value of the response body child `data` is not matching `blah blah`
And the value of the response body child `data` is not matching `blah`
Feature: Including
It can be asserted that a value is a superset of another value. It can be asserted that a value is a superset of another value. It can be asserted that a value is a superset of another value. It can be asserted that a value is a superset of another value.
Scenario: Basic object membership
When the request body is assigned:
"""
{"foo":"bar",
"baz": 1,
"other": "blah"}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is including:
"""
{"baz": 1}
"""
And the value of the response body child `json` is not including:
"""
{"missing":"value"}
"""
And the value of the response body child `json` is including `other`
And the value of the response body child `json` is not including `brother`
And the value of the response body child `json` is not including `value`
Feature: Empty
It can be asserted that a value is empty.
Scenario: Empty body is empty.
When the request body is assigned ``
And a PUT is sent to `/anything`
Then the value of the response body child `data` is empty
Scenario: Whitespace-only body is empty.
When the request body is assigned:
"""
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is empty
Scenario: Empty string is empty.
When the request body is assigned `""`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is empty
Scenario: Non-empty string is not empty.
When the request body is assigned `blah`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is not empty
Scenario: Quoted whitespace is not empty.
When the request body is assigned `" "`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is not empty
Scenario: Empty arrays are empty.
When the request body is assigned `[]`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is empty
Scenario: Non-empty arrays are not empty.
When the request body is assigned `[[]]`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not empty
Scenario: Empty objects are empty.
When the request body is assigned `{}`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is empty
Scenario: Non-empty objects are not empty.
When the request body is assigned `{"foo":{}}`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not empty
Scenario: Null values are empty.
When the request body is assigned `{"foo": null}`
And a PUT is sent to `/anything`
Then the value of the response body child `json.foo` is empty
Scenario: False is not empty.
When the request body is assigned `{"foo": false}`
And a PUT is sent to `/anything`
Then the value of the response body child `json.foo` is not empty
Scenario: 0 is not empty.
When the request body is assigned `0`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not empty
Feature: Of Length
It can be asserted that a value has a provided length.
Scenario: String
When the request body is assigned:
"""
blah
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is of length `4`
Scenario: Array
When the request body is assigned:
"""
["foo", "blah"]
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is of length `2`
Scenario: Map
When the request body is assigned:
"""
{"foo": "blah"}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is of length `1`
Scenario: Value without length attribute
When the request body is assigned:
"""
true
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not of length `1`
And the value of the response body child `json` is not of length `4`
And the value of the response body child `json` is not of length `0`
Feature: A Valid
It can be asserted that a value is a valid instance of a type.
Scenario: String in response body is only a valid String.
When the request body is assigned:
"""
foo
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is a valid `String`
And the value of the response body child `data` is not a valid `Number`
And the value of the response body child `data` is not a valid `Integer`
And the value of the response body child `data` is not a valid `Object`
And the value of the response body child `data` is not a valid `Array`
And the value of the response body child `data` is not a valid `Boolean`
Scenario: Integer in response body is a valid Integer and Number.
When the request body is assigned:
"""
1
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not a valid `String`
And the value of the response body child `json` is a valid `Number`
And the value of the response body child `json` is a valid `Integer`
And the value of the response body child `json` is not a valid `Object`
And the value of the response body child `json` is not a valid `Array`
And the value of the response body child `json` is not a valid `Boolean`
Scenario: Quoted Number in response body is only a valid String.
When the request body is assigned:
"""
"1"
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is a valid `String`
And the value of the response body child `data` is not a valid `Number`
And the value of the response body child `data` is not a valid `Integer`
And the value of the response body child `data` is not a valid `Object`
And the value of the response body child `data` is not a valid `Array`
And the value of the response body child `data` is not a valid `Boolean`
Scenario: Empty Object in response body is only a valid Object.
When the request body is assigned:
"""
{}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not a valid `String`
And the value of the response body child `json` is not a valid `Number`
And the value of the response body child `json` is not a valid `Integer`
And the value of the response body child `json` is a valid `Object`
And the value of the response body child `json` is not a valid `Array`
And the value of the response body child `json` is not a valid `Boolean`
Scenario: Object in response body is only a valid Object.
When the request body is assigned:
"""
{"foo": 1}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not a valid `String`
And the value of the response body child `json` is not a valid `Number`
And the value of the response body child `json` is not a valid `Integer`
And the value of the response body child `json` is a valid `Object`
And the value of the response body child `json` is not a valid `Array`
And the value of the response body child `json` is not a valid `Boolean`
Scenario: Quoted Object in response body is only a valid String.
When the request body is assigned:
"""
"{"foo": 1}"
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is a valid `String`
And the value of the response body child `data` is not a valid `Number`
And the value of the response body child `data` is not a valid `Integer`
And the value of the response body child `data` is not a valid `Object`
And the value of the response body child `data` is not a valid `Array`
And the value of the response body child `data` is not a valid `Boolean`
Scenario: Empty Array in response body is only a valid Array.
When the request body is assigned:
"""
[]
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not a valid `String`
And the value of the response body child `json` is not a valid `Number`
And the value of the response body child `json` is not a valid `Integer`
And the value of the response body child `json` is not a valid `Object`
And the value of the response body child `json` is a valid `Array`
And the value of the response body child `json` is not a valid `Boolean`
Scenario: Array in response body is only a valid Array.
When the request body is assigned:
"""
[1, "foo"]
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not a valid `String`
And the value of the response body child `json` is not a valid `Number`
And the value of the response body child `json` is not a valid `Integer`
And the value of the response body child `json` is not a valid `Object`
And the value of the response body child `json` is a valid `Array`
And the value of the response body child `json` is not a valid `Boolean`
Scenario: true in response body is only a valid Boolean.
When the request body is assigned:
"""
true
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is not a valid `String`
And the value of the response body child `json` is not a valid `Number`
And the value of the response body child `json` is not a valid `Integer`
And the value of the response body child `json` is not a valid `Object`
And the value of the response body child `json` is not a valid `Array`
And the value of the response body child `json` is a valid `Boolean`
Scenario: false in response body is only a valid Boolean.
When the request body is assigned:
"""
{"foo": false}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json.foo` is not a valid `String`
And the value of the response body child `json.foo` is not a valid `Number`
And the value of the response body child `json.foo` is not a valid `Integer`
And the value of the response body child `json.foo` is not a valid `Object`
And the value of the response body child `json.foo` is not a valid `Array`
And the value of the response body child `json.foo` is a valid `Boolean`
Scenario: null in response body is not any valid type.
When the request body is assigned:
"""
[null]
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json[0]` is not a valid `String`
And the value of the response body child `json[0]` is not a valid `Number`
And the value of the response body child `json[0]` is not a valid `Integer`
And the value of the response body child `json[0]` is not a valid `Object`
And the value of the response body child `json[0]` is not a valid `Array`
And the value of the response body child `json[0]` is not a valid `Boolean`
Scenario: Selected Array child is a valid Array.
When the request body is assigned:
"""
{"val": [1, 2, 3]}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json.val` is a valid `Array`
Scenario: Selected Array child member is a valid String.
When the request body is assigned:
"""
{"val": [1, 2, 3]}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json.val[0]` is a valid `Number`
Then the value of the response body child `json.val[0]` is a valid `Integer`
Scenario: Selected nested children are a valid Array.
When the request body is assigned:
"""
[{"val": 1},{"val": 2}]
"""
And a PUT is sent to `/anything`
Then the value of the response body children `json.val` is a valid `Array`
Scenario: Selected nested children can be tested for type.
When the request body is assigned:
"""
[{"val": 1},{"val": 2}]
"""
And a PUT is sent to `/anything`
Then the value of the response body children `json.val` has elements which are all a valid `Number`
And the value of the response body children `json.val` has elements which are all a valid `Integer`
Scenario: Selected nested children can be tested for type when Arrays.
When the request body is assigned:
"""
[{"val": [1]},{"val": [2]}]
"""
And a PUT is sent to `/anything`
Then the value of the response body children `json.val` has elements which are all a valid `Array`
Actions¶
@pending
Feature: Eventually
Conditions which are eventually but may not be immediately satisfied can be tested.
Scenario: A delayed response passes an eventual test.
Given actions are defined such that
When a GET is sent to `/bytes/5`
Then the value of the response body is matching `/fdlb/`
Then the actions are successful within a `short` period
Scenario: A late response fails an eventual test.
When the response is delayed 5 seconds
And the response body is assigned:
"""
{"completed": true}
"""
Given actions are defined such that
Then the value of the response body is equal to:
"""
{"completed": true}
"""
Then the actions are not successful within a `short` period
Scenario: A late response passes a patient eventual test.
When the response is delayed 5 seconds
And the response body is assigned:
"""
{"completed": true}
"""
Given actions are defined such that
Then the value of the response body is equal to:
"""
{"completed": true}
"""
Then the actions are successful within a `long` period
Scenario: Action state is managed properly
When actions are defined such that
When `expected` is assigned `val`
And the response body is assigned:
"""
{"key": "val",
"other": "blah"}
"""
Then the value of the response body child `key` is equal to `{{expected}}`
When `expected` is assigned `blah`
Then the value of the response body children `other` is equal to `{{expected}}`
When the response body is assigned:
"""
{"key": "blah"}
"""
Then the value of the response body child `key` is equal to `{{expected}}`
Then the actions are successful within a `short` period
Argument Transformation¶
Feature: Boolean
An argument that could represent a boolean value will be transformed into a boolean type.
Scenario Outline: Docstring simple value.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Boolean`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| true |
# This produces an empty PUT, should be handled by selection of assigned values
# | false |
Scenario Outline: Inline simple value.
When the request body is assigned `<input>`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Boolean`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| true |
# This produces an empty PUT, should be handled by selection of assigned values
# | false |
@pending
Feature: DateTime
An argument that could represent a date/time value will be transformed into a time type.
Scenario: Docstring datetime is serialized properly.
When the request body is assigned:
"""
2017-01-01T09:00:00Z
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `DateTime`
And the value of the response body child `json` is equal to `2017-01-01T09:00:00Z`
And the value of the response body child `json` is greater than `2017-01-01T08:00:00Z`
And the value of the response body child `json` is less than `2017-01-01T10:00:00Z`
Scenario: Inline datetime is serialized properly.
When the request body is assigned `2017-01-01T09:00:00Z`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `DateTime`
And the value of the response body child `json` is equal to `2017-01-01T09:00:00Z`
And the value of the response body child `json` is greater than `2017-01-01T08:00:00Z`
And the value of the response body child `json` is less than `2017-01-01T10:00:00Z`
Scenario: Value Comparison
When `now` is assigned a timestamp
And `then` is assigned `2017-01-01T12:00:00Z`
Then the value of `{{ then }}` is less than `{{ now }}`
@pending @170
Scenario: Child Comparison
When `now` is assigned a timestamp
And the response body is assigned:
"""
{"my_timestamp": "{{ now }}"}
"""
Then the value of the response body child `my_timestamp` is greater than `2017-01-01T12:00:00Z`
Feature: Integer
An argument that could represent an integer will be transformed into an integer type.
Scenario Outline: Docstring simple value.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Integer`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| 0 |
| -0 |
| 10 |
| -10 |
| 123456789123456789 |
| -123456789123456789 |
Scenario Outline: Inline simple value.
When the request body is assigned `<input>`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Integer`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| 0 |
| -0 |
| 10 |
| -10 |
| 123456789123456789 |
| -123456789123456789 |
Feature: List
An argument that could represent a JSON list will be
transformed into a list whose elements will be also be transformed.
Scenario Outline: Docstring simple list.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Array`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| [] |
| ["a", "b"] |
| ["a" , "b" ] |
| [" a", " b "] |
| [true, "false"] |
| [1,-3,"-5"] |
| ["foo,bar","baz"] |
| ["foo,bar,baz"] |
| ["foo\\"","bar"] |
| ["fo\\"o\\",bar","baz"] |
| [{"i":1},{"i":2}, "h"] |
Scenario Outline: Inline simple list.
When the request body is assigned `<input>`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Array`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| [] |
| ["a", "b"] |
| ["a" , "b" ] |
| [" a", " b "] |
| [true, "false"] |
| [1,-3,"-5"] |
| ["foo,bar","baz"] |
| ["foo,bar,baz"] |
| ["foo\\"","bar"] |
| ["fo\\"o\\",bar","baz"] |
| [{"i":1},{"i":2}, "h"] |
Feature: Object
An argument that could represent a JSON object will be
transformed into an object whose elements will also be transformed.
Scenario Outline: Docstring simple object.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Object`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| {} |
| {"a":1} |
| {"foo":"bar", "num":1, "list": ["1", 2, true]} |
| {"foo": {"bar":{ "num":1, "list": ["1", 2, true]}}} |
| {"foo": "\"list\": [\"1\", 2, true]"} |
Scenario Outline: Inline simple object.
When the request body is assigned `<input>`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `Object`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| {} |
| {"a":1} |
| {"foo":"bar", "num":1, "list": ["1", 2, true]} |
| {"foo": {"bar":{ "num":1, "list": ["1", 2, true]}}} |
| {"foo": "\"list\": [\"1\", 2, true]"} |
Scenario: Object split over lines
When the request body is assigned:
"""
{
"foo":"bar"
}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to:
"""
{"foo":"bar"}
"""
@pending
Feature: Quoted
An argument that is quoted will be (not) transformed into
into a string, regardless of any more specific data type the
quoted value may resemble.
Scenario Outline: Docstring simple value.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is a valid `String`
And the value of the response body child `json` is equal to `<input>`
Examples:
| input |
| "true" |
| ""123"" |
| " -123 " |
| "["foo","bar"]" |
| "{"foo":"bar"}" |
Scenario Outline: Inline simple value.
When the response body is assigned `<input>`
Then the value of the response body is a valid `String`
And the value of the response body is equal to `<input>`
Examples:
| input |
| "true" |
| "123" |
| " -123 " |
| "["foo","bar"]" |
| "{"foo":"bar"}" |
@169
Feature: Regular Expression
An argument that is enclosed in slashes (/) will be transformed into a regex.
Scenario Outline: Docstring simple value.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to:
"""
<expected>
"""
#Expecting Ruby stringification and using painful escaping
Examples:
| input | expected |
| // | ""(?-mix:)"" |
| /\// | ""(?-mix:\\\\\\/)"" |
| /.*/ | ""(?-mix:.*)"" |
| /"[[:alpha:]]?"/ | ""(?-mix:\\"[[:alpha:]]?\\")"" |
| /foo bar/ | ""(?-mix:foo bar)"" |
Scenario Outline: Inline simple value.
When the request body is assigned `<input>`
And a PUT is sent to `/anything`
Then the value of the response body child `data` is equal to:
"""
<expected>
"""
#Expecting Ruby stringification and using painful escaping
Examples:
| input | expected |
| // | ""(?-mix:)"" |
| /\// | ""(?-mix:\\\\\\/)"" |
| /.*/ | ""(?-mix:.*)"" |
| /"[[:alpha:]]?"/ | ""(?-mix:\\"[[:alpha:]]?\\")"" |
| /foo bar/ | ""(?-mix:foo bar)"" |
Feature: Template
An argument that includes _{{ }}_ interpolation markers will be
treated as a template and transformed into an evaluated version of
that template using the current binding environment which will then
also be transformed.
Scenario Outline: Docstring single value template.
When `bound` is assigned `<binding>`
And the request body is assigned:
"""
{{{ bound }}}
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `<expected>`
Examples:
| binding | expected |
| true | true |
| -452 | -452 |
| ["a", 1] | ["a", 1] |
Scenario Outline: Inline single value template.
When `bound` is assigned `<binding>`
And the request body is assigned `{{{ bound }}}`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `<expected>`
Examples:
| binding | expected |
| true | true |
| -452 | -452 |
| ["a", 1] | ["a", 1] |
Feature: Whitespace
An argument that includes leading or trailing whitespace
will be transformed so that such whitespace is removed
and that value will also be transformed.
Scenario Outline: Docstring simple value.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `<expected>`
Examples:
| input | expected |
| true | true |
| 123 | 123 |
| ["a"] | ["a"] |
Scenario Outline: Inline simple value.
When the request body is assigned `<input>`
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `<expected>`
Examples:
| input | expected |
| true | true |
| 123 | 123 |
| ["a"] | ["a"] |
Scenario Outline: Docstring value with a leading and trailing line.
When the request body is assigned:
"""
<input>
"""
And a PUT is sent to `/anything`
Then the value of the response body child `json` is equal to `<expected>`
Examples:
| input | expected |
| true | true |
| 123 | 123 |
| ["a"] | ["a"] |