I seem to be having a dependency issue when running my test while applying a mixin implemented by an engine into my Application controller. I found a work around but wanted to post the problem, cause and workarounds in hope that a solution can be put into the Engines plugin. Let me break it down: 1. I define a mix in my engine under lib/my_engine/foo.rb. We'll call the mixin MyEngine::Foo. 2. I then put the following in my application controller to apply the mixin to all controllers: class ApplicationController < ActionController::Base include MyEngine::Foo end 3. Running this program seems to work fine 4. When I run my testing it cannot seem to find the module MyEngine::Foo I have traced the problem to the following: 1. My test_helper.rb in my engine has the following for the first line: require File.expand_path(File.join(File.dirname(__FILE__), '/../../../../test/test_helper')) as suggested by the documentation. 2. This requires the environment which of course starts the process of booting Rails. 3. When loading the "engine" plugin is loading it requires the testing extensions. 4. The testing extensions require 'test_help' provided by Rails. 5. 'test_help' in requires 'application'. This loads my ApplicationController class. 6. My ApplicationController tries to include my mixin but it cannot find the module because my engine has not initialized yet (since it comes after the engine plugin alphabetically). Hence leading to my problem. Workarounds: 1. Make the "engines" plugin load after the problem plugin 2. Comment out the "require 'test_help'". It is not necessary anyway since the test_helper generated by rails requires it later.
on 2007-03-03 01:09
on 2007-09-26 01:10
Tom W. recently committed this change to the 1.2 release branch, which can be grabbed from http://svn.rails-engines.org/engines/branches/rb_1.2 ... which means it'll be in the next release. Cheers, James
on 2007-09-26 01:12
Excellent! Thanks Tom!