読者です 読者をやめる 読者になる 読者になる

すがブロ

sugamasaoのhatenablogだよ

RSpec実行時にlibとspecが$LOAD_PATHに追加される

ruby rspec

知らなかった

require 'pp'

pp $LOAD_PATH

っていうコードを用意して

Rubyで実行する
% ruby sample.rb
["/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/x86_64-darwin11.4.0",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/vendor_ruby/1.9.1",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin11.4.0",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/vendor_ruby",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0"]
RSpecで実行する
% rspec sample.rb
["./spec",
 "./lib",
 "/Users/sugamasao/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.10.1/lib",
 "/Users/sugamasao/.rvm/gems/ruby-1.9.3-p194/gems/diff-lcs-1.1.3/lib",
 "/Users/sugamasao/.rvm/gems/ruby-1.9.3-p194/gems/rspec-expectations-2.10.0/lib",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/x86_64-darwin11.4.0",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/vendor_ruby/1.9.1",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin11.4.0",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/vendor_ruby",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1",
 "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0"]
No examples found.


Finished in 0.00009 seconds
0 examples, 0 failures
こんな感じで

./specと./libが追加されていた。勉強になります!!