我正在使用RSpec,我无法让RSpec在我的Ruby项目中工作。甚至没有在RSpec官方主页的“立即开始”部分提供的简单示例中:http://rspec.info/
所以我从官方示例中获取代码并创建bowling.rb和bowling_spec.rb。当我尝试从控制台运行rspec时:
rspec bowling_spec.rb --format nested
我得到了这个输出:
require': no such file to load -- bowling (LoadError)
from C:/.../Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/.../bowling_spec.rb:2:in `<top (required)>'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
from C:/.../Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'
我尝试使用Netbans 7.0.1以及Aptanda Studio 3在我自己的项目上运行RSpec。我总是得到同样的错误。宝石列表显示以下rspec宝石:
有人可以帮我吗?
答案 0 :(得分:1)
让它在Netbeans中运行的解决方案是手动安装Rspec,因为Netbeans没有RSpec Version 2支持:
gem install rspec -v 1.3.2
答案 1 :(得分:1)
对于子孙后代,我也遇到了这个问题,问题是我在gem中的非spec类中偶然require
'编辑spec_helper.rb
。 那很有趣。