Skip to content

Instantly share code, notes, and snippets.

@stevedev
Created November 10, 2011 23:30
Show Gist options
  • Save stevedev/1356621 to your computer and use it in GitHub Desktop.
Save stevedev/1356621 to your computer and use it in GitHub Desktop.
mongo_mapper_helper... instead of using spec_helper in models
require 'mongo_mapper'
ENV["RAILS_ENV"] ||= 'test'
$LOAD_PATH.unshift ::File.dirname(__FILE__) + '/../'
MongoMapper.connection = Mongo::Connection.new("127.0.0.1", 27017, :pool_size => 5)
MongoMapper.database = 'testdb'
Dir['app/plugins/*.rb'].sort.each do |file|
load file
end
Dir['app/models/*.rb'].sort.each do |file|
File.read(file)[/^class (\w+)/]
class_name = $1
Kernel.autoload class_name.to_sym, file unless class_name.blank?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment