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


#1

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 / removed_email_address@domain.invalid / 808-722-6142 /
http://www.bitwrangler.com/