简体   繁体   English

NameError:未初始化的常量水豚

[英]NameError: uninitialized constant Capybara

I am a beginner of Ruby on Rails and I am doing a online assignment: https://drive.google.com/file/d/0Bwvt4e6DQqn4ZjgwdzFGazZBZVE/view 我是Ruby on Rails的初学者,并且正在做在线作业: https : //drive.google.com/file/d/0Bwvt4e6DQqn4ZjgwdzFGazZBZVE/view

repository: https://github.com/jhu-ep-coursera/fullstack-course1-module3 仓库: https : //github.com/jhu-ep-coursera/fullstack-course1-module3

However, I encountered some problems (step 5 of getting started in the file) when I tried to get started. 但是,当我尝试入门时遇到了一些问题(该文件入门的第5步)。

The error I got is shown below: 我收到的错误如下所示:

An error occurred while loading ./spec/recipes_app_spec.rb.
Failure/Error: Capybara.default_driver = :poltergeist

NameError:
uninitialized constant Capybara
# ./spec/recipes_app_spec.rb:1:in `<top (required)>'  
No examples found.


Finished in 0.00034 seconds (files took 0.23609 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

How can I fix this problem? 我该如何解决这个问题? Many Thanks!!! 非常感谢!!!

It means that Capybara is not available in your ruby on rails app. 这意味着Capybara在您的ruby on rails应用程序中不可用。 Look for a file called "Gemfile" inside your RoR app, and then look inside the Gemfile for a line that says: 在RoR应用程序中查找一个名为“ Gemfile”的文件,然后在Gemfile中查找以下内容:

gem 'capybara'

If you don't see it then you will need to add it. 如果没有看到,则需要添加它。 Once you've done that, go to the console, go to the root directory of your RoR app and run 完成此操作后,转到控制台,转到RoR应用程序的根目录并运行

bundle install

Once you've done that, in your test helper file you will need to add the line 完成此操作后,需要在测试帮助文件中添加以下行

require 'capybara/rails'

There is a lot of information about Capybara available on their github page located here: https://github.com/teamcapybara/capybara 在此处的github页面上有很多关于Capybara的信息: https : //github.com/teamcapybara/capybara

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM