Troubleshooting
Common issues with Spork, and how to overcome.
It’s faster, but not much. (Rails 2.3)
See http://pragmatig.wordpress.com/2009/09/27/speeding-up-slow-spork-startup-for-rails-2-3/
Database connections don’t work inside of Spork
If you’re using ActiveRecord and Rails, Spork will automatically reconnect to the database. However, if you’re not using ActiveRecord, or if you’re doing some tricky stuff with connections, you’ll have to make sure your connections get re-established on each run. In your spec/spec_helper.rb file:
Spork.each_run do
# Do your connection re-establishing here
end
Couldn’t find formatter class Spec::Runner::Formatter::TextMateFormatter
If you see this error message:
Make sure the --require option is specified *before* --format
On one of our projects, many of us using TextMate with spork, only one developer got this error message while the rest of us ran just fine. I don’t know exactly why it happened, but requiring the textmate formatter in the prefork block made it go away, like this:
Spork.prefork do
gem "rspec", "= 1.2.6"
require 'spec'
...
require 'spec/runner/formatter/text_mate_formatter'
...
end
uninitialized constant MissingSourceFile
This is kind of an issue with RSpec. See this ticket for more info:
Basically, just remove the unless defined?(RAILS_ROOT) from your spec/spec_helper.rb, and this should go away.
Some changes to files don’t take affect until I restart Spork.
Your file is getting preloaded in your prefork block. Anything in the prefork block is cached during the life of the spork server (this is what makes it run faster than otherwise). Run spork -d to help you find out which files are being preloaded, and why.
Some eager plugins (including latest version of Thinking Sphinx) load the contents of your app folder. You can see which by inspecting the output of spork -d > spork.log. See Kickstart Rspec with Spork for more details.
