[rspec-devel] [ rspec-Feature Requests-10814 ] Runner loads shared code, test cases require them again

noreply at rubyforge.org noreply at rubyforge.org
Wed May 16 01:00:43 EDT 2007


Feature Requests item #10814, was opened at 2007-05-13 23:03
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=10814&group_id=797

Category: runner / command line
Group: None
Status: Closed
Priority: 3
Submitted By: Assaf Arkin (assaf)
Assigned to: David Chelimsky (dchelimsky)
Summary: Runner loads shared code, test cases require them again

Initial Comment:
Our test directory contains one file that provides methods and behaviores shared by all other test files. To run individual files, each one requires that shared file. 

However, when running spec test, RSpec loads all the files from the test directory (and its sub-directories). So the file gets loaded once (by RSpec) and required once (by the test files), and interpreted twice (by Ruby). Some of the code doesn't like that.

The current workaround is to detect the second load and ignore it (e.g. unless defined?(SomeConst)). But given the amount of time it took to find the culprit and work around it, can RSpec require the file instead, or allow a directory of shared behaviors not loaded by default?

----------------------------------------------------------------------

>Comment By: Assaf Arkin (assaf)
Date: 2007-05-16 05:00

Message:
Thanks!

Assaf

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-16 03:35

Message:
No reason. Fixed in r1958.

----------------------------------------------------------------------

Comment By: Assaf Arkin (assaf)
Date: 2007-05-16 02:21

Message:
More pain than it's worth. I'm going to have to explain to
every developer how to properly run the test cases, they're
of course not going to RTFM, so their first attempt will
fail miserably. And with each project deciding to exclude a
different file ...

Is there a particular reason for RSpec to use load instead
of require?

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-16 00:35

Message:
How about an "exclude" command line option?

spec spec --exclude spec/shared.rb

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=10814&group_id=797


More information about the rspec-devel mailing list