# Running tests in a different environment

**URL:** <https://www.ruby-forum.com/t/running-tests-in-a-different-environment/184154>\
**Category:** Rails\
**Created:** [February 25, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/running-tests-in-a-different-environment/184154 "2010-02-25T18:51:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![byron\_appelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@byron\_appelt](https://www.ruby-forum.com/u/byron_appelt)\
**Post date:** [February 25, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/running-tests-in-a-different-environment/184154/1 "2010-02-25T18:51:53Z")

</div>

Hi,

We have a continuous integration server setup for our rails projects.  
I would like to set-up a different rails environment for running the  
tests on the build server so that I don’t have to force all the  
developers to set-up their local databases to match the build box’s  
connection information. However, when do something like:

rake RAILS\_ENV=build test:units

It still tries to use the db connection information from the test  
environment. I think this must be hardcoded somewhere.

Is there a way to get the test tasks to run with a different rails  
environment?

---

<div class="post-metadata">

**Author:** ![byron\_appelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@byron\_appelt](https://www.ruby-forum.com/u/byron_appelt)\
**Post date:** [February 25, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/running-tests-in-a-different-environment/184154/2 "2010-02-25T18:51:54Z")

</div>

On Feb 25, 4:56 pm, byron appelt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It still tries to use the db connection information from the test  
> environment. I think this must be hardcoded somewhere.

Take a peak at the first line of test\_helper.rb 🙂

Fred

---

<div class="post-metadata">

**Author:** ![byron\_appelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@byron\_appelt](https://www.ruby-forum.com/u/byron_appelt)\
**Post date:** [February 25, 2010, 11:46pm UTC](https://www.ruby-forum.com/t/running-tests-in-a-different-environment/184154/3 "2010-02-25T23:46:54Z")

</div>

On Feb 25, 10:56 am, byron appelt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It still tries to use the db connection information from the test  
> environment. I think this must be hardcoded somewhere.
> 
> Is there a way to get the test tasks to run with a different rails  
> environment?

It would be better to not share the database.yml at all. That way,  
you can define what the “test” environment means for the ci server  
independently of the developers.

I think it’s better practice to not store the database.yml in source  
control anyway, since it has passwords that you may not want to store  
in source control.

Jeff

---

<div class="post-metadata">

**Author:** ![byron\_appelt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@byron\_appelt](https://www.ruby-forum.com/u/byron_appelt)\
**Post date:** [February 26, 2010, 3:51pm UTC](https://www.ruby-forum.com/t/running-tests-in-a-different-environment/184154/4 "2010-02-26T15:51:57Z")

</div>

> Take a peak at the first line of test\_helper.rb 🙂

I saw that, but it seems to not be the only place it is hardcoded  
since even with that line commented it tries to acees the test  
database.
