# Alone in the wilderness? Testing plugins with a database

**URL:** <https://www.ruby-forum.com/t/alone-in-the-wilderness-testing-plugins-with-a-database/89681>\
**Category:** Rails\
**Created:** [March 22, 2007, 12:37am UTC](https://www.ruby-forum.com/t/alone-in-the-wilderness-testing-plugins-with-a-database/89681 "2007-03-22T00:37:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/df788c/32.png) [@kpd](https://www.ruby-forum.com/u/kpd)\
**Post date:** [March 22, 2007, 12:37am UTC](https://www.ruby-forum.com/t/alone-in-the-wilderness-testing-plugins-with-a-database/89681/1 "2007-03-22T00:37:03Z")

</div>

Hi,

I’m one of the developers of a plugin [1] that needs a database for  
testing. I’ve been having a miserable time keeping the tests for this  
plugin working between Rails versions.

There are a number of guides out there for writing plugins [2], but  
few of them cover testing, and those that do stop short of tests  
requiring a database.

I’m wondering if anyone can point me to accepted best practices for  
testing plugins with a database, or at least working example code. The  
setup that we have for our plugin (used to) work great: it would load  
the schema and run the tests against three different database  
adapters. But now all the callbacks for ActiveRecord objects are being  
triggered twice, and the setup is broken in other ways I don’t  
understand.

I want to keep supporting and developing this plugin, but I’m feeling  
rather stuck at the moment. The code itself works fine, and I’ve got  
500+ assertions; I just need a push in the right direction with the  
test setup.

Many thanks,  
Krishna

[1] [http://opensource.symetrie.com/trac/better\_nested\_set](http://opensource.symetrie.com/trac/better_nested_set)  
[2] [http://wiki.rubyonrails.org/rails/pages/HowTosPlugins](http://wiki.rubyonrails.org/rails/pages/HowTosPlugins)
