当路由“匹配”时,RSpec 似乎中断了。语句列出了子目录(或嵌套路由)
it "should match login for existing account" do
{ :get => 'http://www.' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"})
end
match '/login' => 'admin/calendars#index' # this one should actually work, but fails:
The recognized options <{"controller"=>"errors", "action"=>"handle404", "a"=>"login"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go", "action"=>"index", "a"=>"login"}>.
这里的特定controller#route确实存在,但目录/嵌套路由('admin/')似乎会导致失败。即使该路由不存在,考虑到那里指定的路由('calendars#index')不存在,它也应该以与下一个路由相同的方式失败。结果路由的存在并不重要——因为这只是为了测试映射是否有效。知道如何解决这个问题吗?
match '/login' => 'calendars#index' #this one fails as expected:
The recognized options <{"controller"=>"calendars", "action"=>"index"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go"}>
it "should match login for existing account" do
{ :get => 'http://www.' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"})
end
match '/login' => 'admin/calendars#index' # this one should actually work, but fails:
The recognized options <{"controller"=>"errors", "action"=>"handle404", "a"=>"login"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go", "action"=>"index", "a"=>"login"}>.
The specific controller#route here does exist, but the directory/nested route ('admin/') seems to cause a failure. Even if the route didn't exist it should fail in the same way the next one does, considering that the specified route there ('calendars#index') does not exist. The existence of the resulting routes doesn't matter -- as this is only supposed to test that the mapping works. Any idea how to get around this?
match '/login' => 'calendars#index' #this one fails as expected:
The recognized options <{"controller"=>"calendars", "action"=>"index"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go"}>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您构建的测试路线是错误的:
可能应该阅读:
因为大概您想测试 http://foo.lvh。 me/etc 不是 http://www.foo.lvh.me 等
Your building of your test route is wrong:
should probably read:
as presumably you want to test http://foo.lvh.me/etc not http://www.foo.lvh.me etc