我真的很想学习Ruby,RoR和正确的BDD,并开始学习Rspec。我正在编写代码学校的Rspec教程(以及Nettuts的Rspec教程和其他一些教程)。每次我尝试让Rspec运行时,我都会遇到以下错误。我用谷歌搜索了大部分的线条,看看我需要编辑什么,甚至连天堂都变得更加困惑!我搜索了线程,卸载了RVM并重新安装了RVM,在项目文件夹中安装了rspec gem,当我按照各种方法时,我无法通过第一步看到测试失败!在这个问题上,我正在疯狂。我想学习并想知道是否有人可以就我的白痴noob问题给我一些反馈。是的我是一个愚蠢的菜鸟,但我想弄清楚这一点。
rspec /home/username/Desktop/zombie/spec/lib/zombie_spec.rb
/home/mike/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- spec_helper (LoadError)
from /home/username/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/username/Desktop/zombie/spec/lib/zombie_spec.rb:1:in `<top (required)>'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
from /home/username/.rvm/gems/ruby-2.2.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
from /home/username/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `load'
from /home/username/.rvm/gems/ruby-2.2.0/bin/rspec:23:in `<main>'
from /home/username/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
from /home/username/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
非常感谢。 另一个新手菜鸟只是试图理解Ruby和rspec .. mcsmythe
答案 0 :(得分:2)
尝试cd进入/ home / username / Desktop / zombie并从那里运行你的规范:
rspec spec/lib/zombie_spec.rb
你也跑了:
rspec --init
在那个目录中?这将为您创建spec_helper。
答案 1 :(得分:0)
看起来rspec无法找到spec_helper.rb文件。你偶然看过this question吗?另外,请遵循ruby惯例并确保所有规格都在specs文件夹中,例如spec_helper的路径应该是specs / spec_helper.rb而不是lib / spec_helper.rb。您是否尝试过使用require_relative而不是require?