ShouldaRouting
This gem aims to provide a simple DSL that looks like the rails routes DSL that is used in the routes.rb file. This requires the RSpec testing framework.
Installation
Add this line to your application's Gemfile:
gem 'shoulda_routing'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install shoulda_routing
Basic usage
In your routes.rb file:
YourApp::Application.routes.draw do
namespace :admin do
resources :users
resources :posts, only: [:index, :show]
namespace :mobile do
resources :users
resources :parents, controller: :users
end
end
resources :users, except: :destroy do
resources :posts, :comments
end
end
In your routing_spec.rb file:
require 'spec_helper'
describe "Routes" do
namespace :admin do
resources :users
resources :posts, only: [:index, :show]
namespace :mobile do
resources :users
resources :parents, controller: :users
end
end
resources :users, except: :destroy do
resources :posts, :comments
end
end
This will generate the necessary tests for all rails routes above.
TO-DO
- Support member and collection routes.
- Support single resources (get, post, put, delete) actions.
Testing
To run the test suite you should run the default rake task:
$ bundle exec rake
To run the unit tests:
$ bundle exec rake spec:unit
To run the integration tests:
$ bundle exec cucumber
Contributing
- Fork it
- 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 new Pull Request