I'm using the following trick (from http://mikbe.tk/2011/02/10/blazingly-fast-tests/) to ensure models get reloaded on each RSpec run with Spork:
Spork.each_run do
load "#{Rails.root}/config/routes.rb"
Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
# .....
end
However it causes the following warnings every time I run my tests:
/myproject/app/models/model.rb:36: warning: already initialized constant CONFIGURABLE
Which I can avoid by putting:
if !defined?(A_CONSTANT)
after every constant, which doesn't really look right (but it works). Any suggestions on how I can make this work properly? (i.e. my models will still re-load in tests, but I don't have to put the if
after every constant definition.)