On May 13, 2005, at 2:34 PM, Anthony Fairchild wrote:> I''m a newbie to Rails and Ruby and so far I''m very
impressed with
> it. I''m running into an issue with my model unit tests.
I''ve
> created some test cases that create, retrieve, update and delete
> records in the MySQL database. I also have yml fixtures that add
> records to the database. After the test case runs successfully,
> inspecting the database shows that only the fixture records got
> saved while the records I added/updated in the test case do not
> exist. I understand that the data in the test database is blown
> away with every run, but shouldnt this data still exist after the
> run? Do I need to manually commit the changes or wrap them in a
> transaction?
The state of the database following your test run depends on the
order the tests are executed and which fixtures are declared for
which tests. It''s a scratch database and should be treated as such.
If you want to use the data produced by a test run, perhaps there is
a better way to capture it. For starters, check out script/console.
Best,
jeremy