{"id":17145012,"url":"https://github.com/graze/cucumber-rest-bdd","last_synced_at":"2025-07-05T06:32:38.820Z","repository":{"id":43112542,"uuid":"74362524","full_name":"graze/cucumber-rest-bdd","owner":"graze","description":"Behavioural testing suite for RESTful APIs","archived":false,"fork":false,"pushed_at":"2018-11-19T11:16:50.000Z","size":283,"stargazers_count":35,"open_issues_count":2,"forks_count":17,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-21T14:58:09.576Z","etag":null,"topics":["behavioural-tests","cucumber","rest-api","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-21T12:42:45.000Z","updated_at":"2023-12-04T20:45:05.000Z","dependencies_parsed_at":"2022-09-22T06:12:40.505Z","dependency_job_id":null,"html_url":"https://github.com/graze/cucumber-rest-bdd","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/graze/cucumber-rest-bdd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fcucumber-rest-bdd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fcucumber-rest-bdd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fcucumber-rest-bdd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fcucumber-rest-bdd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graze","download_url":"https://codeload.github.com/graze/cucumber-rest-bdd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fcucumber-rest-bdd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261151320,"owners_count":23116739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behavioural-tests","cucumber","rest-api","ruby"],"created_at":"2024-10-14T21:04:08.385Z","updated_at":"2025-07-05T06:32:38.783Z","avatar_url":"https://github.com/graze.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cucumber Rest BDD\n\n[![Build Status](https://travis-ci.org/graze/cucumber-rest-bdd.svg?branch=master)](https://travis-ci.org/graze/cucumber-rest-bdd)\n[![image](https://images.microbadger.com/badges/image/graze/cucumber-rest-bdd.svg)](https://microbadger.com/images/graze/cucumber-rest-bdd \"Get your own image badge on microbadger.com\")\n[![image version](https://images.microbadger.com/badges/version/graze/cucumber-rest-bdd.svg)](https://microbadger.com/images/graze/cucumber-rest-bdd \"Get your own version badge on microbadger.com\")\n[![image license](https://images.microbadger.com/badges/license/graze/cucumber-rest-bdd.svg)](https://microbadger.com/images/graze/cucumber-rest-bdd \"Get your own license badge on microbadger.com\")\n[![Gem Version](https://badge.fury.io/rb/cucumber-rest-bdd.svg)](https://badge.fury.io/rb/cucumber-rest-bdd)\n\nA set of Behavioural tests that can be run against a REST API.\n\n![Giphy](https://media3.giphy.com/media/Tv7VPg6Os488g/giphy.gif)\n\nThis is based from: [Effective API Testing With Cucumber](https://github.com/gregbeech/website/blob/master/blog/2014/effective-api-testing-with-cucumber.markdown)\n\nA list of [Steps](STEPS.md) shows the comparison between Behavioural and Functional tests provided by this package.\n\n## Usage\n\nYou can include this as a gem in your features, or run directly through docker\n\n**Gem:**\n\n```bash\n~$ gem install cucumber-rest-bdd\n```\n\n**Docker:**\n\n```bash\n~$ docker run --rm -v $(pwd):/opt/src -e endpoint=http://server/ graze/cucumber-rest-bdd\n```\n\n## Configuration\n\nThe following environment variables modify how this will operate:\n\n- `endpoint` - (string) the base url to call for each request\n- `data_key` - (string) the root data key (if applicable) (for example: `\"data\"` if all responses have a `{\"data\":{}}` field)\n- `error_key` - (string) this will ignore the `data_key` when checking for errors\n- `field_separator` - (string) the separator used between words by the api\n- `field_camel` - (bool [`true`|`false`]) does this endpoint use camelCase for fields (default: `false`)\n- `resource_single` - (bool [`true`|`false`]) if each resource should be singularized or not (default: `false`)\n- `set_parent_id` - (bool [`true`|`false`]) when creating sub resources, automatically add parent ids\n\n## Examples\n\n- For a full list of steps see: [STEPS](STEPS.md)\n- These examples are taken from the test [features](features)\n\n### Retrieve items\n\n```gherkin\nGiven I am a client\nWhen I request the post \"1\"\nThen the request was successful\nAnd the response has the following attributes:\n    | attribute | type    | value |\n    | User Id   | numeric | 1     |\n    | Id        | numeric | 1     |\n    | Title     | string  | sunt aut facere repellat provident occaecati excepturi optio reprehenderit |\n    | Body      | string  | quia et suscipit\\\\nsuscipit recusandae consequuntur expedita et cum\\\\nreprehenderit molestiae ut ut quas totam\\\\nnostrum rerum est autem sunt rem eveniet architecto |\n```\n\n```gherkin\nGiven I am a client\nWhen I request the photo \"1\" for album \"1\" for user \"1\"\nThen the request was successful\nAnd the response has the attributes:\n    | attribute | type   | value                                              |\n    | title     | string | accusamus beatae ad facilis cum similique qui sunt |\n```\n\n```gherkin\nGiven I am a client\nWhen I request a list of posts with:\n    | User Id | 2 |\nThen the request is successful\nAnd the response is a list of at least 2 posts\nAnd one response has the following attributes:\n    | attribute | type    | value |\n    | User Id   | numeric | 2     |\n    | Id        | numeric | 11    |\n    | Title     | string  | et ea vero quia laudantium autem |\n    | Body      | string  | delectus reiciendis molestiae occaecati non minima eveniet qui voluptatibus\\\\naccusamus in eum beatae sit\\\\nvel qui neque voluptates ut commodi qui incidunt\\nut animi commodi |\n```\n\nYou can inspect child objects by using `:` in between the names\n\n```gherkin\nGiven I am a client\nWhen I request the comment \"1\" with:\n    | `_expand` | post |\nThen the response has the following attributes:\n    | attribute    | type   | value |\n    | name         | string | id labore ex et quam laborum |\n    | email        | string | Eliseo@gardner.biz |\n    | body         | string | laudantium enim quasi est quidem magnam voluptate ipsam eos\\\\ntempora quo necessitatibus\\\\ndolor quam autem quasi\\\\nreiciendis et nam sapiente accusantium |\n    | post : title | string | sunt aut facere repellat provident occaecati excepturi optio reprehenderit |\n    | post : body  | string | quia et suscipit\\\\nsuscipit recusandae consequuntur expedita et cum\\\\nreprehenderit molestiae ut ut quas totam\\\\nnostrum rerum est autem sunt rem eveniet architecto |\n```\n\nAlternatively you can inspect child arrays and objects by describing the path of the object with attributes\n\n```gherkin\nGiven I am a client\nWhen I set JSON request body to:\n    \"\"\"\n    {\"title\":\"test\",\"body\":\"multiple\",\n    \"comments\":[\n        {\"common\":1,\"id\":1,\"title\":\"fish\",\"body\":\"cake\",\"image\":{\"href\":\"some_url\"}},\n        {\"common\":1,\"id\":2,\"title\":\"foo\",\"body\":\"bar\",\"image\":{\"href\":\"some_url\"}}\n    ]}\n    \"\"\"\nAnd I send a POST request to \"http://test-server/posts\"\nThen the response has the attributes:\n    | attribute | type   | value    |\n    | title     | string | test     |\n    | body      | string | multiple |\nAnd the response has a list of comments\nAnd the response has a list of 2 comments\nAnd the response has two comments with attributes:\n    | attribute | type    | value |\n    | common    | integer | 1     |\nAnd the response has two comments with an image with attributes:\n    | attribute | type    | value    |\n    | href      | string  | some_url |\nAnd the response has one comment with attributes:\n    | attribute | type    | value |\n    | Id        | integer | 1     |\n    | Title     | string  | fish  |\n    | Body      | string  | cake  |\nAnd the response has one comment with attributes:\n    | attribute | type    | value |\n    | Id        | integer | 2     |\n    | Title     | string  | foo   |\n    | Body      | string  | bar   |\n```\n\nEach numeric request can be prefixed with a modifier to modify the number specified\n\n```gherkin\nGiven I am a client\nWhen I request a list of posts with:\n    | `_embed` | comments |\nThen the response is a list of posts\nThen the response is a list of more than 5 posts\nThen the response is a list of at least 10 posts\nThen more than three posts have the attributes:\n    | attribute | type    | value |\n    | User Id   | integer | 5     |\nThen less than 200 posts have more than four comments\nThen more than 50 posts have less than six comments\nThen more than 80 posts have a list of comments\nThen at least 90 posts have a list of five comments\nThen more than 10 posts have five comments\nThen less than 200 posts have five comments\n```\n\n#### Errors\n\nIf the `error_key` environment variable is set, if that key is used as the initial step it will ignore any `data_key`\nsetting.\n\nExample: `error_key=error`, `data_key=data`\n\n```gherkin\nThen the response has a list of posts       | {\"data\":[{\"id\": 12}]}\n\nThen the response has one error             | {\"errors\":[{\"message\": \"Error\"}]}\n\nThen the response has an error              | {\"error\": {\"message\": \"Error}}\n```\n\nExample: `error_key=`, `data_key=data`\n\n```gherkin\nThen the response has a list of posts       | {\"data\":[{\"id\": 12}]}\n\nThen the response has one error             | {\"data\": {\"errors\":[{\"message\": \"Error\"}]}}\n\nThen the response has an error              | {\"data\": {\"error\": {\"message\": \"Error}}}\n```\n\n### Creation\n\n```gherkin\nGiven I am a client\nWhen I request to create a post with:\n    | attribute | type    | value |\n    | Title     | string  | foo   |\n    | Body      | string  | bar   |\n    | User Id   | numeric | 1     |\nThen the request is successful and a post was created\nAnd the response has the following attributes:\n    | attribute | type    | value |\n    | User Id   | numeric | 1     |\n    | Title     | string  | foo   |\n    | Body      | string  | bar   |\n```\n\nIf the environment variable: `set_parent_id` is set to `true` then when you create sub resources it will add the level aboves id into the json, otherwise it will rely on the api to do it for you\n\n```gherkin\nGiven I am a client\nWhen I request to create a photo in album \"2\" for user \"1\" with:\n    | attribute | type   | value |\n    | title     | string | foo   |\nThen the comment was created\nAnd the response has the attributes:\n    | attribute | type   | value |\n    | Album Id  | int    | 2     |\n    | Title     | string | foo   |\nWhen I request a list of photos for album \"2\" for user \"1\"\nThen the request was successful\nAnd one comment has the attributes:\n    | attribute | type   | value |\n    | Title     | string | foo   |\n```\n\n### Removal\n\n```gherkin\nGiven I am a client\nWhen I request to remove the post \"20\"\nThen the request is successful\n```\n\n### Modification\n\n```gherkin\nGiven I am a client\nWhen I request to modify the post \"21\" with:\n    | attribute | type    | value |\n    | Title     | string  | foo   |\nThen the request is successful\nAnd the response has the following attributes:\n    | attribute | type    | value |\n    | User Id   | numeric | 3     |\n    | Title     | string  | foo   |\n    | Body      | string  | repellat aliquid praesentium dolorem quo\\\\nsed totam minus non itaque\\\\nnihil labore molestiae sunt dolor eveniet hic recusandae veniam\\\\ntempora et tenetur expedita sunt |\n```\n\n### Multiple Requests\n\n```gherkin\nGiven I am a client\nWhen I request to create a post with:\n    | attribute | type    | value |\n    | Title     | string  | foo   |\n    | Body      | string  | bar   |\n    | User Id   | integer | 12    |\nThen the request is successful\nWhen I save \"id\"\nAnd I request the post \"{id}\"\nThen the request is successful\nAnd the response has the following attributes:\n    | attribute | type    | value |\n    | Title     | string  | foo   |\n    | Body      | string  | bar   |\n    | User Id   | numeric | 12    |\n    | Id        | numeric | {id}  |\n```\n\n## Resources\n\nA resource \"name\" is attempted to be retrieved from the given name of the item to be retrieved. This pluralises, ensures everything is lower case, removes any unparameterisable characters and uses a `-` separator.\n\n```text\nToken -\u003e tokens\nUser -\u003e users\nBig Life -\u003e big-lives\noctopus -\u003e octopi\n```\n\nIf the environment variable: `resource_single` is set to `true` then it will not attempt to pluralise the resources.\n\n```text\nToken -\u003e token\nUser -\u003e user\n```\n\nYou can directly pass what you want using:\n\n```text\n`field`\n```\n\nthis will not modify the field.\n\n## Attributes\n\n### Types\n\nAttribute types:\nThe following types are supported:\n\n| type    | other names           | example   |\n|---------|-----------------------|-----------|\n| integer | numeric, number, long | 12        |\n| float   | double, decimal       | 4.8       |\n| string  | text                  | \"text\"    |\n| array   | array                 | [\"a\"]     |\n| object  | object                | {\"a\":\"b\"} |\n| null    | nil                   |           |\n| bool    | boolean               | true      |\n\n### Name conversion\n\nattributes are converted into singular parametrised versions of the provided name:\n\nThe conversion is based on the provided environment variables `field_camel` and `field_separator`\n\n#### Default\n\n```text\nfield_camel=false\nfield_separator=_\n\nSomeid -\u003e someid\nProduct Id -\u003e product_id\nBodies -\u003e body\n```\n\n#### CamelCase\n\n```text\nfield_camel=true\nfield_separator=_\n\nSomeid -\u003e someid\nProduct Id -\u003e productId\nBodies -\u003e body\n```\n\n#### Other Separators\n\n```text\nfield_camel=false\nfield_separator=-\n\nSomeid -\u003e someid\nProduct Id -\u003e product-id\nBodies -\u003e body\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraze%2Fcucumber-rest-bdd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraze%2Fcucumber-rest-bdd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraze%2Fcucumber-rest-bdd/lists"}