testing with a secondary 'outside' database

my rails app has a local database where all info is stored, but it
often syncs with a 'master' database that has different connection
info.. i have that all set up in my app and it works great. problem is
with testing.

for example when i create a person it also creates them on the master
database. in test environment it still connects to the same database,
which is not what i'm looking for. I have something like this in my app
to allow a model to connect to the master db:

class Master < ActiveRecord::Base
  self.abstract_class = true
  establish_connection(
    :adapter => "mysql",
    :database => "master",
    :host => "xxx.xxx.xxx",
    :port => xxxx,
    :username => "user",
    :password => "pass")
end

all 'sync tables' inherit from Master instead of ActiveRecord.. so what
i need is something that can ask "is environment = testing ?" and if so
give different connection info for a testing Master DB. what's the best
way to do this?

i was thinking having a similar class called FakeMaster.. but how do i
make my sync tables decide which one to use on the fly?

can i do this? :

if RAILS_ENV == "test"
  class Synctable < FakeMaster
  end
else
  class Synctable < Master
  end
end

also keep in mind that even if the above works i would like to stay dry
and not duplicate the class bodies above. would this work? db_to_use =
(RAILS_ENV == "test" ? 'FakeMaster' : 'Master')
and then:
eval "class Synctable < #{db_to_use}"
.... body goes here...
end

i somehow doubt that that is gonna work.

thanks in advance,

Stuart