1. Gemfileにspring-commands-rspec
を追加する
gem 'spring-commands-rspec'
2. bin/rspec
を作成する
spring-commands-rspecの場合
$ bundle exec spring binstub rspec
bin/rspec
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
注意:すでにbundleのbinstubsを使ってbin/rspec
がある場合は、一度削除する
$ bundle binstubs rspec-core
binstubsで生成したbin/rspec
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
このbin/rspec
はspringが使われない
3. 測定
Springなし
実行
$ bundle exec spring status
Spring is not running.
出力結果
bundle exec rspec 3.83s user 0.94s system 97% cpu 4.887 total
Springあり
実行
$ time bundle exec bin/rspec
出力結果
bundle exec bin/rspec 0.53s user 0.10s system 45% cpu 1.379 total