Created
December 25, 2010 09:12
-
-
Save rummelonp/754783 to your computer and use it in GitHub Desktop.
Ruby on Rails3でRSpecを使ったルーティングのテストのコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RspecRailsSample::Application.routes.draw do | |
get "/" => "index#index", as: :index | |
get "/user/:id(/max_id/:max_id)" => "index#user", as: :user | |
post "/find" => "index#find", as: :find | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe :routes do | |
describe 'GET "index"' do | |
subject { {get: '/'} } | |
it { should route_to(controller: 'index', action: 'index') } | |
end | |
describe 'GET "user/1"' do | |
context 'without max id' do | |
subject { {get: '/user/1'} } | |
it { should route_to(controller: 'index', action: 'user', id: '1') } | |
end | |
context 'with max id "1"' do | |
subject { {get: '/user/1/max_id/10'} } | |
it { should route_to(controller: 'index', action: 'user', id: '1', max_id: '10') } | |
end | |
end | |
describe 'POST "find"' do | |
subject { {post: '/find', url: ''} } | |
it { should route_to(controller: 'index', action: 'find') } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment