Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 269114 - RSpec runner broken for 1.2.0
Summary: RSpec runner broken for 1.2.0
Status: RESOLVED FIXED
Alias: None
Product: DLTK
Classification: Technology
Component: Ruby (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.0M7   Edit
Assignee: dltk.ruby-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-17 20:32 EDT by Tobias Grimm CLA
Modified: 2009-05-08 01:51 EDT (History)
2 users (show)

See Also:


Attachments
dltk-rspec-runner.rb fix for RSpec 1.2.2 (3.00 KB, patch)
2009-03-24 20:21 EDT, Tobias Grimm CLA
no flags Details | Diff
Fixes for RSpec >= 1.1.12 (4.20 KB, patch)
2009-03-28 08:03 EDT, Tobias Grimm CLA
no flags Details | Diff
RSpec runner bugfixes for RSpec up to 1.2.4 (4.85 KB, patch)
2009-04-19 10:29 EDT, Tobias Grimm CLA
alex.panchenko: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Grimm CLA 2009-03-17 20:32:41 EDT
Build ID: M20090211-1700

Steps To Reproduce:
1. Install latest RSpec 1.2.0 (http://rspec.info/)
2. Create a spec
3. Run the spec

Result: 

/home/tobias/opt/eclipse/configuration/org.eclipse.osgi/bundles/393/1/.cp/testing/dltk-rspec-runner.rb:364: uninitialized constant Spec::Extensions (NameError)



More information:
Comment 1 Tobias Grimm CLA 2009-03-20 14:37:56 EDT
Just a small update:

RSpec 1.1.12 and 1.2.0 have a small issue, which breaks the way RSpec is used by the DLTK,

This will be fixed in 1.2.1 over the weekend (see [1]).

I've already tested it and with a slighlty modified dltk-rspec-runner.rb it works fine with versions 1.1.3 - 1.1.11 and 1.2.1.

I'll post a patch as soon as the final 1.2.1 of RSpec is released.

[1]: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/738-regression-in-specexampleexamplemethodsexecute-behavior-in-rspec-120#ticket-738-23
Comment 2 Tobias Grimm CLA 2009-03-24 20:21:09 EDT
Created attachment 129782 [details]
dltk-rspec-runner.rb fix for RSpec 1.2.2

Ok, RSpec 1.2.2 has been released now, and I've attached a patch for dltk-rspec-runner.rb

It works for versions 1.1.3 - 1.1.11 and 1.2.1 - 1.2.2 of RSpec. (RSpec 1.1.12 and 1.2.0 are broken!)

The patch is as least intrusive as possible, but I would suggest to drop support for RSpec < 1.2.2 in favor of a complete refactoring of dltk-rspec-runner.rb. If this would be ok, let me know I would be volunteering for it.
Comment 3 Alex Panchenko CLA 2009-03-24 23:08:53 EDT
Hi Tobias,

Thank you for the patch. I will check it and apply after that.

The only question I have is related to the examples_to_run method. It was used if the rspec was started with a filter, e.g. during 'Rerun failed tests' action.

Ideally we should also have the check for version == 1.2.0 and stop execution since this particular version does not work.

Regards,
Alex
Comment 4 Tobias Grimm CLA 2009-03-25 05:44:37 EDT
Version 1.2.2 was released only 7 days after 1.2.0. It's highly unlikely anyone will use this version. But checking the version doesn't hurt. It's only a one-liner:

raise "RSpec 1.2.0 is not supported, please update RSpec" if ::Spec::VERSION::STRING == '1.2.0'

As for your question about examples_to_run: RSpec now only passes ExampleProxy and ExampleGroupProxy to the formatters, where no examples_to_run is available. ExampleGroupProxy will only provide a list of all examples from the group, not just the ones that would be run.

The cleanest solution might be to modify RSpec itself. Another way to do this would be to do --dry-run to build the example tree in a first run and then run the examples in a second run.

The easiest way would be to move the creation of the test nodes to example_started(). But this doesn't work, because I don't know the number of tests in a group, when creating the group node.

What do you think? Shall I try the --dry-run approach or shall I provide a patch for RSpec and wewait for 1.2.3?

Another solution might be to change the Java part to simply hide tests that were not run when doing a 'Rerun failed tests'.

Tobias
Comment 5 Tobias Grimm CLA 2009-03-25 06:12:51 EDT
PS: I think with a small amount of monkey patching, ExampleGroupProxy can be extended to provide the filtered list of examples. This can then be pushed upstream. Might be the best solution, I'll try it this way and provide a patch.
Comment 6 Alex Panchenko CLA 2009-03-25 06:21:43 EDT
My suggestion is to modify RSpec.
It would make their API more complete, ExampleGroupProxy would have different methods to return all tests and the tests which are to be executed.
Comment 7 Tobias Grimm CLA 2009-03-28 08:03:46 EDT
Created attachment 130160 [details]
Fixes for RSpec >= 1.1.12

Adding an examples_to_run to the ExampleGroupProxy doesn't really fit into RSpec.

I solved this issue by pulling the filtering of examples into the formatter. This is backwards compatible and doesn't require any nasty RSpec hacks or monkey patching

Here's a new patch. I've tested it with all released versions from 1.1.4 (the oldest available in the RSpec Git) up to 1.2.2. Only 1.2.0 doesn't work, but this release became only 7 days old, before 1.2.1 was released.

The "run all examples" as well as the "run failed examples" now works fine.

There's just one minor issue: For nested descriptions, DLTK is unable to jump from the example group to the source code. But this is no regression - it never worked for nested descriptions and therefore I suggest to ignore this for now and fix it later. I'll open a new bug for this, as soon as this one is closed.
Comment 8 Tobias Grimm CLA 2009-04-19 10:29:49 EDT
Created attachment 132346 [details]
RSpec runner bugfixes for RSpec up to 1.2.4

I've updated the patch for RSpec 1.2.2.1, 1.2.3 and 1.2.4
Comment 9 Alex Panchenko CLA 2009-05-06 06:28:22 EDT
Committed to HEAD, will be included in DLTK 1.0 M7 release