# Dynamic evaluation from a database

**URL:** <https://www.ruby-forum.com/t/dynamic-evaluation-from-a-database/150767>\
**Category:** Ruby\
**Created:** [October 13, 2008, 2:16am UTC](https://www.ruby-forum.com/t/dynamic-evaluation-from-a-database/150767 "2008-10-13T02:16:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![allanpeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9e8a1a/32.png) [@allanpeda](https://www.ruby-forum.com/u/allanpeda)\
**Post date:** [October 13, 2008, 2:16am UTC](https://www.ruby-forum.com/t/dynamic-evaluation-from-a-database/150767/1 "2008-10-13T02:16:05Z")

</div>

Hi,

I am writing some functional testing applications in watir and I am most  
likely going to have this application store the data in a MySQL or  
Oracle database. Since the tests are going to be in a constant state of  
change I figure it might be best to store the scripts in the DB as well,  
since this would allow me to re-deploy any code changes by updating the  
clobs in the DB.

The are several ways to go about this, but was curious as to writing  
stubs that just fetch the source directly from the DB using DBI to  
evaluate it. In a general sense is this asking for too much trouble in  
debugging or using require etc ? I assume require can be overloaded to  
search the DB as well as the filesystem.

---

<div class="post-metadata">

**Author:** ![allanpeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9e8a1a/32.png) [@allanpeda](https://www.ruby-forum.com/u/allanpeda)\
**Post date:** [October 13, 2008, 10:39am UTC](https://www.ruby-forum.com/t/dynamic-evaluation-from-a-database/150767/2 "2008-10-13T10:39:23Z")

</div>

2008/10/13 Allan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I am writing some functional testing applications in watir and I am most  
> likely going to have this application store the data in a MySQL or  
> Oracle database.

What is the reason for this? What else data is there that needs to be  
in sync with your test code?

> Since the tests are going to be in a constant state of  
> change I figure it might be best to store the scripts in the DB as well,  
> since this would allow me to re-deploy any code changes by updating the  
> clobs in the DB.

What do you mean by redeploy? Are you doing the tests on multiple  
systems?

> The are several ways to go about this, but was curious as to writing  
> stubs that just fetch the source directly from the DB using DBI to  
> evaluate it. In a general sense is this asking for too much trouble in  
> debugging or using require etc ? I assume require can be overloaded to  
> search the DB as well as the filesystem.

I’d rather not change the default require’s functionality but instead  
write a db\_require or such which can be used for your special case.  
This will also avoid any conflicts when there are similarly named  
modules in your test suite and other load path. My 0.02 EUR.

Kind regards

robert
