# Engines bug breaks functional tests with datetime\_toolbocks

**URL:** <https://www.ruby-forum.com/t/engines-bug-breaks-functional-tests-with-datetime-toolbocks/107371>\
**Category:** Engines Development\
**Created:** [June 20, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/engines-bug-breaks-functional-tests-with-datetime-toolbocks/107371 "2007-06-20T23:35:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geoff\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/58f4c7/32.png) [@Geoff\_D](https://www.ruby-forum.com/u/Geoff_D)\
**Post date:** [June 20, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/engines-bug-breaks-functional-tests-with-datetime-toolbocks/107371/1 "2007-06-20T23:35:49Z")

</div>

This is following up on [http://lists.toolbocks.com/pipermail/](http://lists.toolbocks.com/pipermail/)  
toolbocks-user/2007-May/000027.html  
(datetime\_toolbocks fails in functional tests)

Here’s the problem:

Engines causes plugins to be loaded in 2 phases. First plugins that  
don’t depend on engines are loaded. Then Rails does some  
initialization. Then Engines patches Rails. Then the remaining  
plugins get loaded.

After all that is done, Engines’ modifications of dependencies.rb  
will cause a subsequent load of application\_helper to be patched by  
application\_helper files in plugins. All well and good in  
development and production mode.

The trouble comes in test mode: the file ~rails/lib/test\_help.rb gets  
loaded during Rails’s initialization, before the engines plugins.  
test\_help.rb requires application.rb, which in turn loads  
application\_helper.rb. Because the engines plugins haven’t been  
loaded yet, application\_helper.rb is unpatched, and  
datetime\_toolbocks’s methods are unavailable to functional tests.

It looks like there is a related bug in the engines repository:  
[http://dev.rails-engines.org/engines-plugin/tickets/16](http://dev.rails-engines.org/engines-plugin/tickets/16)

A nasty fix is to copy ~rails/lib/test\_help.rb to your project’s lib  
directory and then add the following two lines right before the call  
to require\_dependency ‘application’

require ‘engines’  
Engines.after\_initialize

(Engines.after\_initialize loads the extra plugins)

Geoff

---

<div class="post-metadata">

**Author:** ![Geoff\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/58f4c7/32.png) [@Geoff\_D](https://www.ruby-forum.com/u/Geoff_D)\
**Post date:** [June 21, 2007, 12:37am UTC](https://www.ruby-forum.com/t/engines-bug-breaks-functional-tests-with-datetime-toolbocks/107371/2 "2007-06-21T00:37:55Z")

</div>

Hi Geoff,

Thanks for the thorough investigation. The first thing I’d do here  
would be to open a new ticket (or reopen Ticket #16) and post your  
findings there. Then we can start looking at how to fix this issue in  
the test environment.

James
