Rails 1.0’s fixtures are different than from before

Faster Testing with Rails 1.0

Was wondering wth was going on. Good thing for the web. According to Mike Clark, if you’re reading the Rails book, “Agile Web Development with Rails”, make sure you take note of the errata with Rails 1.0. The instantiation of fixtures as attributes and hashes are not done by default anymore with Rails v1.0.
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false

The reason being that having to instantiate all those attributes will take too long with a large fixture to test. Now, instanciations are done ON DEMAND with each test. And if they are done, they are cached. Therefore, you can either choose to override and change the use_*_fixtures settings in your test code, or you can change all your code from:
@table["my_fixture"]
to
table[:my_fixture]
table(:my_fixture)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s