API_RSpecta
api_rspecta adds following helper methods to test your JSON APIs with RSpec:
JSON:
- #jsonreturns parsed- last_response.body
- #refresh_jsonreparses- last_response.body
- #print_jsonto- JSON.pretty_generatelast response JSON
- #json_has_keytells you if passed json object has a- key
- #json_has_keyssame as above but for a list of keys
- #json_has_no_keyis opposite to- #json_has_key
Response:
- should_respond_okchecks if- last_response.statuswas 200
- should_respond_createdchecks if- last_response.statuswas 201
- should_respond_with_no_contentchecks if- last_response.statuswas 204
- should_respond_not_authenticatedchecks if- last_response.statuswas 401
- should_respond_not_authorizedchecks if- last_response.statuswas 403
- should_respond_not_foundchecks if- last_response.statuswas 404
- should_respond_with_error_forchecks if- last_response.statuswas 422 and that- jsonhas- errorsfor passed- field
- should_respond_with_errors_forsame 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
- Fork it ( https://github.com/SmartCloud/api_rspecta/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request