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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
88276330f3a40ffe880081657b6003f6?d=identicon&s=25 Ken Mayer (Guest)
on 2009-04-24 06: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.

RAILS_ROOT
|-- 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):

...
  Cucumber::Rake::Task.new(:features) do |t|
    # t.cucumber_opts = "..."
    t.step_pattern = File.dirname(__FILE__) + "/features/**/*.rb"
    t.feature_pattern = File.dirname(__FILE__) + "/features/**/
*.feature"
  end

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
--
Ken Mayer / kmayer@bitwrangler.com / 808-722-6142 /
http://www.bitwrangler.com/
This topic is locked and can not be replied to.