No commit activity in last 3 years
No release in over 3 years
ApiResponseTester tests the api endpoints by taking a yaml file which consists of api endpoints, params, and expected response json file reference.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.1
~> 3.8
 Project Readme

Api Response Tester

A simple to use testing tool to test the apis. Api response tester can be used to test the json responses of your api. It is yaml based i.e, you are required to put all the test scenarios in a yaml file and from there api response tester will run each of your test scenarios and prints the logs on your terminal. To know how it works please see the Usage section below.

Installation

Add this line to your application's Gemfile:

gem 'api_response_tester'

And then execute:

$ bundle

Or install it yourself as:

$ gem install api_response_tester

Usage

Api response tester need two things:

  1. Test file (yml file consists of your test cases)
  2. All of your expected response files under a single folder
#test_file.yml

- api: http://localhost:3000/users.json
  params:
  method: get
  status: 200
  expected_response_file: users_response.json

this is a test for a get request. In the above example params is not set as this is an example of get request. In case of post request you can pass the params using params field.

#all_responses/users_response.json

 [
    {
      "name": "test_user",
      "role": "admin"
    },
    {
      "name": "another_user",
      "role": "buyer"
    }
 ]

the above json file should be inside a folder which you will mention which calling the test function of api_response_tester.

Development

When the test file and the response folder has been created finally you can call the test method as given below:

#test_api.rb

require 'api_response_tester'

ApiResponseTester.test_api('path/to/test_file.yml', 'path/to/responses_directory')
 

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/abhikur/api_response_tester. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the api_response_tester project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.