使用rspec测试嵌套路由 [英] testing nested routes with rspec
本文介绍了使用rspec测试嵌套路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用rspec测试路由。以下给出了错误消息期望的块返回真值。
I'm trying to test routes with rspec. The following gives an error of "Expected block to return true value".
我不确定我缺少什么。通过浏览器,我可以发布到该URL,并且成功。
I'm not sure what I am missing. Through a browser I can post to this url and it is successful.
有什么想法吗?谢谢!
路线
resources :forum_topics do
resources :forum_sub_topics
end
测试:
it "recognizes and generates nested #create" do
{ :post => "/forum_topics/1/forum_sub_topics" }.should route_to(:controller => "forum_sub_topics", :action => "create", :forum_topic_id => 1)
end
推荐答案
没有人正式回答我的问题,所以我会:)
Well nobody officially answered my question, so I will :)
{ :post => "/forum_topics/1/forum_sub_topics" }.should route_to(:controller => "forum_sub_topics", :action => "create", :forum_topic_id => 1)
它归结为:forum_topic_id => 1不等于:forum_topic_id => 1也许我的PHP日子已经悄然而至。字符串和整数:)
It comes down to :forum_topic_id => 1 not being equal to :forum_topic_id => "1" Perhaps my PHP days have crept up to bite me. Strings and Integers :)
这篇关于使用rspec测试嵌套路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文