Closed duff closed 13 years ago
Find out what is preloading your models
spork -d | less
Factory girl is likely loading your factories during preload, and those your models. Therefore your models will be cached from session to session.
(Can you tell factory girl to load factories in the each_run block?)
I'll try that again. Thanks Tim!
It's a strange one - the word model doesn't appear in the -d. Nor does the word factory. Or factories.
I see this:
- Spork Diagnosis -
-- Summary --
config/application.rb
config/boot.rb
config/environment.rb
config/initializers/inflections.rb
.. the rest of the initializers
config/routes.rb
features/support/env.rb
And then there's a bunch of detail below there.
Should I see any of the models mentioned? Just trying to figure out how to use the diagnose flag. Thanks again!
I've got the same issue. But it doesn't happen only to my models; my controllers and helpers are affected as well.
Running spork -d:
-- Summary --
config/initializers/backtrace_silencers.rb
config/initializers/barista_config.rb
config/initializers/compass.rb
config/initializers/devise.rb
config/initializers/differ.rb
config/initializers/dragonfly.rb
config/initializers/haml.rb
config/initializers/inflections.rb
config/initializers/mime_types.rb
config/initializers/secret_token.rb
config/initializers/session_store.rb
config/initializers/simple_form.rb
config/initializers/vestal_versions.rb
config/routes.rb
spec/spec_helper.rb
Using Spork 0.8.4, Rails 3.0.4, RSpec 2.5, and it happens with both Ruby 1.8.7 and 1.9.2, on Ubuntu 10.10. My prefork block is as follows:
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
end
Forgot to say that I'm not using Mongo and I've already tried the devise trap.
I'll look into it during the weekend; after seeing another similar issue it looks like this information if far from enough.
I really would recommend that you use Spork 0.9.0 RC 3. Spork 0.8.4 was not intended to be used with rails 3. I don't believe it will work, at all. (See the README file for the latest Spork)
I am using Spork successfully with Ruby 1.9.2 and the latest version of rails. Everything is behaving exactly as I expect. I'm using MongoID. The integration tests in Spork test to make sure that active record models do in fact reload as expected. Therefore, I am inclined to suspect that your problem is one of the following:
Upgrading to 0.9.0.RC 3 works fine. Thanks!
Now that you mention it... could you clarify the README at least until you release version 0.9.0? If you just follow the instructions, version 0.8.4 gets installed. And I guess if I misunderstood the version requirement for rails 3 in that line, somebody else could misunderstand it as well... of at least I hope so ;).
Thanks for all of the help everyone! Here's what worked for me:
Updating to the Spork 0.9.0.rc3 like Tim suggested. And then:
In the Gemfile: gem "factory_girl_rails", :require => false
In the features/support/env.rb: Spork.each_run do require 'factory_girl_rails' ... end
Somewhere in the spec_helper/test_helper: require 'factory_girl_rails'
Actually with the latest mongoid, the culprit is the Mongoid:
..snip...
/opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.0.0.rc.7/lib/rails/mongoid.rb:15:in load_models' /opt/ruby/lib/ruby/gems/1.9.1/gems/mongoid-2.0.0.rc.7/lib/mongoid/railtie.rb:88:in
block (2 levels) in class:Railtie'
...snip...
I think that I got away by declaring a global variable:
$rails_rake_task = true
(mongoid Railtie checks it)
I've written a wiki entry on this: https://github.com/timcharper/spork/wiki/Troubleshooting
On Aug 19, 2011, at 12:40 AM, FooBarWidget wrote:
I've written a wiki entry on this: https://github.com/timcharper/spork/wiki/Troubleshooting
Reply to this email directly or view it on GitHub: https://github.com/timcharper/spork/issues/83#issuecomment-1848668
Thank you FooBarWidget!
Hi all,
I've seen some tickets referencing this and I haven't been able to find a good solution. I've got a Rails 3 app using Factory Girl and the models aren't getting reloaded.
Might anyone happen to know a good workaround?