Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

62 lines (48 sloc) 2.151 kB
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
MODELS = File.join(File.dirname(__FILE__), "models")
SUPPORT = File.join(File.dirname(__FILE__), "support")
require "mongoid"
require "mocha"
require "rspec"
LOGGER =$stdout)
Mongoid.configure do |config|
name = "mongoid_test"
config.master =
config.logger = nil
Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file) }
Dir[ File.join(SUPPORT, "*.rb") ].each { |file| require File.basename(file) }
Rspec.configure do |config|
config.after(:suite) do {|c| !~ /system/ }.each(&:drop)
# We need to filter out the specs that hit the slave databases if 2 slaves
# are not confiured and running locally.
slaves_configured = Support::Slaves.configured?
warn(Support::Slaves.message) unless slaves_configured
# We filter out the specs that require authentication if the database has not
# had the mongoid user set up properly.
user_configured = Support::Authentication.configured?
warn(Support::Authentication.message) unless user_configured
# We filter out specs that require authentication to MongoHQ if the
# environment variables have not been set up locally.
mongohq_configured = Support::MongoHQ.configured?
warn(Support::MongoHQ.message) unless mongohq_configured
# Filter out the specs for the secondary database tests if the secondary
# master and slaves are not running.
multi_configured = Support::Multi.configured?
warn(Support::Multi.message) unless multi_configured
config.filter_run_excluding(:config => lambda { |value|
return true if value == :mongohq && !mongohq_configured
return true if value == :slaves && !slaves_configured
return true if value == :user && !user_configured
return true if value == :multi && !multi_configured
ActiveSupport::Inflector.inflections do |inflect|
inflect.singular("address_components", "address_component")
Jump to Line
Something went wrong with that request. Please try again.