Unit test: fixutres not getting loaded into instance vars

this is odd… not my first time writing tests, but i have the records
in my test fixtures labelled so i can just use the instance variable
@label’ in my tests. worked fine in my other rails project, but i get
nil errors now… when i put @label = Table.find(1) in the setup method
things work fine… any idea why my fixture data is getting auto-loaded
into the intance vars?

thanks in advance,


That method of dealing with fixtures is deprecated and should not be
It might even be gone now for you. Proper use of fixures:


So in your case



well it works now… but one more thing:

usually the table that the fixture is from gets cleared out after the
test… right now after the test is done i can go into the test database
and still see records in it…

things seem very different. don’t know why

Instanciated fixtures (fixtures appearing as instance variables) can be
turned on/off (default now off as it is slower) from your test_helper
Transactional fixtures are now on by default (because it’s faster),
however if you’re using a db that doesn’t do transactions (eg MySQL with
MyISAM tables then that won’t work), which would explains the changes
made during tests persisting.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs