# \#find(:all) not finding all from fixture -- help?

**URL:** <https://www.ruby-forum.com/t/find-all-not-finding-all-from-fixture-help/47859>\
**Category:** Rails\
**Created:** [November 14, 2005, 5:29pm UTC](https://www.ruby-forum.com/t/find-all-not-finding-all-from-fixture-help/47859 "2005-11-14T17:29:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.fitzgibbons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/838e76/32.png) [@peter.fitzgibbons](https://www.ruby-forum.com/u/peter.fitzgibbons)\
**Post date:** [November 14, 2005, 5:29pm UTC](https://www.ruby-forum.com/t/find-all-not-finding-all-from-fixture-help/47859/1 "2005-11-14T17:29:18Z")

</div>

Hello all,  
please review the code parts here :  
[http://rafb.net/paste/results/CZTw2063.html](http://rafb.net/paste/results/CZTw2063.html)  
Briefly: Buyer belongs\_to :family and :user. User has\_one :buyer. Family  
has\_many :buyer.

When I run this test :

class BuyerTest \< Test::Unit::TestCase

def test\_yaml  
assert\_not\_nil Buyer.find(4000)  
assert\_not\_nil Buyer.find(4001)

assert\_equal 2, Buyer.find(:all)  
end  
end

I get this failure :

Loaded suite C:/ruby/dev/buildview2/test/unit/buyer\_test  
Started  
.F  
Finished in 0.562 seconds.

1. Failure:

test\_yaml(BuyerTest)  
[C:/ruby/dev/buildview2/test/unit/buyer\_test.rb:13]:test\_yaml(BuyerTest)  
[C:/ruby/dev/buildview2/test/unit/buyer\_test.rb:13]:

\<2\> expected but was

\<[#\<Buyer:0x3a0c9a0  
@attributes=  
{“family\_id”=\>5000,  
“created\_on”=\>“2005/01/01 00:00:00”,  
“work\_phone”=\>“(123) 123-1231”,  
“city”=\>“Buyer City”,  
“postal\_code”=\>“12345”,  
“email\_active”=\>1,  
“region”=\>“IL”,  
“updated\_on”=\>“2005/01/01 00:00:00”,  
“ssn”=\>“123121233”,  
“lock\_version”=\>0,  
“country”=\>“USA”,  
“id”=\>4000,  
“cell\_phone”=\>“(123) 123-1231”,  
“address\_line\_1”=\>“Buyer Address 1”,  
“sex”=\>“M”,  
“home\_phone”=\>“(123) 123-1231”,  
“address\_line\_2”=\>“Buyer Address 2”,  
“user\_id”=\>1,  
“date\_of\_birth”=\>nil,  
“first\_name”=\>“Bob”,  
“last\_name”=\>“Buyer”,  
“middle\_name”=\>“”,  
“email”=\>“removed\_email\_address@domain.invalid”}\>,  
#\<Buyer:0x3a0c940  
@attributes=  
{“family\_id”=\>5000,  
“created\_on”=\>“2005/01/01 00:00:00”,  
“work\_phone”=\>“(123) 123-1231”,  
“city”=\>“Buyer City”,  
“postal\_code”=\>“12345”,  
“email\_active”=\>1,  
“region”=\>“IL”,  
“updated\_on”=\>“2005/01/01 00:00:00”,  
“ssn”=\>“123121233”,  
“lock\_version”=\>0,  
“country”=\>“USA”,  
“id”=\>4001,  
“cell\_phone”=\>“(123) 123-1231”,  
“address\_line\_1”=\>“Buyer Address 1”,  
“sex”=\>“F”,  
“home\_phone”=\>“(123) 123-1231”,  
“address\_line\_2”=\>“Buyer Address 2”,  
“user\_id”=\>5,  
“date\_of\_birth”=\>nil,  
“first\_name”=\>“Mary”,  
“last\_name”=\>“Buyer”,  
“middle\_name”=\>“”,  
“email”=\>“removed\_email\_address@domain.invalid”}\>]\>.  
2 tests, 10 assertions, 1 failures, 0 errors

Please tell me I’m missing something very very obvious?

---

<div class="post-metadata">

**Author:** ![peter.fitzgibbons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/838e76/32.png) [@peter.fitzgibbons](https://www.ruby-forum.com/u/peter.fitzgibbons)\
**Post date:** [November 14, 2005, 5:38pm UTC](https://www.ruby-forum.com/t/find-all-not-finding-all-from-fixture-help/47859/2 "2005-11-14T17:38:19Z")

</div>

Hi Peter -

It looks like you are comparing the value 2 against an array that comes  
back. You should  
probably ask for the size of the array in this case.

assert\_equal 2, Buyer.find(:all).size

Thanks  
graeme

---

<div class="post-metadata">

**Author:** ![peter.fitzgibbons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/838e76/32.png) [@peter.fitzgibbons](https://www.ruby-forum.com/u/peter.fitzgibbons)\
**Post date:** [November 14, 2005, 5:41pm UTC](https://www.ruby-forum.com/t/find-all-not-finding-all-from-fixture-help/47859/3 "2005-11-14T17:41:19Z")

</div>

Peter,

You could also use:  
assert\_equal 2, Buyer.count

Cody

---

<div class="post-metadata">

**Author:** ![peter.fitzgibbons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/838e76/32.png) [@peter.fitzgibbons](https://www.ruby-forum.com/u/peter.fitzgibbons)\
**Post date:** [November 14, 2005, 5:47pm UTC](https://www.ruby-forum.com/t/find-all-not-finding-all-from-fixture-help/47859/4 "2005-11-14T17:47:21Z")

</div>

HI Graeme,  
Thank you! Some days I am just not in the Ruby Way.
