Chris Richards
2006-May-04 08:45 UTC
[Rails] @products["car"] is not being recognized in my tests!! help
@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 -- Posted via http://www.ruby-forum.com/.
Dan Venkitachalam
2006-May-04 08:55 UTC
[Rails] @products["car"] is not being recognized in my tests!! help
Does using product("car").id instead of @products["car"].id fix your problem? Cheers, Dan. On 5/4/06, Chris Richards <evilgeenius@gmail.com> wrote:> > @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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Dan Venkitachalam expandingbrain.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060504/a7880224/attachment.html
Chris Richards
2006-May-04 10:35 UTC
[Rails] Re: @products["car"] is not being recognized in my tests!! h
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 -- Posted via http://www.ruby-forum.com/.
Jean-François
2006-May-04 10:48 UTC
[Rails] Re: @products["car"] is not being recognized in my tests!! h
Hello Chris, 2006/5/4, Chris Richards <evilgeenius@gmail.com>:> Dan Venkitachalam wrote: > > Does using product("car").id instead of @products["car"].id fix your > > problem? > > 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,yes, they have. Read : http://clarkware.com/cgi/blosxom/2005/10/24 -- Jean-Fran?ois. -- ? la renverse.