2011-08-25 17 views
2

我需要設置mongoid集合清理每個規範。使用spork時,調用Rspec.configure的正確方法是什麼? prefork或each_run?使用spork時,調用Rspec.configure的正確方法是什麼? prefork或each_run?

這裏是我的當前設置:

require 'rubygems' 
require 'spork' 

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. 
    require File.dirname(__FILE__) + '/../config/environment.rb' 
    require 'rspec' 
    require 'rspec/rails' 
    RSpec.configure do |config| 
    config.mock_with :rspec 
    config.after(:each) do 
     puts "cleaning mongodb...." 
     Mongoid.database.collections.each do |collection| 
     unless collection.name =~ /^system\./ 
      collection.remove 
     end 
     end 
     puts "finished cleaning mongodb." 
    end 
    end 

end 

Spork.each_run do 

end 

回答

0

你有什麼是正確的,因爲你只需要一次配置這一點,並沒有代碼重載需要

相關問題