简体   繁体   中英

RSpec can't find files when I run under Eclipse

When I run my rspec tests from the command line they work just fine. But when I try to run the same tests from within Eclipse (using DLTK) I get the following error:

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' 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: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 '

I assume I've not got it configured correctly, but I'm struggling to find anything useful online about how to configure it. Can anybody point me in the right direction to get it working?

Thanks.

According to comments here and here paste the following into spec_helper.rb at the top (tried with 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM