Forum: RSpec [Cucumber, Rails] Load path hell with plugins /extensions

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ken Mayer (Guest)
on 2009-04-24 08:59
(Received via mailing list)
I discovered this while debugging a RadiantCMS extension:

cucumber uses 'require' to load step definitions, _and_ since I loaded
the rails environment (in features/support/env.rb) for testing, _and_
radiant necessarily adds extensions to the load path, the path to
_every_ extension in your project is added to $LOAD_PATH ($:) -- and,
it is a sorted list (items are not queued).

Imagine the fun when you try to load 'features/support/paths.rb' only
to discover (after single stepping through a lot of code) that it
required an identically named file, but from a completely different
project. DLL hell.

e.g. Given this tree, trying to run 'rake spec:features' in .../
data_manager pulls in files from .../citations first because it is
lexically before it.

|-- config
|   `-- environments
`-- vendor
     |-- extensions
     |   |-- citations
     |   |   |-- Rakefile
     |   |   |-- features
     |   |-- data_manager
     |   |   |-- Rakefile
     |   |   |-- features
     `-- radiant
         |-- features
         |   |-- admin
         |   |-- step_definitions
         |   `-- support

I'm not sure what the solution is, but for now, if you modify your
extension Rakefile to include the following (prepend the patterns with
the current directory):

... do |t|
    # t.cucumber_opts = "..."
    t.step_pattern = File.dirname(__FILE__) + "/features/**/*.rb"
    t.feature_pattern = File.dirname(__FILE__) + "/features/**/

Please note: I'm getting deprecation warnings, in 3.0, about using
these accessors, but the command line options are not yet available.

Aloha a hui hou,
Ken Mayer / removed_email_address@domain.invalid / 808-722-6142 /
This topic is locked and can not be replied to.