简体   繁体   中英

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

repository: 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.

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. Look for a file called "Gemfile" inside your RoR app, and then look inside the Gemfile for a line that says:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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