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

Hello all,
please review the code parts here :
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”=>“[email protected]”}>,
#<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”=>“[email protected]”}>]>.
2 tests, 10 assertions, 1 failures, 0 errors

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

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

Peter,

You could also use:
assert_equal 2, Buyer.count

Cody

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