Cucumber 因“未定义的方法渲染”而失败
我有一个 link_tag 视图,它将呈现的内容添加到页面
link_to("add",nil,:id=>"create_row_cycle",:onclick=>"$('div#cycle_form table').append('#{escape_javascript(render(:partial=>'cycles', :object=>Cycle.new))}');return false;", :href=>"")
我想测试黄瓜中的代码,并且黄瓜失败了该方法 RENDER undefined。
我的步骤是
find('div#cycle_form table').text.should have_content(render(:partial=>'cycles', :object=>Cycle.new))
请帮助,我如何用黄瓜测试这个?
I have a link_tag in view which add rendered content to page
link_to("add",nil,:id=>"create_row_cycle",:onclick=>"$('div#cycle_form table').append('#{escape_javascript(render(:partial=>'cycles', :object=>Cycle.new))}');return false;", :href=>"")
I want to test that code in cucumber and cucumber fails that method RENDER undefined.
my step is
find('div#cycle_form table').text.should have_content(render(:partial=>'cycles', :object=>Cycle.new))
Help please, how can I test this with cucumber?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Cucumber 不理解请求的“渲染”部分 - 您想要做的是找到“循环”部分中存在的一些内容并检查它。例如,如果您的“cycles”部分包含文本“Here are the Cycles for object <%= object.name %>”,那么您的黄瓜测试将类似于
这样,您可以确保您的 Cycles 部分是正确渲染。
Cucumber doesn't understand the "render" part of the request - what you'd want to do is find some content that exists in the "cycles" partial and check for that. For example, if your "cycles" partial contained the text "Here are the cycles for object <%= object.name %>", then your cucumber test would look like
In that way, you can ensure that your cycles partial is rendering correctly.