[rspec-users] Transactional fixtures not working as expected

Michael Hamann rails at content-space.de
Wed Aug 8 13:41:12 EDT 2007


I am quite new to BDD and I just wrote my first tests. Suddenly I
received unexpected results because in a model test I load only
users-fixtures but when the views-fixtures in which I load the
posts-fixtures, are run before this model-test, the posts-fixtures are
loaded too. I test for example if there is one record in the posts-table
after creating one post. But when there are fixtures loaded, this does
not work of course. A similar issue was discussed here already in
October 2006, but there was no real result:

I am using edge rails with the current RSpec and RSpec on Rails -
plugins. I first used sqlite3, then mysql to verify that it is no
sqlite3 bug, but the errors occur also when I am using Mysql.
Transactional fixtures are enabled, instantiated fixtures are disabled.

My question is now: Is this behavior really desired? Because now my
model-tests alone pass, and all the other tests too, but when the
view-tests are run before the model-tests, they don't pass. So the
passing of the tests becomes unpredictable. And I think I will have
additional fixtures for models I don't use fixtures at the moment and
this will make other tests fail, too. So should I really write tests
that work with any fixtures loaded? And why is there a possibility to
load fixtures in one description also this loads the fixtures actually

What can I do against this behavior? Is this a bug?

Michael Hamann

More information about the rspec-users mailing list