I have a problem when running all of my specs.
ActiveRecord::AssociationTypeMismatch: Affiliate(#2154746360) expected, got Affiliate(#2199508660)
It would appear that my models are being loaded twice.
I have isolated the problem to be introduced with Rack::Test's requirement to define an "app" method.
require 'rack/test'
include Rack::Test::Methods
# app method is needed for rack-test
def app
Rails.application
end
If I comment out Rails.application
my rack specs do not work, but all of my other specs work fine. The use of Rails.application
in the "app" method introduces the error above.
If I run my specs individually, everything works. I am preloading my environment with Spork and I think that the models are loaded first by Spork and then they are redefined when Rails.application
is called in my "app" method.
Any ideas on how I can resolve this problem? I am not sure if there is another way to set my Rails app in the "app" method.