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"=>"bob-J0of1frlU80@public.gmane.org"}>, #<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"=>"mary-J0of1frlU80@public.gmane.org"}>]>. 2 tests, 10 assertions, 1 failures, 0 errors Please tell me I''m missing something very very obvious? -- Peter Fitzgibbons _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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 On 11/14/05, Peter Fitzgibbons <peter.fitzgibbons-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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"=>"bob-J0of1frlU80@public.gmane.org"}>, > #<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"=>"mary-J0of1frlU80@public.gmane.org "}>]>. > 2 tests, 10 assertions, 1 failures, 0 errors > > Please tell me I''m missing something very very obvious? > -- > Peter Fitzgibbons > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Peter, You could also use: assert_equal 2, Buyer.count Cody On 11/14/05, Graeme Nelson <graeme.nelson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > On 11/14/05, Peter Fitzgibbons <peter.fitzgibbons-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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"=>" bob-J0of1frlU80@public.gmane.org"}>, > > #<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"=>" mary-J0of1frlU80@public.gmane.org "}>]>. > > 2 tests, 10 assertions, 1 failures, 0 errors > > > > Please tell me I''m missing something very very obvious? > > -- > > Peter Fitzgibbons > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Peter Fitzgibbons
2005-Nov-14 16:46 UTC
Re: #find(:all) not finding all from fixture -- help?
HI Graeme, Thank you! Some days I am just not in the Ruby Way. On 11/14/05, Graeme Nelson <graeme.nelson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > > On 11/14/05, Peter Fitzgibbons <peter.fitzgibbons-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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"=>" bob-J0of1frlU80@public.gmane.org"}>, > > #<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"=>" mary-J0of1frlU80@public.gmane.org "}>]>. > > 2 tests, 10 assertions, 1 failures, 0 errors > > > > Please tell me I''m missing something very very obvious? > > -- > > Peter Fitzgibbons > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Peter Fitzgibbons _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails