rspec LoadError(Ruby on Rails,Michael Hartl的教程)

时间:2013-10-23 01:23:41

标签: ruby-on-rails ruby rspec

我已经搜索了我的问题,但无法在stackoverflow上找到它。发现类似的问题,但没有一个像我的。 我正在关注Hartl的ruby on rails教程,但是当我尝试使用rspec时,我会遇到这个问题:

harrisspec $ rspec spec/
/home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load': cannot load such file -- /home/harris/rails_projects/myapp/spec/spec (LoadError)
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `each'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load_spec_files'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:22:in `run'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:80:in `run'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:17:in `block in autorun'

尝试在应用程序文件夹的根目录中运行它(另一个线程说这会起作用)但没有骰子:

harris~ $ rspec spec/
/home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load': cannot load such file -- /home/harris/spec (LoadError)
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `each'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/configuration.rb:896:in `load_spec_files'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:22:in `run'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:80:in `run'
    from /home/harris/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:17:in `block in autorun'

我该如何解决这个问题?如果没有这个,我对继续学习这个教程感到不舒服,因为我不确定这对于开发应用程序有多重要。

提前致谢!!

1 个答案:

答案 0 :(得分:3)

第二次尝试引发的异常建议您从主目录运行它,而不是根应用程序目录。由于(推测)那里没有rspec目录,LoadError是有意义的。在第一次尝试时出现错误,正确的目录将是/home/harris/rails_projects/myapp

cd /home/harris/rails_projects/myapp
rspec spec/

试试。