This gem is helpful on huge Rails JSON API applications: it allows to specify and track the coverage of tested API requests according to app's routes.
Add this to your application's Gemfile:
gem 'rspec-rails'
gem 'rspec-routes_coverage'
And then execute:
$ bundle
spec/requests/items_spec.rb:
require 'spec_helper'
describe ItemsController do
describe_request :index, request_path: '/items', method: 'GET' do
it 'lists items' do
get '/items'
# ...
end
end
# another style:
describe_request 'GET /items/:id' do
it 'shows item' do
get "/items/#{Item.first.id}"
# ...
end
end
end
By default, pending routes will not be output in common spec pass. To show them you should run:
$ RAILS_ENV=test bundle exec rake spec:requests:with_coverage
- Make "auto marking" with get/post/put/etc... methods
- Make untested routes to be marked as pending specs
- Gem tests :)
- ?????
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request