Mac OSX 10.7.2,
关注rails教程并在以下情况下出现错误:
rspec spec/
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- spec_helper (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/lasernite/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb:1
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `autorun'
from /usr/bin/rspec:19
我不知道如何解决这个问题,但真正的问题不是这个特定的问题(尽管它是一个)但是无法解决这些类型的问题。是否有任何疑难解答资源,我可以学习阅读这样的反馈,因为我无法真正理解这种语法来找出问题所在。
这是我的gemfile的样子,它可能太过于裸露,因为我删除了一些我认为会产生兼容性问题的东西。
来源'http://rubygems.org'
gem 'rails', '~> 3.0.0'
gem 'sqlite3-ruby', '~> 1.2.5', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '~> 2.0.1'
end
group :test do
gem 'rspec', '~> 2.0.1'
gem 'webrat', '~> 0.7.1'
end
答案 0 :(得分:1)
这里真正的错误是“没有这样的文件要加载 - spec_helper”(异常消息的第一行。你有一个试图加载“spec_helper”的rspec文件,它不存在。
解决这个问题:
bundle exec rails generate rspec:install
这将为您创建spec_helper文件。