# @products\["car"\] is not being recognized in my tests! help

**URL:** <https://www.ruby-forum.com/t/products-car-is-not-being-recognized-in-my-tests-help/59576>\
**Category:** Rails\
**Created:** [May 4, 2006, 10:45am UTC](https://www.ruby-forum.com/t/products-car-is-not-being-recognized-in-my-tests-help/59576 "2006-05-04T10:45:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [May 4, 2006, 10:45am UTC](https://www.ruby-forum.com/t/products-car-is-not-being-recognized-in-my-tests-help/59576/1 "2006-05-04T10:45:05Z")

</div>

@products[“car”] is not being recognized in my tests:

class ProductsControllerTest \< Test::Unit::TestCase  
fixtures :products

def test\_view\_product  
post :view\_product, :id=\>@products[“car”].id  
assert\_template “view\_product”  
…  
end

end

products.yml :

car:  
id:1  
name:test

Does anyone have any idea why its not working?  
Im having to do this instead, which is not ideal:  
post :view\_product, :id=\>1

Thanks  
Chris

---

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [May 4, 2006, 10:56am UTC](https://www.ruby-forum.com/t/products-car-is-not-being-recognized-in-my-tests-help/59576/2 "2006-05-04T10:56:02Z")

</div>

Does using product(“car”).id instead of @products[“car”].id fix your  
problem?

Cheers,

Dan.

---

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [May 4, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/products-car-is-not-being-recognized-in-my-tests-help/59576/3 "2006-05-04T12:35:00Z")

</div>

Dan Venkitachalam wrote:

> Does using product(“car”).id instead of @products[“car”].id fix your  
> problem?
> 
> Cheers,
> 
> Dan.

Yeah that seems to work. Though according to the “Agile Development  
with rails” book :

“When a fixture is loaded, its put into a Hash object referenced by an  
instance variable of the test case. For example the :products fixture  
is convieniently loaded into the @products instance variable.”

That goes against what you suggested and what seems to work. Any Ideas  
whats going on? Its hard to believe they’ve changed the way it works so  
drastically,

Thanks  
Chris

---

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [May 4, 2006, 12:51pm UTC](https://www.ruby-forum.com/t/products-car-is-not-being-recognized-in-my-tests-help/59576/4 "2006-05-04T12:51:10Z")

</div>

Hello Chris,

2006/5/4, Chris R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> That goes against what you suggested and what seems to work.  
> Any Ideas whats going on? Its hard to believe they’ve changed  
> the way it works so drastically,

yes, they have.

Read : [http://clarkware.com/cgi/blosxom/2005/10/24](http://clarkware.com/cgi/blosxom/2005/10/24)

```
-- Jean-FranÃ§ois.

```
