Dmytrii Nagirniak
2012-Jun-28 23:59 UTC
Class is loaded twice when used with Rails.application.eager_load!
Hi, I am using the "faster_helper" to avoid loading the Rails (3.2.6) environment when I''m working on a single test file. So I often just declare dummy class (which in reality is AR model) like so: `class User; end` This gives me very fast test runs and no dependencies on Rails env. But when I run the full suite this behaviour is broken because Rails doesn''t autoload the User model since the class/constant has already been declared. The proposed solution was to call Rails.application.eager_load! somewhere before the specs are run. http://stackoverflow.com/questions/11133712/using-rails-model-that-is-already-declared And I do it this way: https://gist.github.com/3014807 The problem is that some of the classes that I require are loaded twice. Thus giving a warning like: warning: already initialized constant MIN_NO_CASH_FLOW_PERIODS It isn''t huge issue ATM, but it''s no good either. Is there anything you can see I am doing wrong? How can this be "fixed"? Cheers, Dmytrii http://ApproachE.com <http://www.ApproachE.com> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.