牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

RSpecの実行速度を速くするらしい『Spork』をいれてみる

『追記:rspec, spork, guard で自動テストをやってみる』

RSpec, Spork

RSpec インストール済み、かつ既にテスト書いてある前提で

Install

Gemfile

group :development, :test do
  gem "rspec-rails"
  gem 'spork'
end

shell

$ bundle install
:
$ spork --bootstrap
spec/spec_helper.rb
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

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.

# ここの元々あった設定を入れる

end
Run: spork

別窓のシェルで

$ spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Edit: .rspec

add "--drb"

--colour --drb --format d
Run: RSpec
$ rake spec

実行速度が十数秒だったのが5秒くらいで実行されるようになった。

追記:rspec, spork, guard で自動テストをやってみる

ファイルを編集保存すると自動でテストしてくれる

Gemfile
group :development, :test do
  gem 'rspec-rails'
  gem "spork-rails"
  gem 'guard-spork'
  gem 'guard-rspec'
end
bundle
$ bundle install
rspec
$ rails generate rspec:install
      create  .rspec
       exist  spec
      create  spec/spec_helper.rb

.rspec

--color
--format d #任意で
Guard

rake db:migrate やっておく前提で

$ guard init spork
$ guard init rspec
動かす

シェルで

$ guard
確認

hoge_spec.rb などを編集保存
テストが通ると Emacs の場合 mode-line に色つく (green | red)