简体   繁体   中英

RoR Test Driven Development - `require': cannot load such file -- nokogiri (LoadError)

I am folowing this tutorial to develop some Ruby on Rails application. http://ruby.railstutorial.org/chapters/static-pages#sec-TDD

I have created ..._spec.rb file.

but when I run command - bundle exec rspec spec/requests/static_pages_spec.rb

There is an error - require: cannot load such file -- nokogiri (LoadError).

Can anyone help me?

Full error message:

/home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/capybara-2.0.1/lib/capybara.rb:2:in `require': cannot load such file -- nokogiri (LoadError)
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/capybara-2.0.1/lib/capybara.rb:2:in `<top (required)>'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `block in require'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
from /home/karlis/workspace/sample_app/config/application.rb:13:in `<top (required)>'
from /home/karlis/workspace/sample_app/config/environment.rb:2:in `require'
from /home/karlis/workspace/sample_app/config/environment.rb:2:in `<top (required)>'
from /home/karlis/workspace/sample_app/spec/spec_helper.rb:3:in `require'
from /home/karlis/workspace/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
from /home/karlis/workspace/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
from /home/karlis/workspace/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/configuration.rb:784:in `load'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/configuration.rb:784:in `block in load_spec_files'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/configuration.rb:784:in `each'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/configuration.rb:784:in `load_spec_files'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:22:in `run'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:69:in `run'
from /home/karlis/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:8:in `block in autorun'

The easiest way to solve this problem is manually updating the capybara bundle, it solved my problem. "bundle update capybara"

In my case, if I don't have a Gemfile, the gems are located automatically, but as soon as I made an empty one, I needed to include nokogiri and other gems. Hope this helps.

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