Skip to content

Example using RSpec and nice_http to test REST APIs. (Uber API and Reqres API)

Notifications You must be signed in to change notification settings

MarioRuiz/api-testing-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 API using a YAML Swagger / Open API file and Reqres 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

  2. Install the libraries we use by running from root folder:

    bundle install

Documentation

General

Libraries

Running tests

To run all the tests:

rspec

To run a particular test file:

rspec ./spec/my_test_spec.rb

To run a particular test (example) inside a test file, add the line number where the test is:

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.

HOST=10.20.30.50 rspec ./spec/my_test_spec.rb

About

Example using RSpec and nice_http to test REST APIs. (Uber API and Reqres API)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages