0.0
No commit activity in last 3 years
No release in over 3 years
`api_rspecta` adds following helper methods to test your JSON APIs with RSpec: **JSON:** - `#json` returns parsed `last_response.body` - `#refresh_json` reparses `last_response.body` - `#print_json` to `JSON.pretty_generate` last response JSON - `#json_has_key` tells you if passed json object has a `key` - `#json_has_keys` same as above but for a list of keys - `#json_has_no_key` is opposite to `#json_has_key` **Response:** - `should_respond_ok` checks if `last_response.status` was 200 - `should_respond_created` checks if `last_response.status` was 201 - `should_respond_with_no_content` checks if `last_response.status` was 204 - `should_respond_not_authenticated` checks if `last_response.status` was 401 - `should_respond_not_authorized` checks if `last_response.status` was 403 - `should_respond_not_found` checks if `last_response.status` was 404 - `should_respond_with_error_for` checks if `last_response.status` was 422 and that `json` has `errors` for passed `field` - `should_respond_with_errors_for` same as above but for a list of errors
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.7
~> 10.0
~> 3.0.0
 Project Readme

Stories in Ready

API_RSpecta

api_rspecta adds following helper methods to test your JSON APIs with RSpec:

JSON:

  • #json returns parsed last_response.body
  • #refresh_json reparses last_response.body
  • #print_json to JSON.pretty_generate last response JSON
  • #json_has_key tells you if passed json object has a key
  • #json_has_keys same as above but for a list of keys
  • #json_has_no_key is opposite to #json_has_key

Response:

  • should_respond_ok checks if last_response.status was 200
  • should_respond_created checks if last_response.status was 201
  • should_respond_with_no_content checks if last_response.status was 204
  • should_respond_not_authenticated checks if last_response.status was 401
  • should_respond_not_authorized checks if last_response.status was 403
  • should_respond_not_found checks if last_response.status was 404
  • should_respond_with_error_for checks if last_response.status was 422 and that json has errors for passed field
  • should_respond_with_errors_for same as above but for a list of errors

Installation

Add this line to your application's Gemfile:

gem 'api_rspecta'

And then execute:

$ bundle

Or install it yourself as:

$ gem install api_rspecta

Usage

TODO: Write usage instructions here

Contributing

  1. Fork it ( https://github.com/SmartCloud/api_rspecta/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request