All Projects → hidroh → Cucumber Api

hidroh / Cucumber Api

Licence: apache-2.0
API validator in BBD style with Cucumber

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Cucumber Api

Bandcamp Api
API wrapper for querying band, album, and track data from bandcamp.com
Stars: ✭ 20 (-60%)
Mutual labels:  api, json
Node Quick Mock
🌞 基于Express的mock接口平台
Stars: ✭ 33 (-34%)
Mutual labels:  api, json
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+79076%)
Mutual labels:  api, json
Aruba
Test command-line applications with Cucumber-Ruby, RSpec or Minitest. The most up to date documentation can be found on Cucumber.Pro (https://app.cucumber.pro/projects/aruba)
Stars: ✭ 900 (+1700%)
Mutual labels:  bdd, cucumber
Flask Restx
Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 1,050 (+2000%)
Mutual labels:  api, json
Movement
Movement is an easier, simpler way to explore and use NIEM. Want to join the Movement and contribute to it? Start here.
Stars: ✭ 19 (-62%)
Mutual labels:  api, json
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+1814%)
Mutual labels:  api, json
Mobility
Pluggable Ruby translation framework
Stars: ✭ 644 (+1188%)
Mutual labels:  json, ruby-gem
Pantry
🥑 Free data storage as a service that allows devs to store JSON for multiple apps & users. A good resource when building personal projects, apps for hackathons, and prototypes alike.
Stars: ✭ 42 (-16%)
Mutual labels:  api, json
Spyne
A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
Stars: ✭ 992 (+1884%)
Mutual labels:  api, json
Telize
High performance JSON IP and GeoIP REST API (IP Geolocation)
Stars: ✭ 774 (+1448%)
Mutual labels:  api, json
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-2%)
Mutual labels:  api, json
Api
姬长信API For Docker 一个基于多种编程语言开源免费不限制提供生活常用,出行服务,开发工具,金融服务,通讯服务和公益大数据的平台.
Stars: ✭ 743 (+1386%)
Mutual labels:  api, json
Geochile
Esta es una api de Geocodificación, para que, con las coordenadas Latitud y Longitud se entregue una lista de ciudades cercanas.
Stars: ✭ 13 (-74%)
Mutual labels:  api, json
Json Ld.org
JSON for Linked Data
Stars: ✭ 722 (+1344%)
Mutual labels:  api, json
Behapi
Behat extension for those who want to write acceptances tests for apis
Stars: ✭ 29 (-42%)
Mutual labels:  api, bdd
Ponzu
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
Stars: ✭ 5,373 (+10646%)
Mutual labels:  api, json
Manticoresearch
Database for search
Stars: ✭ 610 (+1120%)
Mutual labels:  api, json
Realtime Newsapi
Financial News Aggregator - Real Time & Query API for Financial News
Stars: ✭ 34 (-32%)
Mutual labels:  api, json
Dito
Dito.js is a declarative and modern web framework with a focus on API driven development, based on Objection.js, Koa.js and Vue.js – Released in 2018 under the MIT license, with support by Lineto.com
Stars: ✭ 44 (-12%)
Mutual labels:  api, json

cucumber-api

Build Status Gem Version Dependency Status Code Climate Total Downloads

API validator in BDD style with Cucumber. cucumber-api lets one validate public APIs JSON response in blazingly fast time.

Inspired by cucumber-api-steps.

Checkout sample to see cucumber-api in action.

Installation

Add cucumber-api gem to your Gemfile:

gem 'cucumber-api'

Require cucumber-api in your Cucumber's env.rb:

require 'cucumber-api'

Configuration

Verbose logging: enable verbose logging of API calls and responses by setting cucumber_api_verbose=true in your ENV, preferably via your cucumber.yml

# config/cucumber.yml
##YAML Template
---
verbose     : cucumber_api_verbose=true

Usage

Available steps

Preparation steps

Specify your request header's Content-Type and Accept. The only supported option for Accept is application/json at the moment.

Given I send and accept JSON
Given I send "(.*?)" and accept JSON

You could also others header's information like:

Given I send and accept JSON
And I add Headers:
  | name1 | value |
  | name2 | other |  

Specify POST body

When I set JSON request body to '(.*?)'
When I set form request body to:
  | key1 | value1              |
  | key2 | {value2}            |
  | key3 | file://path-to-file |
When I set JSON request body to:
"""
{
  "key1": "jsonString",
  "key2":  1
}
"""

Or from YAML/JSON file

When I set request body from "(.*?).(yml|json)"

Example:

Given I send "www-x-form-urlencoded" and accept JSON
When I set JSON request body to '{"login": "[email protected]", "password": "password"}'
When I set form request body to:
  | login    | [email protected]     |
  | password | password              |
When I set request body from "data/json-data.json"
When I set request body from "data/form-data.yml"

Request steps

Specify query string parameters and send an HTTP request to given URL with parameters

When I send a (GET|POST|PATCH|PUT|DELETE) request to "(.*?)"
When I send a (GET|POST|PATCH|PUT|DELETE) request to "(.*?)" with:
  | param1 | param2 | ... |
  | value1 | value2 | ... |

Temporarily save values from the last request to use in subsequent steps in the same scenario:

When I grab "(.*?)" as "(.*?)"

Optionally, auto infer placeholder from grabbed JSON path:

# Grab and auto assign {id} as placeholder
When I grab "$..id"

The saved value can then be used to replace {placeholder} in the subsequent steps.

Example:

When I send a POST request to "http://example.com/token"
And I grab "$..request_token" as "token"
And I grab "$..access_type" as "type"
And I grab "$..id"
And I send a GET request to "http://example.com/{token}" with:
  | type            | pretty |
  | {type}          | true   |
Then the JSON response should have required key "id" of type string and value "{id}"

Assume that http://example.com/token have an element {"request_token": 1, "access_type": "full", "id": "user1"}, cucumber-api will execute the followings:

This will be handy when one needs to make a sequence of calls to authenticate/authorize API access.

Assert steps

Verify:

  • HTTP response status code
  • JSON response against a JSON schema conforming to JSON Schema Draft 4
  • Adhoc JSON response key-value type pair, where key is a JSON path
Then the response status should be "(\d+)"
Then the JSON response should follow "(.*?)"
Then the JSON response root should be (object|array)
Then the JSON response should have key "([^\"]*)"
Then the JSON response should have (required|optional) key "(.*?)" of type (numeric|string|boolean|numeric_string|object|array|any)( or null)
Then the JSON response should have (required|optional) key "(.*?)" of type (numeric|string|boolean|numeric_string|object|array|any)( or null) and value "(.*?)"

Example:

Then the response status should be "200"
Then the JSON response should follow "features/schemas/example_all.json"
Then the JSON response root should be array
Then the JSON response should have key "id"
Then the JSON response should have optional key "format" of type string or null
Then the JSON response should have required key "status" of type string and value "foobar"

Also checkout sample for real examples. Run sample with the following command:

cucumber -p verbose

Response caching

Response caching is provided for GET requests by default. This is useful when you have a Scenario Outline or multiple Scenarios that make GET requests to the same endpoint.

Only the first request to that endpoint is made, subsequent requests will use cached response. Response caching is only available for GET method.

The response cache can also be cleared if needed:

Given I clear the response cache

Dependencies

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].