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


#1

@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


#2

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

Cheers,

Dan.


#3

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


#4

Hello Chris,

2006/5/4, Chris R. 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

-- Jean-François.