测试 Rails 控制器选择布局而不渲染布局
我想取消渲染,并且想测试是否选择了某个布局
额外的收获:在测试环境中,该布局文件将不存在
是否有一种聪明的方法来检测控制器是否选择了布局而无需渲染,并且不会触发 ActionView::MissingTemplate 错误?
(这是在 Rails 2.3 应用程序上,但请随意聊天 Rails 3)
i'd like to stub out render and i'd like to test that a certain layout is chosen
bonus catch: in the test env, that layout file will not exist
is there a clever way to detect if the controller has selected a layout without rendering, and without triggering an ActionView::MissingTemplate error?
(this is on a Rails 2.3 app, but feel free to chat rails 3)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是将布局选择逻辑放入助手中并直接测试助手。无需删除任何内容或伪造渲染。
The easiest way to do this is put your layout selection logic in a helper and test the helper directly. No need to stub anything out or fake the rendering.