Sha256: b9fc4b47e7262ef583e083b3494ea65e70a842bf234bb3a69c645c701d065d02

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../lib/mongo_mapper')

gem 'jnunemaker-matchy', '0.4.0'
gem 'shoulda', '2.10.2'
gem 'timecop', '0.3.1'
gem 'mocha', '0.9.8'

require 'matchy'
require 'shoulda'
require 'timecop'
require 'mocha'
require 'pp'

require 'support/custom_matchers'
require 'support/timing'

class Test::Unit::TestCase
  include CustomMatchers
  
  cattr_accessor :mm_document_count
  self.mm_document_count = 0
  
  def Doc(name=nil, &block)
    Test::Unit::TestCase.mm_document_count += 1
    
    klass = Class.new do
      include MongoMapper::Document
      set_collection_name "test#{rand(20)}"
      
      if name
        class_eval "def self.name; '#{name}' end"
        class_eval "def self.to_s; '#{name}' end"
      end
      
      class_eval(&block) if block_given?
    end
    klass.collection.remove
    klass
  end
  
  def EDoc(&block)
    Class.new do
      include MongoMapper::EmbeddedDocument
      instance_eval(&block) if block_given?
    end
  end
end

test_dir = File.expand_path(File.dirname(__FILE__) + '/../tmp')
FileUtils.mkdir_p(test_dir) unless File.exist?(test_dir)

MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, {
  :logger => Logger.new(test_dir + '/test.log')
})
MongoMapper.database = 'test'

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
mrkurt-mongo_mapper-0.6.11 test/test_helper.rb
mongo_mapper-unstable-2010.1.6 test/test_helper.rb
mongo_mapper-unstable-2010.1.5 test/test_helper.rb
mongo_mapper-unstable-2010.1.4 test/test_helper.rb
tpitale-mongo_mapper-0.6.10 test/test_helper.rb
mrkurt-mongo_mapper-0.6.10 test/test_helper.rb