RSpec / RSpec Rails / Docs / Routing specs
This page comes from RSpec Rails 6.0.4. It is not part of the 6.0.1 docs. See the latest RSpec Rails docs.
Using named routes
Routing specs have access to named routes.
Scenario: Access named route
- Given a file named "
spec/routing/widget_routes_spec.rb" with:rubyrequire "rails_helper" RSpec.describe "routes to the widgets controller", type: :routing do it "routes a named route" do expect(:get => new_widget_path). to route_to(:controller => "widgets", :action => "new") end end - When I run `rspec spec`
- Then the examples should all pass
Source: features/routing_specs/named_routes.feature at v6.0.4, RSpec Rails (MIT license).