获取 Rspec 视图规范以呈现应用程序布局 [英] getting Rspec view specs to render application layout

查看:39
本文介绍了获取 Rspec 视图规范以呈现应用程序布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们的项目中有多种视图规范:

So we have a variety of view specs in our project:

https://github.com/tansaku/LocalSupport/blob/master/spec/views/organizations/index.html.erb_spec.rb

但是我们在测试由 gmap4rails gem 生成的 javascript 时遇到了问题.我想我已经将问题归结为视图规范似乎没有呈现应用程序布局的问题.

but we are having trouble with testing javascript generated by the gmap4rails gem. I think I've tracked the issue down to the problem that the view specs don't appear to render the application layout.

我们有一个单独的应用程序布局视图规范,它可以工作,并且可以很好地呈现应用程序布局.然而,当我们运行视图规范时,应用程序布局代码没有被渲染.

We have a separate view spec for the application layout, which works, and that renders the application layout fine. However when we run view specs the application layout code is not getting rendered.

对此非常感谢的任何帮助

Any help on this much appreciated

推荐答案

我正要发布这个,然后看到了 如何从 RSpec 视图规范中测试页面的标题?不同的问题,但让我想出了在规范中显式呈现布局的解决方案:

I was just about to post this and then saw the second answer to How do I test the title of a page from an RSpec view spec? which is about a different problem, but allowed me to come up with the solution which is to explicitly render the layout in the spec:

render template: "organizations/index", layout: "layouts/application"

这篇关于获取 Rspec 视图规范以呈现应用程序布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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