2

当我从命令行运行我的 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:inrequire' 来自 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'

我假设我没有正确配置它,但我很难在网上找到任何关于如何配置它的有用信息。有人可以指出我正确的方向以使其正常工作吗?

谢谢。

4

1 回答 1

1

根据此处此处的评论,将以下内容粘贴到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
于 2013-08-28T15:50:36.953 回答