Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT:</strong> If you can upgrade to Ruby 2.0 this is your best bet. It is fast enough and will let you work in regular way without the need for tools like Spork, Zeus, and ect. And in essence you won't need anything I wrote below. </p> <p>If you still need some speed bump while developing check out the <a href="http://railscasts.com/episodes/412-fast-rails-commands" rel="nofollow">Fast Rails Commands</a> cast.</p> <hr> <p>Well yes, you want to reload Spork if you changed environment, initializer or spec_helper files (and for that guard-spork is perfect), but not when you updated one of your classes (models) as this would deny the purpose of tools like spork. I had the very same issue: I could delete all methods in a model, and tests would still pass, because Spork hold "old" model class in memory. Restarting Spork was required. </p> <p>Reason:</p> <blockquote> <p>Some plugins cause the model code to be preloaded so some work is required to block that from happening.</p> </blockquote> <ul> <li><a href="https://github.com/sporkrb/spork/issues/37" rel="nofollow">https://github.com/sporkrb/spork/issues/37</a></li> <li><a href="https://github.com/sporkrb/spork/issues/94" rel="nofollow">https://github.com/sporkrb/spork/issues/94</a></li> </ul> <p>You want to prevent model code preloaded, as this will not "reload" them if you make any changes (like with validations).</p> <p>Solutions:</p> <p>Depends from gems that are involved. In my case, I had to deal with Devise and FactoryGirl, but in essence, you do it by using Spork.trap_method as described on wiki: <a href="https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujitsu" rel="nofollow">https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujitsu</a></p> <p>Additionally you can run <code>spork -d</code> to get a list of files that are preloaded, it may be helpful to track which gems may be involved in causing this issue.</p> <p>Example: Rails 3.0.x + Rspec2 + Spork 0.9.0.rcX + Capybara + Devise + FactoryGirl</p> <pre><code># spec/spec_helper.rb Spork.prefork do # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'capybara/rspec' require 'capybara/rails' # set "gem 'factory_girl', :require =&gt; false" in Gemfile require 'factory_girl' # deal with Devise require "rails/application" Spork.trap_method(Rails::Application, :reload_routes!) require File.dirname(__FILE__) + "/../config/environment.rb" Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| config.mock_with :rspec config.use_transactional_fixtures = false config.before(:suite) do DatabaseCleaner.strategy = :transaction end config.before(:each) do DatabaseCleaner.start end config.after(:each) do DatabaseCleaner.clean end # Devise controller test helpers: config.include Devise::TestHelpers, :type =&gt; :controller end end Spork.each_run do # deal with factory girl Factory.definition_file_paths = [File.join(Rails.root, 'spec', 'factories')] Factory.find_definitions end </code></pre> <p>Please note that <code>config.cache_classes = true</code> need to be set to <code>true</code> in test environment, otherwise you may get errors from gems like FactoryGirl.</p> <p>This made my model tests (specs) run quickly, and "reload" them every time I save a file and fire rspec.</p> <p><strong>EDIT:</strong> If you're running on Ruby 1.9.3 you can try out an interesting alternative: Zeus - <a href="https://github.com/burke/zeus" rel="nofollow">https://github.com/burke/zeus</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload