当我在Eclipse下运行时,RSpec无法找到文件

时间:2013-07-04 20:19:08

标签: ruby eclipse rspec dltk

当我从命令行运行我的rspec测试时,它们工作得很好。但是当我尝试从Eclipse中运行相同的测试(使用DLTK)时,我收到以下错误:

  

C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require': cannot load such file -- spec (LoadError) from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require'     来自C:/Users/Tim/.eclipse/org.eclipse.platform_4.3.0_1709980481_win32_win32_x86_64/configuration/org.eclipse.osgi/bundles/886/1/.cp/testing/dltk-rspec-runner.rb:12:in rescue in <main>' from C:/Users/Tim/.eclipse/org.eclipse.platform_4.3.0_1709980481_win32_win32_x86_64/configuration/org.eclipse.osgi/bundles/886/1/.cp/testing/dltk-rspec-runner.rb:3:in

我认为我没有正确配置它,但我很难在网上找到有关如何配置它的任何有用信息。有人能指出我正确的方向让它发挥作用吗?

感谢。

1 个答案:

答案 0 :(得分:1)

根据评论herehere将以下内容粘贴到顶部的spec_helper.rb(尝试使用Eclipse Kepler):

# Taken from a helpful comments:
# http://www.eclipse.org/forums/index.php/mv/msg/202462/846682/#msg_846682
# http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-testing-with-rspec/#comment-693919160
# RSpec needs the following lines to have it run from Eclipse Helios (or Kepler <ed: mE>)or Komodo Edit 7.0
version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'rspec-core', version
load Gem.bin_path('rspec-core', 'rspec', version)
# end of RSpec parameters