[rspec-users] How to test an app with multiple databases?
dchelimsky at gmail.com
Sun Mar 7 11:42:19 EST 2010
On Sun, Mar 7, 2010 at 10:11 AM, Russell Fine <lists at ruby-forum.com> wrote:
> David Chelimsky wrote:
>> On Sun, Mar 7, 2010 at 9:45 AM, Russell Fine <lists at ruby-forum.com>
>>> Our app connects to two databases. �The main database (through
>>> ActiveRecord::Base) is automatically cleared before each test. �How do I
>>> force the clear of the secondary database as well ?
>> There's no implicit support for this, so you'd have to do something
>> manually in a before(:each) block. You can do that in the
>> configuration (usually in spec_helper):
>> Spec::Runner.configure do |c|
>> c.before(:each) do
>> # clear out 2ndary db
> Thanks for the quick reply. Do you happen to know where in the
> framework I would call to clear out the db? I can obviously do it
> myself by hand by just deleting all elements, but I'm worried that the
> testing framework may perform some unique actions that differ from what
> I would do.
rspec-rails just wraps the rails testing framework facilities, so
whatever you're looking for is going to be found in the rails code.
I'm not sure how the database_cleaner gem handles multiple databases,
but you might find your answer there.
Can anybody else point Russell in the right direction?
More information about the rspec-users