Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325971 - RSpec runner broken if RSpec 2.0.0 installed
Summary: RSpec runner broken if RSpec 2.0.0 installed
Status: CLOSED WONTFIX
Alias: None
Product: DLTK
Classification: Technology
Component: Ruby (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: dltk.ruby-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-22 10:56 EDT by John-Mason P. Shackelford CLA
Modified: 2020-01-03 07:58 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John-Mason P. Shackelford CLA 2010-09-22 10:56:12 EDT
Build Identifier: 20100617-1415

When RSpec 2.0.0 is installed, the DLTK Script Runner always fails with the error:

C:/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate rspec (= 1.3.0, runtime) for [], already activated rspec-2.0.0.beta.22 for [] (Gem::LoadError)
	 from C:/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
	 from C:\Documents and Settings\shacjo\My Documents\work\eclipse-3.6\configuration\org.eclipse.osgi\bundles\751\1\.cp\testing\dltk-rspec-runner.rb:12

When I debug and configure debugging to break on the first line, I start on line 1 dltk-rspec-runner.rb so I can't figure out what could be activating rspec-2.0.0.beta.22. DTLK doesn't specifically ask for 1.3.0, but 1.3.0 is the most recent, non-beta version I have installed. While rspec 2.0 is still in beta, it is required for RSpec testing in Rails 3.0 so uninstalling it is not a good option--though it does solve the problem.

Dynamic Languages Toolkit - Core Frameworks	2.0.0.v20100518

Reproducible: Always

Steps to Reproduce:
1. Install JRuby 1.5.1
2. Run an RSpec test via DLTK test runner to demonstrate that the test runner works.
3. jruby -S gem install rspec -v 2.0.0.beta.20
4. Re-reun the RSpec test and look for the error above in the console output.


I would be very grateful for work-around ideas since this will impact everyone on my team.
Comment 1 David Chelimsky CLA 2010-09-26 12:00:07 EDT
RSpec-2's architecture supports extensions through hooks and mixins rather than subclassing or monkey patching RSpec's internals. The good news is that future RSpec releases will be able to support backward compatibility to RSpec-2 without being bound to structure. The bad news is that RSpec-2's structure has changed quite radically from RSpec-1, so extensions like that in dltk-rspec-runner.rb are not compatible with RSpec-2.

To resolve this issue, we'll need to figure out a way to identify the version of RSpec that an Eclipse user wants to use in each project, and then load the appropriate hooks based on that choice. I am not an eclipse user myself, so I don't know how this would work from a UX perspective or internally, but I am more than happy to work with you to ensure that the RSpec-2 support is using documented APIs that won't break compatibility in future releases. I'm also happy to establish new APIs if there are things RSpec-2 can do to make this sort of extension easier.

Sound like a plan?
Comment 2 John-Mason P. Shackelford CLA 2010-09-28 13:15:17 EDT
By inserting lines as below into dltk-rspec-runner.rb, I get past the problem with the install of 2.0.0.beta breaking runner for 1.6.0. Seem that while the first require was throwing LoadError, it had still activated the rspec-2 gem so that rspec-1 could not be activated below. (I had previously tried to activate the 1.6.0 gem in the rescue block but 2.0.0 had already been activated.)

+ # -- Hack --
+ require 'rubygems'
+ gem 'rspec', '1.3.0'
+ require 'spec'
+ # -----------

require 'socket'

begin
  # ssanders: Try to load RSpec based on the LOADPATH, this allows
  #           projects (e.g. Rails) to provide alternate versions via the buildpath
  require 'spec'
rescue LoadError
  # ssanders: Fallback to loading from the Gem
  require 'rubygems'

  gem 'rspec'
  require 'spec'
end


In Response to David Chelimsky's comment, I believe DLTK-Ruby already has the concept of a selectable testing engine in the UI. It currently has engines for Test::Unit and RSpec-1, so if we can find a better approach to fixing the problem with inadvertently loading the beta GEM in the current runner, we could just add a seperate RSpec runner for RSpec-2.
Comment 3 Alex Panchenko CLA 2010-09-29 05:44:35 EDT
Hi all,

I have some questions regarding this issue:

1. Is rspec-2 compatible with rspec-1? 

I want to understand if it makes sense for the user to select the correct version of the runner manually, or should we use the greatest version installed and automatically run the correct code?

2. Regarding the workaround

Do you think it will work in the following way: gem 'rspec', '< 2.0'

Regards,
Alex
Comment 4 Giovanni Degani CLA 2011-04-16 15:14:02 EDT
(In reply to comment #3)
> 1. Is rspec-2 compatible with rspec-1? 

From what David comment above:
"The bad news is that RSpec-2's structure has
changed quite radically from RSpec-1, so extensions like that in
dltk-rspec-runner.rb are not compatible with RSpec-2."

So I think that is not compatible.
Comment 5 Dawid Pakula CLA 2020-01-03 07:58:24 EST
Ruby support has been removed.