API_RSpecta
api_rspecta adds following helper methods to test your JSON APIs with RSpec:
JSON:
#jsonreturns parsedlast_response.body#refresh_jsonreparseslast_response.body#print_jsontoJSON.pretty_generatelast response JSON#json_has_keytells you if passed json object has akey#json_has_keyssame as above but for a list of keys#json_has_no_keyis opposite to#json_has_key
Response:
should_respond_okchecks iflast_response.statuswas 200should_respond_createdchecks iflast_response.statuswas 201should_respond_with_no_contentchecks iflast_response.statuswas 204should_respond_not_authenticatedchecks iflast_response.statuswas 401should_respond_not_authorizedchecks iflast_response.statuswas 403should_respond_not_foundchecks iflast_response.statuswas 404should_respond_with_error_forchecks iflast_response.statuswas 422 and thatjsonhaserrorsfor passedfieldshould_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
