Skip to content

Commit

Permalink
refactored dynamic_pages_routing test to iterate through all allowed …
Browse files Browse the repository at this point in the history
…pages
  • Loading branch information
Janell-Huyck committed Dec 13, 2023
1 parent 8317a36 commit 8976951
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions spec/routing/dynamic_pages_routing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@

RSpec.describe PagesController, type: :routing do
describe 'routing' do
it 'routes to #show with about as parameter' do
expect(get: '/pages/about').to route_to('pages#show', page: 'about')
end

it 'routes to #show with contact as parameter' do
expect(get: '/pages/contact').to route_to('pages#show', page: 'contact')
end

it 'routes to #show with faq as parameter' do
expect(get: '/pages/faq').to route_to('pages#show', page: 'faq')
PagesController::ALLOWED_PAGES.each do |page|
it "routes to #show with #{page} as parameter" do
expect(get: "/pages/#{page}").to route_to('pages#show', page: page)
end
end

it 'does not route to #show without a page parameter' do
expect(get: '/pages/').not_to be_routable
end

it 'routes to #closed' do
expect(get: '/pages/closed').to route_to('pages#show', page: 'closed')
end
end
end

0 comments on commit 8976951

Please sign in to comment.