def test_check_for_validity post=County.new(:name=>"myname",:description=>"mydesc") assert post.save end above is the method and when i run unit test it is saying as 1) Failure: test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: <false> is not true. what does it say i cannot under stand please help -- Karthik.k Mobile - +91-9894991640 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> def test_check_for_validity > post=County.new(:name=>"myname",:description=>"mydesc") > assert post.save > end > > above is the method and when i run unit test it is saying as > > 1) Failure: > test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: > <false> is not true. > > what does it say i cannot under stand >It is saying that the post.save failed (the assert is expecting true, so false makes the test fail). Possibly your validations are failing. If you put the line assert post.valid?, post.errors.full_messages before the save this will check the item for validity before attempting to save it and show you any errors from validations (I think). Colin
Hi Colin Thank you very much can you please guide me for testing purpose because i am very new to ruby on rails -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > def test_check_for_validity > > post=County.new(:name=>"myname",:description=>"mydesc") > > assert post.save > > end > > > > above is the method and when i run unit test it is saying as > > > > 1) Failure: > > test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: > > <false> is not true. > > > > what does it say i cannot under stand > > > > It is saying that the post.save failed (the assert is expecting true, > so false makes the test fail). Possibly your validations are failing. > If you put the line > > assert post.valid?, post.errors.full_messages > > before the save this will check the item for validity before > attempting to save it and show you any errors from validations (I > think). > > Colin > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi Colin > > Thank you very much > > can you please guide me for testing purpose because i am very new to ruby on > rails >Did you try what I suggested? If you have not already done so I would look at the RoR guides at http://guides.rubyonrails.org/ particularly Getting Started and Testing Rails Applications. Also the rest of them in fact. Colin> > -- > Karthik.k > Mobile - +91-9894991640 > > > On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > def test_check_for_validity >> > post=County.new(:name=>"myname",:description=>"mydesc") >> > assert post.save >> > end >> > >> > above is the method and when i run unit test it is saying as >> > >> > 1) Failure: >> > test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: >> > <false> is not true. >> > >> > what does it say i cannot under stand >> > >> >> It is saying that the post.save failed (the assert is expecting true, >> so false makes the test fail). Possibly your validations are failing. >> If you put the line >> >> assert post.valid?, post.errors.full_messages >> >> before the save this will check the item for validity before >> attempting to save it and show you any errors from validations (I >> think). >> >> Colin >> >> > > > > > > >
Hi Colin Thank you I saw that link but as a fresher not able to understand but if i have any doubt please guide me -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 1:40 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > Hi Colin > > > > Thank you very much > > > > can you please guide me for testing purpose because i am very new to ruby > on > > rails > > > > Did you try what I suggested? > > If you have not already done so I would look at the RoR guides at > http://guides.rubyonrails.org/ particularly Getting Started and > Testing Rails Applications. Also the rest of them in fact. > > Colin > > > > > -- > > Karthik.k > > Mobile - +91-9894991640 > > > > > > On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> > >> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> > def test_check_for_validity > >> > post=County.new(:name=>"myname",:description=>"mydesc") > >> > assert post.save > >> > end > >> > > >> > above is the method and when i run unit test it is saying as > >> > > >> > 1) Failure: > >> > test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: > >> > <false> is not true. > >> > > >> > what does it say i cannot under stand > >> > > >> > >> It is saying that the post.save failed (the assert is expecting true, > >> so false makes the test fail). Possibly your validations are failing. > >> If you put the line > >> > >> assert post.valid?, post.errors.full_messages > >> > >> before the save this will check the item for validity before > >> attempting to save it and show you any errors from validations (I > >> think). > >> > >> Colin > >> > >> > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 1, 9:13 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin > > Thank you > I saw that link but as a fresher not able to understand > but if i have any doubt please guide meLike Colin said, your test is asserting that the record is saved successfully. The most likely reason for this failing is if your model has validations that are not being satisfied (and one way of working out which one and why is to do as Colin suggested). Fred> > -- > Karthik.k > Mobile - +91-9894991640 > > > > On Sat, Aug 1, 2009 at 1:40 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > Hi Colin > > > > Thank you very much > > > > can you please guide me for testing purpose because i am very new to ruby > > on > > > rails > > > Did you try what I suggested? > > > If you have not already done so I would look at the RoR guides at > >http://guides.rubyonrails.org/particularly Getting Started and > > Testing Rails Applications. Also the rest of them in fact. > > > Colin > > > > -- > > > Karthik.k > > > Mobile - +91-9894991640 > > > > On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > >> 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > >> > def test_check_for_validity > > >> > post=County.new(:name=>"myname",:description=>"mydesc") > > >> > assert post.save > > >> > end > > > >> > above is the method and when i run unit test it is saying as > > > >> > 1) Failure: > > >> > test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: > > >> > <false> is not true. > > > >> > what does it say i cannot under stand > > > >> It is saying that the post.save failed (the assert is expecting true, > > >> so false makes the test fail). Possibly your validations are failing. > > >> If you put the line > > > >> assert post.valid?, post.errors.full_messages > > > >> before the save this will check the item for validity before > > >> attempting to save it and show you any errors from validations (I > > >> think). > > > >> Colin
hi Fred Thank you I will do the same -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 2:13 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Aug 1, 9:13 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi Colin > > > > Thank you > > I saw that link but as a fresher not able to understand > > but if i have any doubt please guide me > > Like Colin said, your test is asserting that the record is saved > successfully. The most likely reason for this failing is if your model > has validations that are not being satisfied (and one way of working > out which one and why is to do as Colin suggested). > > Fred > > > > -- > > Karthik.k > > Mobile - +91-9894991640 > > > > > > > > On Sat, Aug 1, 2009 at 1:40 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > Hi Colin > > > > > > Thank you very much > > > > > > can you please guide me for testing purpose because i am very new to > ruby > > > on > > > > rails > > > > > Did you try what I suggested? > > > > > If you have not already done so I would look at the RoR guides at > > >http://guides.rubyonrails.org/particularly Getting Started and > > > Testing Rails Applications. Also the rest of them in fact. > > > > > Colin > > > > > > -- > > > > Karthik.k > > > > Mobile - +91-9894991640 > > > > > > On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > > wrote: > > > > > >> 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > >> > def test_check_for_validity > > > >> > post=County.new(:name=>"myname",:description=>"mydesc") > > > >> > assert post.save > > > >> > end > > > > > >> > above is the method and when i run unit test it is saying as > > > > > >> > 1) Failure: > > > >> > test_check_for_validity(CountyTest) > [/test/unit/county_test.rb:10]: > > > >> > <false> is not true. > > > > > >> > what does it say i cannot under stand > > > > > >> It is saying that the post.save failed (the assert is expecting > true, > > > >> so false makes the test fail). Possibly your validations are > failing. > > > >> If you put the line > > > > > >> assert post.valid?, post.errors.full_messages > > > > > >> before the save this will check the item for validity before > > > >> attempting to save it and show you any errors from validations (I > > > >> think). > > > > > >> Colin > > >-- Karthik.k Mobile - +91-9894991640 http://kkarthikresume.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hi i am updating the data in unit testing def test_for_update post=counties(:one) assert post.valid?, post.errors.full_messages assert post.update_attributes(:name=>"") end name should not be empty but as you said i displayed "assert post.valid?, post.errors.full_messages" But i am not getting error message in assert but getting error message please let me know whether i am right or wrong please help -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 2:46 PM, karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi Fred > > Thank you > > I will do the same > > > -- > Karthik.k > Mobile - +91-9894991640 > > > On Sat, Aug 1, 2009 at 2:13 PM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> >> On Aug 1, 9:13 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hi Colin >> > >> > Thank you >> > I saw that link but as a fresher not able to understand >> > but if i have any doubt please guide me >> >> Like Colin said, your test is asserting that the record is saved >> successfully. The most likely reason for this failing is if your model >> has validations that are not being satisfied (and one way of working >> out which one and why is to do as Colin suggested). >> >> Fred >> > >> > -- >> > Karthik.k >> > Mobile - +91-9894991640 >> > >> > >> > >> > On Sat, Aug 1, 2009 at 1:40 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> wrote: >> > >> > > 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > > > Hi Colin >> > >> > > > Thank you very much >> > >> > > > can you please guide me for testing purpose because i am very new to >> ruby >> > > on >> > > > rails >> > >> > > Did you try what I suggested? >> > >> > > If you have not already done so I would look at the RoR guides at >> > >http://guides.rubyonrails.org/particularly Getting Started and >> > > Testing Rails Applications. Also the rest of them in fact. >> > >> > > Colin >> > >> > > > -- >> > > > Karthik.k >> > > > Mobile - +91-9894991640 >> > >> > > > On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> > > wrote: >> > >> > > >> 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > > >> > def test_check_for_validity >> > > >> > post=County.new(:name=>"myname",:description=>"mydesc") >> > > >> > assert post.save >> > > >> > end >> > >> > > >> > above is the method and when i run unit test it is saying as >> > >> > > >> > 1) Failure: >> > > >> > test_check_for_validity(CountyTest) >> [/test/unit/county_test.rb:10]: >> > > >> > <false> is not true. >> > >> > > >> > what does it say i cannot under stand >> > >> > > >> It is saying that the post.save failed (the assert is expecting >> true, >> > > >> so false makes the test fail). Possibly your validations are >> failing. >> > > >> If you put the line >> > >> > > >> assert post.valid?, post.errors.full_messages >> > >> > > >> before the save this will check the item for validity before >> > > >> attempting to save it and show you any errors from validations (I >> > > >> think). >> > >> > > >> Colin >> >> >> > > > -- > Karthik.k > Mobile - +91-9894991640 > http://kkarthikresume.blogspot.com/ >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> hi > i am updating the data in unit testing > > def test_for_update > post=counties(:one) > assert post.valid?, post.errors.full_messages > assert post.update_attributes(:name=>"") > end > > > name should not be empty but as you said i displayed > > "assert post.valid?, post.errors.full_messages" > > But i am not getting error message in assert but getting error messageWhat is the error message you see (all of it) Colin
hi Colin 1) Failure: test_for_update(CountyTest) [test/unit/county_test.rb:19]: Name has already been taken. <false> is not true. -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 3:59 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > hi > > i am updating the data in unit testing > > > > def test_for_update > > post=counties(:one) > > assert post.valid?, post.errors.full_messages > > assert post.update_attributes(:name=>"") > > end > > > > > > name should not be empty but as you said i displayed > > > > "assert post.valid?, post.errors.full_messages" > > > > But i am not getting error message in assert but getting error message > > What is the error message you see (all of it) > > Colin > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> hi Colin > > 1) Failure: > test_for_update(CountyTest) [test/unit/county_test.rb:19]: > Name has already been taken. > <false> is not true. > >Could you reply with your comments inserted into the existing email please rather than at the top, it makes it much easier to follow the thread, so your comment above should have been after my bit asking for the error. Have you got a validates_uniqueness_of :name? I think the error means there are two with the same name. If you can''t see the problem post your counties.yml. Earlier it was suggested that you look at the rails guides Getting Started and Testing. Have you done that and do you understand all that is in them? (Or at least understand most of it) Colin> > -- > Karthik.k > Mobile - +91-9894991640 > > > > On Sat, Aug 1, 2009 at 3:59 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > hi >> > i am updating the data in unit testing >> > >> > def test_for_update >> > post=counties(:one) >> > assert post.valid?, post.errors.full_messages >> > assert post.update_attributes(:name=>"") >> > end >> > >> > >> > name should not be empty but as you said i displayed >> > >> > "assert post.valid?, post.errors.full_messages" >> > >> > But i am not getting error message in assert but getting error message >> >> What is the error message you see (all of it) >> >> Colin >> >> > > > > > > >
My Question def test_check_for_validity post=County.new(:name=>"myname",:description=>"mydesc") assert post.save end above is the method and when i run unit test it is saying as 1) Failure: test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: <false> is not true. what does it say i cannot under stand please help your answer It is saying that the post.save failed (the assert is expecting true, so false makes the test fail). Possibly your validations are failing. If you put the line assert post.valid?, post.errors.full_messages before the save this will check the item for validity before attempting to save it and show you any errors from validations (I think). Colin My question> hi > i am updating the data in unit testing > > def test_for_update > post=counties(:one) > assert post.valid?, post.errors.full_messages > assert post.update_attributes(:name=>"") > end > > > name should not be empty but as you said i displayed > > "assert post.valid?, post.errors.full_messages" > > But i am not getting error message in assert but getting error messageOn Sat, Aug 1, 2009 at 4:26 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > hi Colin > > > > 1) Failure: > > test_for_update(CountyTest) [test/unit/county_test.rb:19]: > > Name has already been taken. > > <false> is not true. > > > > >your answer> > Could you reply with your comments inserted into the existing email > please rather than at the top, it makes it much easier to follow the > thread, so your comment above should have been after my bit asking for > the error. > > Have you got a validates_uniqueness_of :name? I think the error means > there are two with the same name. If you can''t see the problem post > your counties.yml. > > Earlier it was suggested that you look at the rails guides Getting > Started and Testing. Have you done that and do you understand all > that is in them? (Or at least understand most of it) > > Colin > >Yes i have validates_uniqueness_of :name what i need to do please help karthik.k --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Colin I got it we need to give like below assert post.update_attributes(:name=>"") ,post.errors.full_messages -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 4:44 PM, karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> My Question > > def test_check_for_validity > post=County.new(:name=>" > myname",:description=>"mydesc") > assert post.save > end > > above is the method and when i run unit test it is saying as > > 1) Failure: > test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: > <false> is not true. > > what does it say i cannot under stand > > please help > > your answer > > It is saying that the post.save failed (the assert is expecting true, > so false makes the test fail). Possibly your validations are failing. > If you put the line > > assert post.valid?, post.errors.full_messages > > before the save this will check the item for validity before > attempting to save it and show you any errors from validations (I > think). > > Colin > > > My question > > > hi > > i am updating the data in unit testing > > > > def test_for_update > > post=counties(:one) > > assert post.valid?, post.errors.full_messages > > assert post.update_attributes(:name=>"") > > end > > > > > > name should not be empty but as you said i displayed > > > > "assert post.valid?, post.errors.full_messages" > > > > But i am not getting error message in assert but getting error message > > > > On Sat, Aug 1, 2009 at 4:26 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> >> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > hi Colin >> > >> > 1) Failure: >> > test_for_update(CountyTest) [test/unit/county_test.rb:19]: >> > Name has already been taken. >> > <false> is not true. >> > >> > >> > your answer > >> >> Could you reply with your comments inserted into the existing email >> please rather than at the top, it makes it much easier to follow the >> thread, so your comment above should have been after my bit asking for >> the error. >> >> Have you got a validates_uniqueness_of :name? I think the error means >> there are two with the same name. If you can''t see the problem post >> your counties.yml. >> >> Earlier it was suggested that you look at the rails guides Getting >> Started and Testing. Have you done that and do you understand all >> that is in them? (Or at least understand most of it) >> >> Colin >> >> > > Yes > i have validates_uniqueness_of :name > > what i need to do > please help > > karthik.k >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi colin On small help below is the code or checking for uniquness def test_check_for_uniqueness_name post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") assert post.valid?, "post was not valid #{post.errors.inspect}" post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") assert post1.valid?, post1.errors.full_messages assert_not_nil post1.errors.on(:name) end when i run unit testing 1) Failure: test_check_for_uniqueness_name(CountyTest) [test/unit/county_test.rb:26]: <nil> expected to not be nil. what i am making mistake can you please guide me -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 4:56 PM, karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin > > I got it > > we need to give like below > > assert post.update_attributes(:name=>"") ,post.errors.full_messages > > > -- > Karthik.k > Mobile - +91-9894991640 > > On Sat, Aug 1, 2009 at 4:44 PM, karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> My Question >> >> def test_check_for_validity >> post=County.new(:name=>" >> myname",:description=>"mydesc") >> assert post.save >> end >> >> above is the method and when i run unit test it is saying as >> >> 1) Failure: >> test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: >> <false> is not true. >> >> what does it say i cannot under stand >> >> please help >> >> your answer >> >> It is saying that the post.save failed (the assert is expecting true, >> so false makes the test fail). Possibly your validations are failing. >> If you put the line >> >> assert post.valid?, post.errors.full_messages >> >> before the save this will check the item for validity before >> attempting to save it and show you any errors from validations (I >> think). >> >> Colin >> >> >> My question >> >> > hi >> > i am updating the data in unit testing >> > >> > def test_for_update >> > post=counties(:one) >> > assert post.valid?, post.errors.full_messages >> > assert post.update_attributes(:name=>"") >> > end >> > >> > >> > name should not be empty but as you said i displayed >> > >> > "assert post.valid?, post.errors.full_messages" >> > >> > But i am not getting error message in assert but getting error message >> >> >> >> On Sat, Aug 1, 2009 at 4:26 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >>> >>> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >>> > hi Colin >>> > >>> > 1) Failure: >>> > test_for_update(CountyTest) [test/unit/county_test.rb:19]: >>> > Name has already been taken. >>> > <false> is not true. >>> > >>> > >>> >> your answer >> >>> >>> Could you reply with your comments inserted into the existing email >>> please rather than at the top, it makes it much easier to follow the >>> thread, so your comment above should have been after my bit asking for >>> the error. >>> >>> Have you got a validates_uniqueness_of :name? I think the error means >>> there are two with the same name. If you can''t see the problem post >>> your counties.yml. >>> >>> Earlier it was suggested that you look at the rails guides Getting >>> Started and Testing. Have you done that and do you understand all >>> that is in them? (Or at least understand most of it) >>> >>> Colin >>> >>> >> >> Yes >> i have validates_uniqueness_of :name >> >> what i need to do >> please help >> >> karthik.k >> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi colin > > On small help > > below is the code or checking for uniquness > > def test_check_for_uniqueness_name > post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") > assert post.valid?, "post was not valid #{post.errors.inspect}" > > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") > assert post1.valid?, post1.errors.full_messages > assert_not_nil post1.errors.on(:name) > end > > when i run unit testing > > 1) Failure: > test_check_for_uniqueness_name(CountyTest) [test/unit/county_test.rb:26]: > <nil> expected to not be nil. >You have said in the test that you expect post1.errors.on(:name) not to be nil, but the test fails because it is in fact nil. Why did you expect it not to be nil? Colin
Hi Colin the name field is made as validates_uniqueness_of :name so please let me know what i did is right or wrong though the name is different it is providing the error message Is this the right way to check uniqueness I got the information from from http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of Please help -- Karthik.k Mobile - +91-9894991640 On Sat, Aug 1, 2009 at 6:43 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > Hi colin > > > > On small help > > > > below is the code or checking for uniquness > > > > def test_check_for_uniqueness_name > > > post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") > > assert post.valid?, "post was not valid #{post.errors.inspect}" > > > > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") > > assert post1.valid?, post1.errors.full_messages > > assert_not_nil post1.errors.on(:name) > > end > > > > when i run unit testing > > > > 1) Failure: > > test_check_for_uniqueness_name(CountyTest) [test/unit/county_test.rb:26]: > > <nil> expected to not be nil. > > > > You have said in the test that you expect post1.errors.on(:name) not > to be nil, but the test fails because it is in fact nil. Why did you > expect it not to be nil? > > Colin > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2009/8/4 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi Colin > > the name field is made as > > validates_uniqueness_of :name > > so please let me know what i did is right or wrong > though the name is different it is providing the error message > > Is this the right way to check uniqueness > > I got the information from from > > http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of >Please do not top post, insert your question in the right place in other peoples responses. It is much easier then to follow the thread. You have not answered my previous questions. See below.> Please help > > > -- > Karthik.k > Mobile - +91-9894991640 > > > On Sat, Aug 1, 2009 at 6:43 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > Hi colin >> > >> > On small help >> > >> > below is the code or checking for uniquness >> > >> > def test_check_for_uniqueness_name >> > >> > post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") >> > assert post.valid?, "post was not valid #{post.errors.inspect}" >> > >> > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") >> > assert post1.valid?, post1.errors.full_messages >> > assert_not_nil post1.errors.on(:name) >> > end >> > >> > when i run unit testing >> > >> > 1) Failure: >> > test_check_for_uniqueness_name(CountyTest) >> > [test/unit/county_test.rb:26]: >> > <nil> expected to not be nil. >> > >> >> You have said in the test that you expect post1.errors.on(:name) not >> to be nil, but the test fails because it is in fact nil. Why did you >> expect it not to be nil?You still have not answered this question - in the test shown why did you expect post1.errors.on(:name) to be not nil?. When you reply please put your answer after here so that we can see what you are replying to: Also you have not replied to a previous question I asked:> Earlier it was suggested that you look at the rails guides Getting > Started and Testing. Have you done that and do you understand all > that is in them? (Or at least understand most of it)Colin
On Tue, Aug 4, 2009 at 12:43 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/8/4 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > Hi Colin > > > > the name field is made as > > > > validates_uniqueness_of :name > > > > so please let me know what i did is right or wrong > > though the name is different it is providing the error message > > > > Is this the right way to check uniqueness > > > > I got the information from from > > > > http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of > > > > Please do not top post, insert your question in the right place in > other peoples responses. It is much easier then to follow the thread. > You have not answered my previous questions. See below. > > > Please help > > > > > > -- > > Karthik.k > > Mobile - +91-9894991640 > > > > > > On Sat, Aug 1, 2009 at 6:43 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> > >> 2009/8/1 karthik k <cse.k.karthik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> > Hi colin > >> > > >> > On small help > >> > > >> > below is the code or checking for uniquness > >> > > >> > def test_check_for_uniqueness_name > >> > > >> > > post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") > >> > assert post.valid?, "post was not valid #{post.errors.inspect}" > >> > > >> > > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") > >> > assert post1.valid?, post1.errors.full_messages > >> > assert_not_nil post1.errors.on(:name) > >> > end > >> > > >> > when i run unit testing > >> > > >> > 1) Failure: > >> > test_check_for_uniqueness_name(CountyTest) > >> > [test/unit/county_test.rb:26]: > >> > <nil> expected to not be nil. > >> > > >> > >> You have said in the test that you expect post1.errors.on(:name) not > >> to be nil, but the test fails because it is in fact nil. Why did you > >> expect it not to be nil? > > You still have not answered this question - in the test shown why did > you expect post1.errors.on(:name) to be not nil?. When you reply > please put your answer after here so that we can see what you are > replying to:I got that post from the below link http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of So i tried to use and check> > Also you have not replied to a previous question I asked: > > Earlier it was suggested that you look at the rails guides Getting > > Started and Testing. Have you done that and do you understand all > > that is in them? (Or at least understand most of it) >Ya I studied the guide but they did not explain fully as i am new to ruby on rails i have basic doubt "how it happens" Though ruby on rails say coding by convention When i search for any document there are some version conflict i am using 2.3.2 (as my client needs) this is where i am standing i am a java developer with struts, flex etc but ruby on rails is very new so thats why i have this much queries If i am wrong i am sorry> > > > Colin > > > >-- Karthik.k Mobile - +91-9894991640 http://kkarthikresume.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 4, 5:05 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin > > the name field is made as > > validates_uniqueness_of :name >Your test is not consistent: you first assert that post1 is valid, then you assert that it has an error on the name column - clearly these cannot both be true. Fred> so please let me know what i did is right or wrong > though the name is different it is providing the error message > > Is this the right way to check uniqueness > > I got the information from from > > http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of > > Please help > > -- > Karthik.k > Mobile - +91-9894991640 > > > > On Sat, Aug 1, 2009 at 6:43 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > Hi colin > > > > On small help > > > > below is the code or checking for uniquness > > > > def test_check_for_uniqueness_name > > > post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") > > > assert post.valid?, "post was not valid #{post.errors.inspect}" > > > > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") > > > assert post1.valid?, post1.errors.full_messages > > > assert_not_nil post1.errors.on(:name) > > > end > > > > when i run unit testing > > > > 1) Failure: > > > test_check_for_uniqueness_name(CountyTest) [test/unit/county_test.rb:26]: > > > <nil> expected to not be nil. > > > You have said in the test that you expect post1.errors.on(:name) not > > to be nil, but the test fails because it is in fact nil. Why did you > > expect it not to be nil? > > > Colin
On Tue, Aug 4, 2009 at 2:19 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Aug 4, 5:05 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi Colin > > > > the name field is made as > > > > validates_uniqueness_of :name > > > > Your test is not consistent: you first assert that post1 is valid, > then you assert that it has an error on the name column - clearly > these cannot both be true. > > Fredhi Fred def test_check_for_uniqueness_name post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") assert post.valid?, "post was not valid #{post.errors.inspect}" assert post.save post1=County.new(:name=>"myname",:description=>"mydesc",:region_id=>"4") assert post1.valid?, post1.errors.full_messages assert post1.save end above is my code and worked fine for uniqueness I two name is same then it provides error message else it succeeds plz let me know whether i am right or wrong> > > so please let me know what i did is right or wrong > > though the name is different it is providing the error message > > > > Is this the right way to check uniqueness > > > > I got the information from from > > > > http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of > > > > Please help > > > > -- > > Karthik.k > > Mobile - +91-9894991640 > > > > > > > > On Sat, Aug 1, 2009 at 6:43 PM, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > 2009/8/1 karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > Hi colin > > > > > > On small help > > > > > > below is the code or checking for uniquness > > > > > > def test_check_for_uniqueness_name > > > > > > post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3") > > > > assert post.valid?, "post was not valid #{post.errors.inspect}" > > > > > > > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4") > > > > assert post1.valid?, post1.errors.full_messages > > > > assert_not_nil post1.errors.on(:name) > > > > end > > > > > > when i run unit testing > > > > > > 1) Failure: > > > > test_check_for_uniqueness_name(CountyTest) > [test/unit/county_test.rb:26]: > > > > <nil> expected to not be nil. > > > > > You have said in the test that you expect post1.errors.on(:name) not > > > to be nil, but the test fails because it is in fact nil. Why did you > > > expect it not to be nil? > > > > > Colin > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 4, 9:56 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Aug 4, 2009 at 2:19 PM, Frederick Cheung <frederick.che...@gmail.com > above is my code and worked fine for uniqueness > > I two name is same then it provides error message else it succeeds > > plz let me know whether i am right or wrongI can''t tell that - I don''t know what you are trying to test. Right or wrong doesn''t really mean much in this context - a perfectly valid test could be considered ''wrong'' if it didn''t test what you thought it would and right if it did. Fred
On Tue, Aug 4, 2009 at 2:29 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Aug 4, 9:56 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Tue, Aug 4, 2009 at 2:19 PM, Frederick Cheung < > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > above is my code and worked fine for uniqueness > > > > I two name is same then it provides error message else it succeeds > > > > plz let me know whether i am right or wrong > > I can''t tell that - I don''t know what you are trying to test. Right or > wrong doesn''t really mean much in this context - a perfectly valid > test could be considered ''wrong'' if it didn''t test what you thought it > would and right if it did. > > FredThank you Fred can you please guide me to the below link http://www.ruby-forum.com/topic/192712#new It is for functional testing> > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Karthik Do you have any issues now in testing? On Aug 4, 2:01 pm, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Aug 4, 2009 at 2:29 PM, Frederick Cheung <frederick.che...@gmail.com > > > > > > > wrote: > > > On Aug 4, 9:56 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Tue, Aug 4, 2009 at 2:19 PM, Frederick Cheung < > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > above is my code and worked fine for uniqueness > > > > I two name is same then it provides error message else it succeeds > > > > plz let me know whether i am right or wrong > > > I can''t tell that - I don''t know what you are trying to test. Right or > > wrong doesn''t really mean much in this context - a perfectly valid > > test could be considered ''wrong'' if it didn''t test what you thought it > > would and right if it did. > > > Fred > > Thank you Fred > > can you please guide me to the below link > > http://www.ruby-forum.com/topic/192712#new > > It is for functional testing > > > >
On Tue, Aug 11, 2009 at 3:12 PM, Anurag <anuraag.jpr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Karthik > > Do you have any issues now in testing? > > On Aug 4, 2:01 pm, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Tue, Aug 4, 2009 at 2:29 PM, Frederick Cheung < > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > > > >hi Anurag thank you for your response i need to do functional testing can you plz giude me for this -- Karthik.k Mobile - +91-9894991640> > > > > > > wrote: > > > > > On Aug 4, 9:56 am, karthik k <cse.k.kart...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Tue, Aug 4, 2009 at 2:19 PM, Frederick Cheung < > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > above is my code and worked fine for uniqueness > > > > > > I two name is same then it provides error message else it succeeds > > > > > > plz let me know whether i am right or wrong > > > > > I can''t tell that - I don''t know what you are trying to test. Right or > > > wrong doesn''t really mean much in this context - a perfectly valid > > > test could be considered ''wrong'' if it didn''t test what you thought it > > > would and right if it did. > > > > > Fred > > > > Thank you Fred > > > > can you please guide me to the below link > > > > http://www.ruby-forum.com/topic/192712#new > > > > It is for functional testing > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---