# Unit test: fixutres not getting loaded into instance vars

**URL:** <https://www.ruby-forum.com/t/unit-test-fixutres-not-getting-loaded-into-instance-vars/75413>\
**Category:** Rails\
**Created:** [November 9, 2006, 7:31pm UTC](https://www.ruby-forum.com/t/unit-test-fixutres-not-getting-loaded-into-instance-vars/75413 "2006-11-09T19:31:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stewbawka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@stewbawka](https://www.ruby-forum.com/u/stewbawka)\
**Post date:** [November 9, 2006, 7:31pm UTC](https://www.ruby-forum.com/t/unit-test-fixutres-not-getting-loaded-into-instance-vars/75413/1 "2006-11-09T19:31:56Z")

</div>

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,

Stuart

---

<div class="post-metadata">

**Author:** ![stewbawka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@stewbawka](https://www.ruby-forum.com/u/stewbawka)\
**Post date:** [November 9, 2006, 7:37pm UTC](https://www.ruby-forum.com/t/unit-test-fixutres-not-getting-loaded-into-instance-vars/75413/2 "2006-11-09T19:37:57Z")

</div>

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

fixture\_type(:fixture\_name)

So in your case

table(:label)

Jason

---

<div class="post-metadata">

**Author:** ![stewbawka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@stewbawka](https://www.ruby-forum.com/u/stewbawka)\
**Post date:** [November 9, 2006, 9:38pm UTC](https://www.ruby-forum.com/t/unit-test-fixutres-not-getting-loaded-into-instance-vars/75413/3 "2006-11-09T21:38:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stewbawka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@stewbawka](https://www.ruby-forum.com/u/stewbawka)\
**Post date:** [November 10, 2006, 12:20am UTC](https://www.ruby-forum.com/t/unit-test-fixutres-not-getting-loaded-into-instance-vars/75413/4 "2006-11-10T00:20:17Z")

</div>

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.

Fred
