views:

16

answers:

2

Hi, I am trying to test a functionality, which inserts few details into the DB. In the test.log, it shows the insert command that is generated and also the log messages that I have placed to show the progress and everything seems to be working fine except the actual data is not getting inserted into the DB. I am checking whether data is inserted in db/test.sqlite3. No exception is generated when the test cases are run. Is there a setting, which I have to set inorder to insert data into the test DB? or am i missing anything else Thanks

+1  A: 

Are you checking the database after the test is run?

By default Rails runs all tests usings transactions. This means after each test is run, the database is rolled back.

This is preferred for testing. Otherwise you may have one test tainting the data or state which affects another test.

The Who
Oh... It ll be rolled back. Thanks :)
Felix
+1  A: 

Test data is usually cleaned up. Once the test cases are run. So I don't think there is anything in a test database. After each test transaction is run, the database is rolled back.

Rishav Rastogi
Thanks for the information
Felix