路由规范

路由规范通过type: :routing标记,或者如果您已设置config.infer_spec_type_from_file_location!,则将其放置在spec/routing中。

除了标准的 RESTful 路由之外,没有任何内容的简单应用程序不会从路由规范中获得太多价值,但是当用于指定自定义路由(例如,虚荣链接、slug 等)时,它们可以提供显着的价值。

expect(:get => "/articles/2012/11/when-to-use-routing-specs").to route_to(
  :controller => "articles",
  :month => "2012-11",
  :slug => "when-to-use-routing-specs"
)

它们对于不应提供的路由也有价值

expect(:delete => "/accounts/37").not_to be_routable

主题