-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test cases which tests format:false constraint on the route
- Loading branch information
1 parent
57a2eb0
commit 73bf213
Showing
1 changed file
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Index routing', type: :routing do | ||
it 'routes GET / to index#show' do | ||
it 'routes GET / to index#index' do | ||
expect(get: '/').to route_to(controller: 'index', action: 'index') | ||
end | ||
|
||
it 'routes GET /index to index#index' do | ||
it 'routes GET /index to index#show' do | ||
expect(get: '/index').to route_to(controller: 'index', action: 'show', id: 'index') | ||
end | ||
|
||
end | ||
it 'does not route GET /index.xml to index#show' do | ||
expect(get: '/index.xml').not_to route_to(controller: 'index', action: 'show', id: 'index', format: 'xml') | ||
end | ||
|
||
it 'routes GET /custom_id to index#show with custom_id' do | ||
expect(get: '/custom_id').to route_to(controller: 'index', action: 'show', id: 'custom_id') | ||
end | ||
|
||
it 'does not route GET /custom_id.xml to index#show with custom_id and xml format' do | ||
expect(get: '/custom_id.xml').not_to route_to(controller: 'index', action: 'show', id: 'custom_id', format: 'xml') | ||
end | ||
|
||
it 'routes GET / with format: false to index#index' do | ||
expect(get: '/', constraints: { format: false }).to route_to(controller: 'index', action: 'index') | ||
end | ||
|
||
it 'does not route GET /index.xml with format: false to index#show' do | ||
expect(get: '/index.xml', constraints: { format: false }).not_to route_to(controller: 'index', action: 'show', id: 'index', format: 'xml') | ||
end | ||
|
||
it 'does not route GET /custom_id.xml with format: false to index#show with custom_id' do | ||
expect(get: '/custom_id.xml', constraints: { format: false }).not_to route_to(controller: 'index', action: 'show', id: 'custom_id', format: 'xml') | ||
end | ||
end |