Hi all,
I''m working on the rails book and the test definition shown further
below
gives the following error.
test_read_with_hash(ProductTest):
NoMethodError: You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]
test/unit/product_test.rb:45:in `test_read_with_hash''
4 tests, 15 assertions, 0 failures, 1 errors
def test_read_with_hash
assert_kind_of Product, @product
vc_book = @products["version_control_book"] << line 45
assert_equal vc_book["id"], @product.id
assert_equal vc_book["title"], @product.title
assert_equal vc_book["description"], @product.description
assert_equal vc_book["image_url"], @product.image_url
assert_equal vc_book["price"], @product.price
assert_equal vc_book["date_available"],
@product.date_available_before_type_cast
end
Fixture in question:
version_control_book:
id: 1
title: Pragmatic Version Control
description: How to use version control
image_url: http://.../sk_svn_small.jpg
price: 29.95
date_available: 2005-01-26 00:00:00
I''m clueless .. Thanx a lot
Regards,
Gerard.
--
"Who cares if it doesn''t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..."
My $Grtz =~ Gerard;
~
:wq!
ara.t.howard-32lpuo7BZBA@public.gmane.org
2005-Dec-09 00:43 UTC
Re: Newbie going blind on test from book
On Fri, 9 Dec 2005, Gerard wrote:> 4 tests, 15 assertions, 0 failures, 1 errors > > def test_read_with_hash > assert_kind_of Product, @product > vc_book = @products["version_control_book"] << line 45^ ^ ^ take this away -a -- ==============================================================================| ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================
Regretfully that wasn''t it, althought the reply signs "> "
had me confused
somewhat I tried several. Removing any quotes or brackets results in syntax
errors so that doesn''t improve.
I also tried the @products in single form @product, but that still gets the
error:
test_read_with_hash(ProductTest):
NoMethodError: You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]
test/unit/product_test.rb:45:in `test_read_with_hash''
4 tests, 15 assertions, 0 failures, 1 errors
Regards,
Gerard.
On Friday 09 December 2005 01:43, ara.t.howard-32lpuo7BZBA@public.gmane.org
tried to type
something like:> On Fri, 9 Dec 2005, Gerard wrote:
> > 4 tests, 15 assertions, 0 failures, 1 errors
> >
> > def test_read_with_hash
> > assert_kind_of Product, @product
> > vc_book = @products["version_control_book"] <<
line 45
>
> ^
> ^
> ^
> take this away
>
> -a
--
"Who cares if it doesn''t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..."
My $Grtz =~ Gerard;
~
:wq!