[rspec-users] [Cucumber, Rails] Load path hell with plugins /extensions

Ken Mayer lists at bitwrangler.com
Thu Apr 23 11:19:30 EDT 2009

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

  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/**/ 

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 / kmayer at bitwrangler.com / 808-722-6142 / http://www.bitwrangler.com/

More information about the rspec-users mailing list