我正在尝试为可安装的rails 3.1引擎编写一些路由规范.我有工作模型和控制器规格,但我无法弄清楚如何指定路线.
对于示例引擎'testy',我尝试的每种方法都以相同的错误结束:
Run Code Online (Sandbox Code Playgroud)ActionController::RoutingError: No route matches "/testy"
我已经尝试了Rspec和Test :: Unit语法(spec/routing/index_routing_spec.rb):
describe "test controller routing" do
it "Routs the root to the test controller's index action" do
{ :get => '/testy/' }.should route_to(:controller => 'test', :action => 'index')
end
it "tries the same thing using Test::Unit syntax" do
assert_routing({:method => :get, :path => '/testy/', :use_route => :testy}, {:controller => 'test', :action => 'index'})
end
end
Run Code Online (Sandbox Code Playgroud)
我已经正确布局了路由(config/routes.rb):
Testy::Engine.routes.draw do
root :to => 'test#index'
end
Run Code Online (Sandbox Code Playgroud)
并将它们安装在虚拟应用程序中(spec/dummy/config/routes.rb):
Rails.application.routes.draw do
mount Testy::Engine => "/testy" …
Run Code Online (Sandbox Code Playgroud)