Created
November 10, 2011 23:30
-
-
Save stevedev/1356621 to your computer and use it in GitHub Desktop.
mongo_mapper_helper... instead of using spec_helper in models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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