Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marioruiz/api-testing-example
Example using RSpec and nice_http to test REST APIs. (Uber API and Reqres API)
https://github.com/marioruiz/api-testing-example
openapi openapi3 rspec ruby swagger test testing
Last synced: 13 days ago
JSON representation
Example using RSpec and nice_http to test REST APIs. (Uber API and Reqres API)
- Host: GitHub
- URL: https://github.com/marioruiz/api-testing-example
- Owner: MarioRuiz
- Created: 2019-02-12T12:33:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T11:37:01.000Z (almost 6 years ago)
- Last Synced: 2024-10-11T23:09:43.745Z (3 months ago)
- Topics: openapi, openapi3, rspec, ruby, swagger, test, testing
- Language: Ruby
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API testing example
The purpose of this document is to be an easy guide for devs and testers to start testing REST APIs just in minutes.
For the examples we will be testing the [**Uber**](https://api.uber.com) API using a YAML Swagger / Open API file and [**Reqres**](https://reqres.in/) API using a normal Request Hash file.
To generate the Request Hashes from a **Swagger** / **Open API file**, run the file ./utils/import_swagger.rb or use the **open_api_import** command line executable.
If you want to automatically generate RSpec tests for every end point of your Swagger file, use the create_tests gem: https://github.com/MarioRuiz/create_tests
# Installation
1. Install Ruby >=2.4. Recommended last 2.5 stable release. To see which version you already have installed: `ruby -v`
* [Ruby Installation](https://www.ruby-lang.org/en/documentation/installation/)2. Install the libraries we use by running from root folder:
```bash
bundle install
```
# Documentation## General
* [Ruby in 20 minutes](https://www.ruby-lang.org/en/documentation/quickstart/)
* [Ruby from other languages](https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/)
* [Ruby Cheat Sheet](https://learnxinyminutes.com/docs/ruby/)## Libraries
* [RSpec](http://rspec.info/), [RSpec CheatSheet](https://devhints.io/rspec)
* [nice_http](https://github.com/MarioRuiz/nice_http)
* [nice_hash](https://github.com/MarioRuiz/nice_hash)
* [open_api_import](https://github.com/MarioRuiz/open_api_import)
* [create_tests](https://github.com/MarioRuiz/create_tests)# Running tests
To run all the tests:
```bash
rspec
```To run a particular test file:
```bash
rspec ./spec/my_test_spec.rb
```To run a particular test (example) inside a test file, add the line number where the test is:
```bash
rspec ./spec/my_test_spec.rb:42
```The default values to set all tests are on `settings` folder. You can pass parameters to overwrite the settings in command line or ENV variables.
```bash
HOST=10.20.30.50 rspec ./spec/my_test_spec.rb
```