sporkrb / spork

A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state.
spork.rubyforge.org
MIT License
1.4k stars 202 forks source link

Mongoid Models not reloading #105

Closed subdigital closed 13 years ago

subdigital commented 13 years ago

I read this: https://github.com/timcharper/spork/wiki/Spork.trap_method-Jujutsu

and figured it would answer my problems. Basically I'm running guard-spork to reload spork for env changes, and guard-rspec to automatically run my spec when it (or the related model file) change.

But if I change the model file, the change is not picked up, thus the test incorrectly reports pass/failure for various specs that depend on the changed behavior.

I have the following in my Spork.prefork block:

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'

  require 'rails/mongoid'
  Spork.trap_class_method(Rails::Mongoid, :load_models)
  require 'rails/application'
  Spork.trap_method(Rails::Application, :reload_routes!)

  # Now load our environment
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  ...

Is there something else I need to be doing, perhaps in the each_run block, to make sure my models are reloaded?

subdigital commented 13 years ago

Ugh, nevermind. This was my own stupidity. Triple checked this was really an issue, but it turns out I had a typo, so my models weren't being called at all.