Sha256: c75555c89c2a508033dc7d5a04f86d22be0f078726577fcfb77a3e295f0b5d59

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

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

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

RAILS_ENV = "test"

ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/test.log")
ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))

ActiveRecord::Base.establish_connection('test_slave')
load(File.dirname(__FILE__) + "/schema.rb")

ActiveRecord::Base.establish_connection('test')
load(File.dirname(__FILE__) + "/schema.rb")


class Test::Unit::TestCase

  def assert_using_master_db(klass)
    assert_equal('replica_test', klass.connection.instance_variable_get(:@config)[:database])
  end

  def assert_using_slave_db(klass)
    assert_equal('replica_test_slave', klass.connection.instance_variable_get(:@config)[:database])
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
replica-1.2.0 test/helper.rb
replica-1.1.0 test/helper.rb
replica-1.0.2 test/helper.rb