gpt4 book ai didi

ruby-on-rails-3 - 应用程序 Controller 辅助方法不适用于 View 规范

转载 作者:行者123 更新时间:2023-12-04 00:55:13 25 4
gpt4 key购买 nike

我的应用程序 Controller 中有一个名为 current_user 的辅助方法(与 Authlogic 一起使用)。

使用该帮助程序的 View 规范失败(但当我使用浏览器时 View 正在工作)
ActionView::Template::Error: undefined local variable or method 'current_user' for #<#<Class:0x0000000229b060>:0x00000002004248>
我使用 rspec 2.6.0。

有人遇到过同样的问题吗?请指教。谢谢

最佳答案

您可以在 view 上删除该方法。

view.stub(:current_user).and_return(user)

这也适用于辅助规范。

关于ruby-on-rails-3 - 应用程序 Controller 辅助方法不适用于 View 规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6057026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com