Forum: Ruby on Rails @products["car"] is not being recognized in my tests!! help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris Richards (chris)
on 2006-05-04 10:45
@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
9e44fa55e7078bff7c3dab8404913928?d=identicon&s=25 Dan Venkitachalam (Guest)
on 2006-05-04 10:56
(Received via mailing list)
Does using product("car").id instead of @products["car"].id fix your
problem?

Cheers,

Dan.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris Richards (chris)
on 2006-05-04 12:35
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
13ea48f056b19349027d2f4a6921a46a?d=identicon&s=25 Jean-François (Guest)
on 2006-05-04 12:51
(Received via mailing list)
Hello Chris,

2006/5/4, Chris Richards <evilgeenius@gmail.com>:
>
> 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.
This topic is locked and can not be replied to.