when using Spork: if your tests are failing when you think they should be passing, the problem might be the Spork prefork loading, which can sometimes prevent necessary files from being re-loaded.When in doubt, quit the Spork server with Control-C and restart it
針對這種情況,我們可以使用一個名為Guard的gem,來自動監控spork中預加載的文件發生變化后,自動重啟spork
1).在Gemfile中增加gem 'guard-spork'
2).在shell中gem install libnotify / gem install inotify
3).bundle install
4).guard init spork
5).guard start
其中第4步會在Rails項目下生成一個Guardfile文件,文件的內容如下:
guard 'spork' do
watch('^config/application.rb$')
watch('^config/environment.rb$')
watch('^config/environments/.*.rb$')
watch('^config/initializers/.*.rb$')
watch('^spec/spec_helper.rb')
end
這表明使用Guard來監控配置文件的改變,最后一步是使用Guard來啟動Spork
-------------------------------------------------------------
生活就像打牌,不是要抓一手好牌,而是要盡力打好一手爛牌。
posted on 2011-07-15 18:12
Paul Lin 閱讀(426)
評論(0) 編輯 收藏 所屬分類:
RoR