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 阅读(419)
评论(0) 编辑 收藏 所属分类:
RoR