Hello,
i've an initializer which set as constants all the instances retrieved
from the DB, for specific AR models.
Thoose constant are used a bit everywhere in the application.
In my unit test, I run the initializer top preload my "dynamic
constants" in the setup method of the test class. The setup method call
a method in the test_helper class, as follows :
require File.dirname(__FILE__) + '/../test_helper'
class StatusTest < ActiveSupport::TestCase
setup :preload_constants_from_db
(...)
end
In the test_helper file I got the method preload_constants_from_db,
which require the initializer.
def preload_constants_from_db
require File.expand_path(File.dirname(__FILE__) +
"/../config/initializers/constant_cache")
end
Run separately the test works great :
mac:trunk nico$ ruby test/unit/status_test.rb
Loaded suite test/unit/status_test
Started
....
Finished in 0.955416 seconds.
4 tests, 5 assertions, 0 failures, 0 errors
mac:trunk nico$ ruby test/unit/status_test.rb
Loaded suite test/unit/status_test
Started
....
Finished in 0.958518 seconds.
4 tests, 5 assertions, 0 failures, 0 errors
But run whith rake everything fails :
rake test:units
=> BOUM
Any idea how to proceed ??
PS: Sorry for the approximative english...
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---