api_rspecta
adds following helper methods to test your JSON APIs with RSpec:
JSON:
#json
returns parsedlast_response.body
#refresh_json
reparseslast_response.body
#print_json
toJSON.pretty_generate
last response JSON#json_has_key
tells you if passed json object has akey
#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 iflast_response.status
was 200should_respond_created
checks iflast_response.status
was 201should_respond_with_no_content
checks iflast_response.status
was 204should_respond_not_authenticated
checks iflast_response.status
was 401should_respond_not_authorized
checks iflast_response.status
was 403should_respond_not_found
checks iflast_response.status
was 404should_respond_with_error_for
checks iflast_response.status
was 422 and thatjson
haserrors
for passedfield
should_respond_with_errors_for
same as above but for a list of errors
Add this line to your application's Gemfile:
gem 'api_rspecta'
And then execute:
$ bundle
Or install it yourself as:
$ gem install api_rspecta
TODO: Write usage instructions here
- 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