RSpecの実行を早くするためにSpork使ってみた

とても今更な話題だけどSporkつかってみた。実行速度が1/10くらいはやいはやい

Install

$ gem install spork

Config

## spec_helper.rbにspork用の設定が足される
$ spork rspec --bootstrap

spec_helper.rb

require 'rubygems'
require 'spork'

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However,
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.

  ## ここに元々のspec_helper.rbの内容をかく
end

Spork.each_run do
  # This code will be run each time you run your specs.

end

# --- Instructions ---
# - Sort through your spec_helper file. Place as much environment loading
#   code that you don't normally modify during development in the
#   Spork.prefork block.
# - Place the rest under Spork.each_run block
# - Any code that is left outside of the blocks will be ran during preforking
#   and during each_run!
# - These instructions should self-destruct in 10 seconds.  If they don't,
#   feel free to delete them.
#

spec.optsにオプションを足す

--drb

Init

$ spork rspec

これでspec実行するとはやくなりました。