# Newbie going blind on test from book

**URL:** <https://www.ruby-forum.com/t/newbie-going-blind-on-test-from-book/49830>\
**Category:** Rails\
**Created:** [December 9, 2005, 12:46am UTC](https://www.ruby-forum.com/t/newbie-going-blind-on-test-from-book/49830 "2005-12-09T00:46:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mailing](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f475e1/32.png) [@mailing](https://www.ruby-forum.com/u/mailing)\
**Post date:** [December 9, 2005, 12:46am UTC](https://www.ruby-forum.com/t/newbie-going-blind-on-test-from-book/49830/1 "2005-12-09T00:46:00Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mailing](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f475e1/32.png) [@mailing](https://www.ruby-forum.com/u/mailing)\
**Post date:** [December 9, 2005, 1:47am UTC](https://www.ruby-forum.com/t/newbie-going-blind-on-test-from-book/49830/2 "2005-12-09T01:47:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mailing](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f475e1/32.png) [@mailing](https://www.ruby-forum.com/u/mailing)\
**Post date:** [December 9, 2005, 9:59am UTC](https://www.ruby-forum.com/t/newbie-going-blind-on-test-from-book/49830/3 "2005-12-09T09:59:45Z")

</div>

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, removed\_email\_address@domain.invalid tried to type  
something like:

> ```
> 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!
