如何测试扩展我的控制器的模块?
我想创建一个模块,因为我需要对应用程序的每个控制器操作执行一些方法。因此,我创建了一个模块并在我的应用程序控制器中使用了 before_filter ,以便它针对每个操作运行。
该模块就像控制器扩展,因为它处理重定向并具有一些方法。我需要有一个登录用户来检查这一点,但由于某种原因,我为其他控制器使用的宏无法识别:
require 'spec_helper'
require 'devise/test_helpers'
describe GameEngine::GameLoop do
login_user
it "should check tavern quest" do
...
end
end
我发现 login_user 未定义,尽管它适用于我需要的所有控制器。为什么模块无法识别它?
I wanted to create a module because i needed to execute some methods upon every controller action of my application. Thus, i created a module and used a before_filter to my application controller, so that it runs for every action.
This module is like a controller extension, since it handles redirects and has some methods as well. I need to have a logged in user to check that, but for some reason, the macro that i have for my other controllers is not recognized :
require 'spec_helper'
require 'devise/test_helpers'
describe GameEngine::GameLoop do
login_user
it "should check tavern quest" do
...
end
end
I get that login_user is undefined, though it works for all my controller, where i need it. Why isn't it recognized on the module ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论