Spec_server not reloading model classes

On May 26, 2009, at 3:06 PM, Ben M. wrote:

It should be something like:
end
include AuthenticatedTestHelper
Tim and I work… So, there could very well be bugs we need to
Scott

Ok cool. Seems like the bug may of been poor documentation…
please send a pull request if you think it can be improved. :slight_smile:

BTW:

https://rspec.lighthouseapp.com/projects/5645-rspec/tickets

Scott

Scott T. wrote:

Spork seems to have the same problem that I have with spec_server:

end

Sweet! Seems to be working great now.

Looks like the README has changed over the weekend - previously, I had
been starting the spec server with script/spec_server. Running spork
directly seems to work just fine.

Thanks a TON!

Scott

Ok cool. Seems like the bug may of been poor documentation… please
send a pull request if you think it can be improved. :slight_smile:

-Ben

Ben J.,
Have you given up on this? You’re right - that defeats the purpose of
Spork. You need to make sure that any code that loads code in your
project
does not make it in to your Spork.prefork block. If you are
specifically
loading the models in your environment, that’s your problem.

Here’s some possible options to resolve what you’re experiencing:

  1. Add spork blocks to your environment.rb to put portions that are
    loading
    code you develop on inside of a Spork.each_run block, and the rest of it
    in
    a Spork.prefork block.

  2. modify your environment.rb file to only load libraries like gems and
    plug-ins, and set up autoload to load the rest of your classes as you
    need
    them. Alternatively, is this is a matter of pre-caching, you could
    choose
    not to load those classes preemptively in the test environment.

Ben J. wrote:

Did anyone ever figure out the factory_girl / machinist issues? I am
having the same problems and can figure out how to fix it for the life
of me. The first run works fine, then afterwards I get a bunch of these
errors:

No blueprint for class Venue

Any ideas? Thanks!

I found that using

load File.expand_path(File.dirname(FILE) + “/blueprints.rb”)

in the spec_helper.rb

did the trick.

Some plugins (like Thinking Sphinx) preload all the files in the app/
folder. You can see if this is the case by logging spork’s output to a
file and see what requested the app/* files to load.

spork -d > spork.log

More details can be found here:
http://upstream-berlin.com/2009/07/27/kickstart-rspec-with-spork

Hope it helps someone! It took me an hour to solve this :slight_smile:

Zach Powell wrote:

Ben J. wrote:

Did anyone ever figure out the factory_girl / machinist issues? I am
having the same problems and can figure out how to fix it for the life
of me. The first run works fine, then afterwards I get a bunch of these
errors:

No blueprint for class Venue

Any ideas? Thanks!

I found that using

load File.expand_path(File.dirname(FILE) + “/blueprints.rb”)

in the spec_helper.rb

did the trick.