2

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

digitig
  • 1,989
  • 3
  • 25
  • 45
  • Same on Ubuntu 13.04, Eclipse Juno Service Release 2, with local installation of Dynamic Languages Toolkit - Ruby Development Tools 5.0.0.201306060709 org.eclipse.dltk.ruby.feature.group – WaffleSouffle Jul 31 '13 at 15:58

1 Answers1

1

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
WaffleSouffle
  • 3,293
  • 2
  • 28
  • 27
  • Where do I add this code (That is where is the spec_helper.rb) ? I came to your post from here - https://stackoverflow.com/questions/27222647/running-rspec-examples – Erran Morad Dec 01 '14 at 06:43
  • I believe `spec_helper.rb` is a Rails thing, included by all Rails tests, thus makes a good place for RSpec config. I'd just try sticking it in any file your Eclipse RSpec is executing, or taking a page from Rails's book and including a certain setting file in all of your tests. – Amadan Dec 01 '14 at 06:58
  • @Amadan - Please tell me where to put the code. I just tried my luck and put it in 'C:\Ruby\lib\ruby\site_ruby\1.8\rubygems\custom_require.rb'. Now, rspec/expectations cannot be loaded error is happening. – Erran Morad Dec 01 '14 at 07:05
  • No, not `custom_require.rb`. Just... top of your file. The file with your tests. And if it doesn't work, remember, I can't test anything, as I don't have Eclipse environment. – Amadan Dec 01 '14 at 07:07