2

我正在按照本教程开发一些 Ruby on Rails 应用程序。http://ruby.railstutorial.org/chapters/static-pages#sec-TDD

我已经创建了..._spec.rb文件。

但是当我运行命令时-bundle exec rspec spec/requests/static_pages_spec.rb

有一个错误 -require: cannot load such file -- nokogiri (LoadError).

谁能帮我?

完整的错误信息:

/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'
4

2 回答 2

3

解决这个问题的最简单方法是手动更新 capybara 包,它解决了我的问题。“捆绑更新水豚”

于 2012-11-26T09:07:25.057 回答
0

就我而言,如果我没有 Gemfile,则会自动定位 gem,但是一旦我创建了一个空文件,我就需要包含 nokogiri 和其他 gem。希望这可以帮助。

于 2013-12-30T19:27:47.040 回答