$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)
VALIDATORS = File.join(File.dirname(__FILE__), "validators")
$LOAD_PATH.unshift(VALIDATORS)

require "rubygems"
require "bundler"
Bundler.setup

require 'mongoid'
require 'rspec'
require 'rspec/core'
require 'rspec/expectations'

Mongoid.configure do |config|
  config.connect_to("mongoid-rspec-test")
end

Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file) }

require 'mongoid-rspec'

RSpec.configure do |config|
  config.include RSpec::Matchers
  config.include Mongoid::Matchers
  config.mock_with :rspec
  config.after :all do
    Mongoid::Config.purge!
  end
  config.after :suite do
    print "\n# Mongoid v#{Mongoid::VERSION}"
  end
  config.disable_monkey_patching!
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)
VALIDATORS = File.join(File.dirname(__FILE__), "validators")
$LOAD_PATH.unshift(VALIDATORS)

require "rubygems"
require "bundler"
Bundler.setup

require 'mongoid'
require 'rspec'
require 'rspec/core'
require 'rspec/expectations'

Mongoid::Config.connect_to('mongoid-rspec-test')
Mongo::Logger.logger.level = ::Logger::INFO

Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file) }

require 'mongoid-rspec'

RSpec.configure do |config|
  config.include RSpec::Matchers
  config.include Mongoid::Matchers
  config.mock_with :rspec
  config.after :all do
    Mongoid::Config.purge!
  end
  config.after :suite do
    print "\n# Mongoid v#{Mongoid::VERSION}"
  end
  config.disable_monkey_patching!
end

Update RSpec configuration. Set mongoid log level to debug in order to prevent poluting RSpec's output
Update RSpec configuration. Set mongoid log level to debug in order to
prevent poluting RSpec's output
