Sha256: f8ad8e9fb2c9feb575b6f15a2b684a69eedfdbad68f992f00d31aec5c5efe03e

Contents?: true

Size: 1.41 KB

Versions: 22

Compression:

Stored size: 1.41 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

  def Doc(name=nil, &block)
    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
    end

    klass.class_eval(&block) if block_given?
    klass.collection.remove
    klass
  end

  def EDoc(name=nil, &block)
    klass = Class.new do
      include MongoMapper::EmbeddedDocument

      if name
        class_eval "def self.name; '#{name}' end"
        class_eval "def self.to_s; '#{name}' end"
      end
    end

    klass.class_eval(&block) if block_given?
    klass
  end

  def drop_indexes(klass)
    if klass.database.collection_names.include?(klass.collection.name)
      klass.collection.drop_indexes
    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

22 entries across 22 versions & 3 rubygems

Version Path
numon-0.0.1 test/test_helper.rb
mongo_mapper-0.7.1 test/test_helper.rb
mongo_mapper-unstable-2010.3.8 test/test_helper.rb
mongo_mapper-unstable-2010.3.5 test/test_helper.rb
mongo_mapper-unstable-2010.3.4 test/test_helper.rb
mongo_mapper-unstable-2010.3.3 test/test_helper.rb
mongo_mapper-unstable-2010.2.27 test/test_helper.rb
mongo_mapper-unstable-2010.2.26 test/test_helper.rb
mongo_mapper-unstable-2010.2.25 test/test_helper.rb
mongo_mapper-unstable-2010.2.24 test/test_helper.rb
mongo_mapper-unstable-2010.2.23 test/test_helper.rb
mongo_mapper-unstable-2010.2.22 test/test_helper.rb
mongo_mapper-unstable-2010.2.19 test/test_helper.rb
mongo_mapper-unstable-2010.2.18 test/test_helper.rb
mongo_mapper-unstable-2010.2.17 test/test_helper.rb
mongo_mapper-unstable-2010.2.16 test/test_helper.rb
mongo_mapper-unstable-2010.2.15 test/test_helper.rb
mongo_mapper-unstable-2010.2.12 test/test_helper.rb
mongo_mapper-unstable-2010.2.11 test/test_helper.rb
mongo_mapper-unstable-2010.2.10 test/test_helper.rb