使用命名路由

路由规格可以访问命名路由。

访问命名路由

给定一个名为“spec/routing/widgetroutesspec.rb”的文件,其中包含

require "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

我运行 rspec spec

那么所有示例都应该通过。