如何测试也定义为辅助方法的 ApplicationController 方法? [英] How to test ApplicationController method defined also as a helper method?

查看:18
本文介绍了如何测试也定义为辅助方法的 ApplicationController 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 ApplicationController 中,我有一个方法定义为辅助方法:

In my ApplicationController I have a method defined as a helper method:

helper_method :some_method_here

  • 如何在 RSpec 中测试 ApplicationController?
  • 在测试视图/助手时如何包含/调用此助手方法?

我使用 Rails3 和 RSpec2

推荐答案

您可以使用 匿名控制器 来测试您的 ApplicationController,如 RSpec 文档中所述.还有一个关于测试助手的部分.

You can use an anonymous controller to test your ApplicationController, as describe in the RSpec documentation. There's also a section on testing helpers.

这篇关于如何测试也定义为辅助方法的 ApplicationController 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆