Sha256: 5f5df87539b5b1cf6a1da9b59a1ced91ea4c5d0b1b2b10f47c420b14d0c5bdf5

Contents?: true

Size: 1.24 KB

Versions: 22

Compression:

Stored size: 1.24 KB

Contents

require 'rubygems'
require 'test/unit'
require 'shoulda'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'has_constant'

def setup_mongoid
  begin
    require 'mongoid'
    Mongoid.database = Mongo::Connection.new('localhost', @port).db('i18n_test')
  rescue LoadError => e
    puts "can't use Mongoid adapter because: #{e}"
  end
end

def setup_active_record
  begin
    require 'active_record'
    ActiveRecord::Base.connection
    true
  rescue LoadError => e
    puts "can't use ActiveRecord backend because: #{e.message}"
  rescue ActiveRecord::ConnectionNotEstablished
    connect_active_record
    true
  end
end

def connect_active_record
  connect_adapter
  ActiveRecord::Migration.verbose = false
  ActiveRecord::Schema.define(:version => 1) do
    create_table :users, :force => true do |t|
      t.integer :salutation
    end
  end
end

def connect_adapter
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ":memory:")
end

class Test::Unit::TestCase

  def setup
    Mongoid.database.collections.each do |collection|
      begin
        collection.drop
      rescue
      end
    end if defined?(Mongoid)
    User.delete_all if defined?(ActiveRecord)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
has_constant-0.2.1 test/helper.rb
has_constant-0.2.0 test/helper.rb