spec/spec_helper.rb in voteable_mongo-0.8.1 vs spec/spec_helper.rb in voteable_mongo-0.9.0

- old
+ new

@@ -1,31 +1,37 @@ require 'rubygems' require 'bundler' Bundler.setup +if rand > 0.6 + puts 'Mongoid' + require 'mongoid' + models_folder = File.join(File.dirname(__FILE__), 'mongoid/models') + Mongoid.configure do |config| + name = 'voteable_mongo_test' + host = 'localhost' + config.master = Mongo::Connection.new.db(name) + config.autocreate_indexes = true + end +else + puts 'MongoMapper' + require 'mongo_mapper' + models_folder = File.join(File.dirname(__FILE__), 'mongo_mapper/models') + MongoMapper.database = 'voteable_mongo_test' +end + + $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -MODELS = File.join(File.dirname(__FILE__), "models") -$LOAD_PATH.unshift(MODELS) - -require 'mongoid' require 'voteable_mongo' require 'rspec' require 'rspec/autorun' - -Mongoid.configure do |config| - name = "voteable_mongo_test" - host = "localhost" - config.master = Mongo::Connection.new.db(name) -end - - -Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file) } - -User.collection.drop -Post.collection.drop -Comment.collection.drop -Category.collection.drop +Dir[ File.join(models_folder, '*.rb') ].each { |file| + require file + file_name = File.basename(file).sub('.rb', '') + klass = file_name.classify.constantize + # klass.collection.drop +}