Alexey Zakharov
2011-Aug-25 16:20 UTC
[rspec-users] What is the right method to call Rspec.configure when spork is used? prefork or each_run?
I need to setup mongoid collections clean up for each spec. What is the right method to call Rspec.configure when spork is used? prefork or each_run? Here is my current setup: 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110825/2794a8ae/attachment.html>
David Chelimsky
2011-Aug-29 03:27 UTC
[rspec-users] What is the right method to call Rspec.configure when spork is used? prefork or each_run?
On Aug 25, 2011, at 11:20 AM, Alexey Zakharov wrote:> I need to setup mongoid collections clean up for each spec. What is the right method to call Rspec.configure when spork is used? prefork or each_run? >Either should be fine for a before or after hook, as long as they depend on any global data (which your example does not). HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110828/f3eb5f58/attachment.html>