未定义方法错误“has_content?”与 rspec/capybara/rails3
我收到一个未定义的方法“has_content?” rspeccontroller_spec 文件上出现错误。
我发现一个有类似问题的线程,尽管该线程说该问题已在 rspec2.0beta 中修复(这是一个相当旧的线程),但我在更新的版本中得到了这个问题。 rspec 上的一些线程显示水豚在视图规范中不起作用,但我正在控制器规范中工作,因此这不应该成为问题...
我的 Gemfile 信息如下所示:
rspec-rails+ dependecies 2.6.0.rc6
capybara 0.4.1.2
rails 3.0.7
我正在尝试做一个简单的断言喜欢
response.body.should have_content("Project A")
感谢您的回复, 托尼
I am getting an undefined method 'has_content?' error on an rspec controller_spec file.
I found a thread with similar issues though that thread said the issue was fixed in rspec2.0beta (it was a fairly old thread) but I'm getting this with a more recent version. Some threads on rspec shows that capybara doesn't work in view specs, but I'm working in the controller specs so that shouldn't be the issue...
My Gemfile info looks like this:
rspec-rails+ dependecies 2.6.0.rc6
capybara 0.4.1.2
rails 3.0.7
I am trying to do a simple assert like
response.body.should have_content("Project A")
Thanks for the response,
Tony
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,Capybara 仅包含在 Rspec 请求规范中。将此文件更改为请求规范(将其放入请求规范目录中,更改其标题...)
阅读水豚自述文件部分“使用水豚与 RSpec”
https://github.com/jnicklas/capybara
另外,如果这些是您想要执行的断言类型,则这符合请求规范不仅仅是控制器规格。
Capybara is only included in Rspec request specs by default. Change this file to a be a request spec (put it in the request specs directory, change the title of it...)
Read the capybara Readme section 'Using Capybara with RSpec'
https://github.com/jnicklas/capybara
Also, if these are the types of asserts you're looking to do, this qualifies as a request spec more than it is a controller spec.