Search code examples
ruby-on-railsruby-on-rails-3rspecsporkguard

Spork doesn't reload code


I am using following gems and ruby-1.9.3-p194:

  • rails 3.2.3

  • rspec-rails 2.9.0

  • spork 1.0.0rc2

  • guard-spork 0.6.1

Full list of used gems is available in this Gemfile.lock or Gemfile.

And I am using this configuration files:

If I modify any model (or custom validator in app/validators etc) reloading code doesnt works.

I mean when I run specs (hit Enter on guard console) Spork contain "old code" and I got obsolete error messages. But when I manually restart Guard and Spork (CTRC-C CTRL-d guard) everything works fine. But it is getting tired after few times.

Questions:

Can somebody look at my config files please and fix error which block updating code.

Or maybe this is an issue of newest Rails version?


PS This problem repeats and repeats over some projects (and on some NOT). But I haven't figured out yet why this is happens.

PS2 Perhaps this problem is something to do with ActiveAdmin? When I change file in app/admin code is reloaded.


Solution

  • Workaround:

    # config/environments/test.rb
    config.cache_classes = false
    

    But it is "double-edged sword".

    Specs run now ~2.0x time longer. But it is still faster than restarting again and again Spork.


    Update 28.06.2013

    Use Zeus. It works perfectly. Benchmarks are at the bottom..

    If you are using 1.9.3 consider installing special patches which REALLY speed up loading app.

    RVM patchsets

    rbenv instructions

    Background & Benchmark:

    I have a quite large 1.9.3 app and I wanted to speedup app loading, Spork doesn't work so I started looking for other solutions:

    I write a empty spec to see how long it takes to load my app

    -/spec/empty_spec.rb

    require 'spec_helper'
    
    describe 'Empty' do
    
    end
    

    plain 1.9.3

    time rspec spec/empty_spec.rb 64,65s user 2,16s system 98% cpu 1:07,55 total

    1.9.3 + rvm patchsets

    time rspec spec/empty_spec.rb 17,34s user 2,58s system 99% cpu 20,047 total

    1.9.3 + rvm patchsets + zeus

    time zeus test spec/empty_spec.rb 0,57s user 0,02s system 58% cpu 1,010 total [w00t w00t!]