Unit tests leave data behind when they should not

Hi,

I was confused yesterday. I have bunch of tests and one of those was
testing ActiveRecord::save and it was all right, but next method failed
because table still had newly created record. All documentation suggests
that it should not be the case and that data is reloaded from fixtures
before every method is run.
I am running edge rails and really did not have anything special done
about unit testing setup.
Anybody can suggest where to look for the cause?

Sergei

Since 1.0, Rails tries to use transactions during testing, to help
with performance. So, if you’re database does not support
transactions, the tests won’t work correctly. If you’re using MySQL,
you can enable transactions by attaching “engine = innodb” to the end
of your create table statements. Alternatively, you can add this
line to your test classes:

self.use_transactional_fixtures = false

Hope that helps,

Tim

Thank you Tim.

Hope that helps,

Tim

In mySQL you can alter an existing table (named table_name) to use
InnoDB with the command:

mysql> alter table table_name TYPE=InnoDB;

just substitute your table name, and run at the mysql prompt (or however
you prefer to run stand alone sql.

-sean

Timothy B. wrote:

Since 1.0, Rails tries to use transactions during testing, to help
with performance. So, if you’re database does not support
transactions, the tests won’t work correctly. If you’re using MySQL,
you can enable transactions by attaching “engine = innodb” to the end
of your create table statements. Alternatively, you can add this
line to your test classes:

self.use_transactional_fixtures = false

Hope that helps,

Tim