# How can I inspect the test env database?

**URL:** <https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878>\
**Category:** Rails\
**Created:** [November 12, 2009, 9:43pm UTC](https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878 "2009-11-12T21:43:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [November 12, 2009, 9:43pm UTC](https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878/1 "2009-11-12T21:43:53Z")

</div>

I’m wanting to be able to inspect what is actually getting written to  
the test database when/after tests are ran.

However I do no not know how to do this. Since after each test is ran  
the DB is wiped. How can I somehow prevent the BD from getting  
cleared out after running a test so I can manually check it’s content?

I am using MySQL, Shoulda and Factory Girl.

Thank you.  
Elliott G

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [November 13, 2009, 12:25am UTC](https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878/2 "2009-11-13T00:25:26Z")

</div>

try this from the command line  
tail -f log/test.log  
…and run your tests from another console  
hope it helps!

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [November 13, 2009, 12:59am UTC](https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878/3 "2009-11-13T00:59:23Z")

</div>

I’m not sure how Shoulda works, but in Cucumber, I can turn off  
transactional fixtures which retains state in the test database  
between scenarios.

The danger with this is that tests may pass or fail based on previous  
state, when each scenario should really be run in isolation.

Eric

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [November 13, 2009, 12:40am UTC](https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878/4 "2009-11-13T00:40:04Z")

</div>

Thanks for the reply Auvi.

I have been tailing the test log. It is showing me that the records I  
am watching are getting update on the test db as expected. But when I  
do a subsequent AR find query to pull them out and run assertions on  
them they do not match what the test log was showing. That’s why I am  
trying to get a peek at the db itself.

Is it poor form/problematic to run AR find queries in functional  
tests?

Thanks, EG

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [November 13, 2009, 1:41am UTC](https://www.ruby-forum.com/t/how-can-i-inspect-the-test-env-database/178878/5 "2009-11-13T01:41:32Z")

</div>

Thanks E.Litwin

That worked like a charm.

I just changed self.use\_transactional\_fixtures = false in test/  
test\_helper.rb from the default true to false.

Thanks again, Elliott G
