Forum: Ruby on Rails Constants defined in initializer not found when running gems:install in test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tobi (Guest)
on 2009-04-23 23:39
(Received via mailing list)
Dear all,

I am setting some constants in an initializer, which are used in
validations in my models.
When I run

  RAILS_ENV=test rake gems:install

I get missing constant errors for these, but not when I run

  RAILS_ENV=development rake gems:install

It only happens for the gems:install task in test.
Everything else (e.g. rake test) works as expected.
What could be the problem?

Thanks for your help

Tobi
Matt J. (Guest)
on 2009-04-25 03:42
(Received via mailing list)
The problem you ran into was the same one as this thread:

http://groups.google.com/group/rubyonrails-talk/br...

and both are caused by load_application_classes trying to load all
your models at startup. That routine does nothing when
config.cache_classes is false (the default in development mode, but
not in test).

As a quick workaround, try setting config.cache_classes to false in
environments/test.rb to get the gems installed.

--Matt J.
This topic is locked and can not be replied to.